Writing a microprocessor program

Thread Starter

sdonke002

Joined Oct 12, 2010
18
Hello,

I am stuck on a homework problem. I need to write a program that will add any 2 digit bcd number located in memory locations 6100 & 6101. The results need to be placed in the x register and displayed on the terminal.

This is what I have so far. Please let me know what you think.

MVI C,00
LDAA 6100
MOV B,A
LDAA 6101
ADD B
JNC
INR C
(JNC here)STA 6102
MOV A,C
STA 6103
MOV X,A
JSR FFBB
BRA to this location to stop program

If anyone has any input it will be welcome. Thank you!
 

Georacer

Joined Nov 25, 2009
5,182
Which microprocessor is this program written for?

Also, since you are adding BCD numbers, isn't it reasonable for the result to be BCD?
If so, why don't you check the result (temporarily A) if it is longer than 9, and instead you check if it is longer than 15?
 

Thread Starter

sdonke002

Joined Oct 12, 2010
18
This program is written for the MM68HC11 microprocessor. I will work on doing the hex to BCD conversion and post it when I am finished.
Thank you
 

Thread Starter

sdonke002

Joined Oct 12, 2010
18
Ok. I rewrote the program and I think it should work.
Here it is:
LDAA $6100
ADDA $6101
DAA
STAA $6200
LDX $6200
JSR FFBB
BRA (to this location to stop program)

I have walked myself through the program in my head and it seams to work. Any ideas?
Thank you!!
 
Top