Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
05/12/06 16:04
Read: times


 
#116104 - its not working
I am using adc0808 with 4x20 lcd display and i am try smallist asm for bytes to ASCII
but this subroutines is not working,
if u have any other asm so please. advise me thanks
;*******************************************************************************
; Returns the ASCII codes from the nibbles of a byte stored in the Acc.
; After being called the high nibble is in the Acc and the low nibble
; is in the B register.
;
;
; ;usage:
;
; mov a, #byte
; CALL nibble
;
; ;returns
; ;A= high nibble
; ;B= low nibble
;*******************************************************************************

nibble:
mov b,a ; b=a ; stores Acc in B
anl a,#0f0h ; a=xxxx0000 ; A && #f0h (get the high nibble)
swap a ; a=0000xxxx ; swap nibbles
orl a,#30h ; a=0011xxxx ; add #30h, if nibble is
push acc ; 0-9 we have the ASCII value
push b ; stores A and B
mov b, #3ah ; stores #3ah in B
div ab ; divide A/#3ah
jz, recupera1 ; if zero, nibble < #0Ah
nibble1_ok:
pop b ; recover B
pop acc ; recover A
add a, #07h ; adds #07h to get ASCII of A-F
xch a,b
jmp nibble2
recupera1:
pop b ; stores B
pop acc ; stores A
xch a,b
nibble2:
anl a,#0fh ; a=0000xxxx ; A && #0fh (get low nibble)
orl a,#30h ; a=0011xxxx ; add #30h, if nibble is
push acc ; 0-9 we have the ASCII value
push b ; stores A and B
mov b, #3ah ; stores #3ah in B
div ab ; divide A/#3ah
jz, recupera2 ; if zero, nibble < #0Ah
pop b ; recover B
pop acc ; recover A
add a, #07h ; adds #07h to get ASCII of A-F
xch a,b
ret ; return to main routine
recupera2:
pop b ; recover B
pop acc ; recover A
xch a,b
ret ; return to main routine



List of 9 messages in thread
TopicAuthorDate
its not working            01/01/70 00:00      
   Easier to read            01/01/70 00:00      
   Have you tried a simulator?            01/01/70 00:00      
   It works            01/01/70 00:00      
      i have also that            01/01/70 00:00      
   another way:            01/01/70 00:00      
      cute            01/01/70 00:00      
      mr peter            01/01/70 00:00      
         simply...            01/01/70 00:00      

Back to Subject List