base:8_bit_to_hexadecimal_conversion
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
base:8_bit_to_hexadecimal_conversion [2017-08-10 17:15] – created abujok | base:8_bit_to_hexadecimal_conversion [2017-08-20 00:30] (current) – tww_ctr | ||
---|---|---|---|
Line 49: | Line 49: | ||
</ | </ | ||
+ | |||
+ | |||
+ | Slight optimization: | ||
+ | |||
+ | < | ||
+ | ; | ||
+ | ; print Akku hex value | ||
+ | ; | ||
+ | OUTHEX tax ; | ||
+ | lsr ; ignore CARRY and shift hi nybble to lonybble pos. | ||
+ | lsr ; | ||
+ | lsr ; | ||
+ | lsr ; | ||
+ | jsr NIB2HEX ; print nibble | ||
+ | txa ; restore value | ||
+ | and #$0f ; Low nibble | ||
+ | jsr NIB2HEX ; print nibble | ||
+ | rts | ||
+ | |||
+ | ; | ||
+ | ;* Akku low Nibble to Hex | ||
+ | ; | ||
+ | NIB2HEX cmp #$0a ; Accu >= 10? | ||
+ | bcs HEX ; Yes | ||
+ | adc #$30 ; Accu < 10 | ||
+ | jmp BSOUT ; Print #$30 - #39 | ||
+ | HEX adc #$36 ; Accu >= 10, subtract #$09 to get " | ||
+ | jmp BSOUT ; Print Accu (HEX nibble) and bye | ||
+ | </ | ||
+ | |||
+ | Version not using KERNAL: | ||
+ | |||
+ | < | ||
+ | // Dest. = YREG:XREG | ||
+ | // Value to utput = ACC | ||
+ | OUTHEX: | ||
+ | sty $fb | ||
+ | stx $fc | ||
+ | ldy #$00 | ||
+ | pha | ||
+ | lsr | ||
+ | lsr | ||
+ | lsr | ||
+ | lsr | ||
+ | tax | ||
+ | lda tab,x | ||
+ | sta ($fb),y | ||
+ | iny | ||
+ | pla | ||
+ | and #$0f | ||
+ | tax | ||
+ | lda tab,x | ||
+ | sta ($fb),y | ||
+ | rts | ||
+ | |||
+ | tab: | ||
+ | .text " | ||
+ | </ | ||
+ |
base/8_bit_to_hexadecimal_conversion.txt · Last modified: 2017-08-20 00:30 by tww_ctr