Daniela Gocheva
Daniela Gocheva

Reputation: 63

8051 Assembly Sum Program With EdSim51

I am newbie when it comes to assembly and 8051, so I need a little help. I want to make this Sum program that saves E887h in 50h and 77DDh in 52h. Then it should Sum them in 70h. I tried making the program, but it looks like I am making mystake somewhere. Here's my code:

mov 50h,#0E877h
mov 52h,#77DDh
mov a,50h
add a,52h
mov 70h,a
end 

Upvotes: 0

Views: 2950

Answers (1)

Jester
Jester

Reputation: 58802

8051 is a 8 bit processor, you will need to split your 16 bit addition into two 8 bit additions, minding the carry. Something like:

mov 50h, #77h   # low byte
mov 51h, #0E8h  # high byte
mov 52h, #0DDh  # low byte
mov 53h, #77h   # high byte
mov a, 50h      # add
add a, 52h      # low bytes
mov 70h, a      # result low byte
mov a, 51h      # add
addc a, 53h     # high bytes and carry
mov 71h, a      # result high byte

Upvotes: 1

Related Questions