Hardware Reference
In-Depth Information
negb
; compute two's complement of quotient
stab
quo
movb
#1,sign
; temperature is negative
ldab
rem
; if remainder is 0, skip a few instructions
beq
convert
;
ldab
#62
; compute 62
2
rem
subb
rem
;
“
stab
rem
;
“
bra
cal_fract
save_quo
stab
quo
; save updated quotient
cal_fract
ldab
rem
beq
convert
; come here when positive
ldaa
#10
; compute fractional digit
mul
;
“
ldx
#62
;
“
idiv
;
“
cmpb
#31
; round off fractional digit
blt
no_round
;
“
inx
;
“
cpx
#10
;
“
bne
no_round
;
“
inc
quo
;
“
bra
convert
; prepare to separate integer digits
no_round
tfr
x,d
; convert fractional digit to ASCII code
addb
#$30
;
“
stab
fract
;
“
convert
ldab
quo
clra
;
“
ldx
#10
; use repeated divide by 10 to separate
idiv
; integral digits
addb
#$30
;
“
stab
buf
1
2
; save the one's digit
tfr
x,d
; transfer quotient to D
tstb
; is quo zero?
beq
add_fra
; if integral part is 0, then add fraction digit
ldx
#10
; separate the ten's digit
idiv
addb
#$30
; convert and store the tens digit
stab
buf
1
1
;
“
tfr
x,d
; test hundreds digit
tstb
; is quotient 0?
beq
add_fra
movb
#$31,buf
; hundreds digit, if any, is 1 only
add_fra
movb
fract,buf
1
4
; insert fraction digit
ldaa
sign
; check the sign
beq
out_it
movb
#$2D,buf
; when minus, add minus character
out_it
ldaa
#$C0
; set cursor to 2nd row
jsr
cmd2lcd
;
“
ldx
#spaces
; clear the 2nd row of the LCD
Search WWH ::
Custom Search