HCS129S12 An Introduction to Software and Hardware Interfaci
HCS12/9S12 An Introduction to Software and Hardware Interfacing #2.9
Write an instruction sequence to add the 4-digit BCD numbers stored at $1000, $1001 and $1002, $ 1003 and store the sum at $1010, 1011.Solution
org $0500
;here we need to take care of decimal adjustment part by daa instruction
lda $1000 ;A <-m[$1000]
adaa $1001 ;A <-A+m [$1001]
daa ;decimal adjust lower byte
staa $1010 ;m[$1010]<-A
lda $1002 ;A <-m[$1002]
adaa $1003 ;A <-A+m [$1003]
daa ;decimal adjust higher byte
staa $1011 ;m[$1011]<-A
