flat assembler
Message board for the users of flat assembler.
Index
> DOS > Tutorial: Convert byte to hex |
Author |
|
AsmGuru62 05 Jan 2013, 15:32
This one made my head spin (from ASM JEMS page)!
Code: ; ; input: ; al = single hex digit ; ; output: ; al = single ASCII digit ; ; destroys: ; flags ; cmp al,10 ; if x < 10, set CF = 1 sbb al,69h ; 0-9: 96h .. 9Fh, A-F: A1h..A6h das ; 0-9: subtr. 66h -> 30h-39h, ; A-F: subtr. 60h -> 41h..46h |
|||
05 Jan 2013, 15:32 |
|
Ciper 05 Jan 2013, 16:06
Wow!
And it works: (of course ) Code: org 100h macro print_nibble { xor ch,ch shl cx,4 mov al,ch cmp al,10 sbb al,69h das int 10h } mov cx,0efh ; Byte to convert mov ah,0eh rept 2 {print_nibble} int 20h _________________ Ciper |
|||
05 Jan 2013, 16:06 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.