PG1995
Active Member
Hi
I want to add every digit in this number 457-85-9999-1, i.e. 4+5+7+8+.... I'm new to assembly language and using MCU 8051.
One way to do it is given below. How else can I do it efficiently and using few lines without making it complex for myself? Please help me with it. Thank you.
Regards
PG
I want to add every digit in this number 457-85-9999-1, i.e. 4+5+7+8+.... I'm new to assembly language and using MCU 8051.
One way to do it is given below. How else can I do it efficiently and using few lines without making it complex for myself? Please help me with it. Thank you.
Code:
;add all digits of the number 457-85-9999-1
ORG 0H
Repeat:
CLR A
ADD A, #4
ADD A, #5
ADD A, #7
ADD A, #8
ADD A, #5
ADD A, #9
ADD A, #9
ADD A, #9
ADD A, #9
ADD A, #1
SJMP Repeat
END
Regards
PG