MOV R1, R0 ; Store the first ; value in R1
SWI getInt ; Get second value
MOV R2, R0 ; Store in register ; R2
MOV R3, R1 ; R3 = a
ADD R3, R2 ; R3 = a+b
MOV R4, R1 ; R4 = a
MOV R0, R3 ; Copy amswer to R0
SWI putInt ; Operating system ; call to display the ; 16-bit integer in ; R0
HLT ; Terminate program.
- a – b
SWI getInt ; Operating
; system call to ; get a 16 bit ; integer from ; the keyboard. ; Value returned ; in R0
MOV R1, R0 ; Store the first ; value in R1
SWI getInt ; Get second value
MOV R2, R0 ; Store in register ; R2
MOV R3, R1 ; R3 = a
SUB R3, R2 ; R3 = a-b
MOV R4, R1 ; R4 = a
MOV R0, R3 ; Copy amswer to R0
SWI putInt ; Operating system ; call to display the ; 16-bit integer in ; R0
HLT ; Terminate program.
- a x b
SWI getInt ; Operating
; system call to ; get a 16 bit ; integer from ; the keyboard. ; Value returned ; in R0
MOV R1, R0 ; Store the first ; value in R1
SWI getInt ; Get second value
MOV R2, R0 ; Store in register ; R2
MOV R3, R1 ; R3 = a
MUL R3, R2 ; R3 = a x b
MOV R4, R1 ; R4 = a
MOV R0, R3 ; Copy amswer to R0
SWI putInt ; Operating system ; call to display the ; 16-bit integer in ; R0
HLT ; Terminate program.
- a² + b²
SWI getInt ; Operating
; system call to ; get a 16 bit ; integer from ; the keyboard. ; Value returned ; in R0
MOV R1, R0 ; Store the first ; value in R1
SWI getInt ; Get second value
MOV R2, R0 ; Store in register ; R2
MOV R3, R1 ; R3 = a
SUB R3, R2 ; R3 = a - b
MOV R4, R1 ; R4 = a
ADD R4, R2 ; R4 = a + b
MOV R0, R3 ; Copy amswer to R0
SWI putInt ; Operating system ; call to display the ; 16-bit integer in ; R0
HLT ; Terminate program.
- a² + b²
SWI getInt ; Operating
; system call to ; get a 16 bit ; integer from ; the keyboard. ; Value returned ; in R0
MOV R1, R0 ; Store the first ; value in R1
SWI getInt ; Get second value
MOV R2, R0 ; Store in register ; R2
MOV R3, R1 ; R3 = a
ADD R3, R2 ; R3 = a + b
MOV R4, R1 ; R4 = a
SUB R4, R2 ; R4 = a - b
MOV R0, R3 ; Copy amswer to R0
SWI putInt ; Operating system ; call to display the ; 16-bit integer in ; R0
HLT ; Terminate program.