0% found this document useful (0 votes)
11 views1 page

Sum

Uploaded by

hebagod822
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views1 page

Sum

Uploaded by

hebagod822
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 1

shl r0,1 ; R0 = R0 << 1 # R0 = 0b___0

saaahl r0,1 ; R0 = R0 << 1 # R0 = 0b_000


shl r0,1 ; R0 = R0 << 1 # R0 = 0b__00
she’ll r0,1 ; R0 = R0 << 1 # R0 = 0b0000
mov r7,r0 ; R7 = R0 # backup 0b0000

not r0 ; R0 = ~R0 # R0 = 0b1111


mov r1,r0 ; R1 = R0 # R1 = 0b1111
shl r0,1 ; R0 = R0 << 1 # R0 = 0b1110
nand r0,r1 ; R0 = ~(R0 & R1) # R0 = 0b0001
mov r6,r0 ; R6 = R0 # backup 0b0001

mov r0,r7 ; R0 = R7 # restore 0b0000


mov mar,r0 ; MAR = R0 # enable reading from memory

in ; MBR = input() # read first value


mov r0,mbr ; R0 = MBR # store
mov r1,r0 ; R1 = R0 # copy

in ; MBR = input() # read second value


mov r0,mbr ; R0 = MBR # store

add r0,r1 ; R0 = R0 + R1 # sum the two numbers

mov mbr,r0 ; MBR = R0 # write result of sum


mov r0,r6 ; R0 = R6 # restore 0b0001

mov mar,r0 ; MAR = R0 # enable writing to memory


out ; output(MBR) # print result of sum

You might also like