nasm - Assembly translating ASCII character to HEX value -


i modifying code suppose translate ascii characters hexadecimal values. first version working without problems, newer function have problems.

this new function translates ascii values hexadecimal values:

;carry flag cleared if successed, if not set ;input number should in al ;output number should in ah .translate:     xor ah,ah     mov bx, hexascii     .loop:         mov dl,[bx]         cmp dl,al         je .end         inc bx         inc ah         cmp ah,0x10         je .err         jmp .loop     .end:         clc         ret     .err:         stc         ret ; ... code hexascii db '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' 

however function seems not work - when sending output function int 13, bochs returning error - read/write/verify parameter out of range. numbers use 00 head, 00 cylinder, , 01 sector, guess not actual problem arguments wrote.

i used previous function same arguments , loaded sector wanted to.

i tried use bochs debugger track registers in memory before int 0x13, looking registers have same values inputted.

my previous function is:

;carry flag cleared if successed, if not set ;input number should in al ;output number should in ah .translate:     cmp al,'0'     je .x0     cmp al,'1'     je .x1     cmp al,'2'     je .x2     cmp al,'3'     je .x3     cmp al,'4'     je .x4     cmp al,'5'     je .x5     cmp al,'6'     je .x6     cmp al,'7'     je .x7     cmp al,'8'     je .x8     cmp al,'9'     je .x9     cmp al,'a'     je .xa     cmp al,'b'     je .xb     cmp al,'c'     je .xc     cmp al,'d'     je .xd     cmp al,'e'     je .xe     cmp al,'f'     je .xf     cmp al,'a'     je .xa     cmp al,'b'     je .xb     cmp al,'c'     je .xc     cmp al,'d'     je .xd     cmp al,'e'     je .xe     cmp al,'f'     je .xf     jmp .none     .x0:         xor ah,ah         clc         ret     .x1:         mov ah,0x1         clc         ret     .x2:         mov ah,0x2         clc         ret     .x3:         mov ah,0x3         clc         ret     .x4:         mov ah,0x4         clc         ret     .x5:         mov ah,0x5         clc         ret     .x6:         mov ah,0x6         clc         ret     .x7:         mov ah,0x7         clc         ret     .x8:         mov ah,0x8         clc         ret     .x9:         mov ah,0x9         clc         ret     .xa:         mov ah,0xa         clc         ret     .xb:         mov ah,0xb         clc         ret     .xc:         mov ah,0xc         clc         ret     .xd:         mov ah,0xd         clc         ret     .xe:         mov ah,0xe         clc         ret     .xf:         mov ah,0xf         clc         ret     .none:         xor ah,ah         stc         ret 

i don't expect other part of code damaged, did not modified it. if needed include full code, pretty long.

is there missing or wrong in new function?

edit: forgot mention code running in 16 bit real mode

after getting osdev forum noticed function translate values properly, damaging dl register forget keep same holds hard drive number.

if needs newer version of code here go:

.translate:     xor ah,ah     mov bx, hexascii     .loop:         cmp [bx],al         je .end         inc bx         inc ah         cmp ah,0x10         je .err         jmp .loop     .end:         clc         ret     .err:         stc         ret ;... code hexascii db '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' 

Comments

Popular posts from this blog

ruby on rails - Permission denied @ sys_fail2 - (D:/RoR/projects/grp/public/uploads/ -

c++ - nodejs socket.io closes connection before upgrading to websocket -

python - PyQt: Label not showing correct number of length -