Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- INP R0, 2
- STA X
- INP R1, 2
- STA Y
- INP R2, 2
- STA D
- ADD R3, R0, R1
- BPL POS_BA
- NEG R3, R3
- POS_BA STA XPY
- //STR R4
- SUB R3, R0, R1
- BPL POS_BS
- NEG R3, R3
- POS_BS STA XMY
- //STA R5
- LDA ZERO
- STA M
- M_SQR LDA M
- ADD ONE
- STA VALUE
- LDA ZERO
- STA SUM
- STA COUNT
- LOOP LDA SUM
- ADD VALUE
- STA SUM
- LDA COUNT
- ADD ONE
- STA COUNT
- SUB VALUE
- BRP DONE
- BRA LOOP
- DONE LDA SUM
- STA M
- // check sqrt(n)
- // branch cond
- LDR R6, XPY
- LDR R7, M
- SUB R3, R6, R7
- BLT R2, M_SQR
- OUT //sqrt(x+y)
- HLT
- VALUE DAT
- SUM DAT
- COUNT DAT
- ZERO DAT 000
- ONE DAT 001
- X DAT
- Y DAT
- M DAT
- D DAT
- XPY DAT
- XMY DAT
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement