Advertisement
regzarr

cet_test1

Nov 5th, 2024
7
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. INP R0, 2
  2. STA X
  3. INP R1, 2
  4. STA Y
  5. INP R2, 2
  6. STA D
  7. ADD R3, R0, R1
  8. BPL POS_BA
  9. NEG R3, R3
  10. POS_BA STA XPY
  11. //STR R4
  12. SUB R3, R0, R1
  13. BPL POS_BS
  14. NEG R3, R3
  15. POS_BS STA XMY
  16. //STA R5
  17. LDA ZERO
  18. STA M
  19. M_SQR LDA M
  20. ADD ONE
  21. STA VALUE
  22. LDA ZERO
  23. STA SUM
  24. STA COUNT
  25. LOOP LDA SUM
  26. ADD VALUE
  27. STA SUM
  28. LDA COUNT
  29. ADD ONE
  30. STA COUNT
  31. SUB VALUE
  32. BRP DONE
  33. BRA LOOP
  34. DONE LDA SUM
  35. STA M
  36. // check sqrt(n)
  37. // branch cond
  38. LDR R6, XPY
  39. LDR R7, M
  40. SUB R3, R6, R7
  41. BLT R2, M_SQR
  42. OUT //sqrt(x+y)
  43. HLT
  44. VALUE DAT
  45. SUM DAT
  46. COUNT DAT
  47. ZERO DAT 000
  48. ONE DAT 001
  49. X DAT
  50. Y DAT
  51. M DAT
  52. D DAT
  53. XPY DAT
  54. XMY DAT
  55.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement