Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- org 100h
- use16
- mov ax, 65535
- call ConvertHexToString
- mov si, bx
- call print
- mov ah, 0x0
- int 0x16
- ret
- print:
- lodsb
- cmp al, 0
- je endP
- mov ah, 0xe
- int 10h
- jmp print
- endP:
- ret
- WordBuffer: times 7 db 0
- base dw 0x0010
- ConvertHexToString:
- mov cx, 0 ;bug fix, cx equalled a big number threw address calculation off
- mov bx, WordBuffer+6 ;;address to end
- mov [bx], BYTE 0 ;null last letter
- loopCHTS:
- cmp ax, 0
- je doneCHTS
- xor dx,dx
- div WORD [base]
- dec bx ;move down buffer
- mov [bx], BYTE dl
- cmp dl, 10 ;equal or above ten is a letter
- jge ProcessToLetter
- add [bx], BYTE '0' ;its number 0x30 + our number, say 0, is 0x30 plus 0, which is 0x30 or 0 in decimal
- jmp loopCHTS
- ProcessToLetter:
- sub [bx], BYTE 10
- add [bx], BYTE 'A'
- jmp loopCHTS
- doneCHTS:
- sub bx, 0x2
- mov [bx], WORD '0x'
- ;bx contains beginning of string
- ret
Add Comment
Please, Sign In to add comment