User Tools

Site Tools


base:8_bit_to_hexadecimal_conversion

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
base:8_bit_to_hexadecimal_conversion [2017-08-20 00:05] – fixed slight bug tww_ctrbase:8_bit_to_hexadecimal_conversion [2017-08-20 00:17] tww_ctr
Line 58: Line 58:
 ;************************** ;**************************
 OUTHEX tax ; save value for low nibble OUTHEX tax ; save value for low nibble
- and #$f0 ; High nibble +        lsr             ; ignore CARRY and shift hi nybble to lonybble pos.
-        lsr             ; ignore CARRY!+
  lsr ;   lsr ; 
  lsr ;   lsr ; 
Line 68: Line 67:
  jsr NIB2HEX ; print nibble  jsr NIB2HEX ; print nibble
  rts  rts
- 
  
 ;********************* ;*********************
Line 77: Line 75:
         adc #$30 ; Accu < 10         adc #$30 ; Accu < 10
  jmp BSOUT       ; Print #$30 - #39  jmp BSOUT       ; Print #$30 - #39
-HEX sbc #$09 ; Accu >= 10, subtract #$09 to get "A" to "F"+HEX adc #$36 ; Accu >= 10, subtract #$09 to get "A" to "F" (CARRY always set here)
  jmp BSOUT ; Print Accu (HEX nibble) and bye  jmp BSOUT ; Print Accu (HEX nibble) and bye
 </code> </code>
  
-Alternatively, add #$36 (CARRY is set, so effectively becomes #$37) to get upper case characters in lower case mode. Also you can "branch always" after adding #$30 to OUT to save a byte at the expense of 3 cycles. 
base/8_bit_to_hexadecimal_conversion.txt · Last modified: 2017-08-20 00:30 by tww_ctr