Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
hexstringtoint proc
;input: si=start of sz string
;output: si=end of sz string, ax=integer
push bx
mov ax,0
mov bx,0
loop1hsti:
;get a byte from the string
mov bl,byte ptr [si]
;check if it's end of string
test bl,0ffh
jz outofloop1hsti
;check if it's an alphabetical character
cmp bl,64
jbe notalpha
;adjust alpha characters
sub bl,7
notalpha:
;determine the value of the digit we just got
and bl,0fh
;shift our accumulator
shl ax,4
add ax,bx
inc si
jmp loop1hsti
outofloop1hsti:
pop bx
ret
hexstringtoint endp
decimaldata dw 10000,1000,100,10,1
inttodecstring proc
;input: ax=integer to output, si=string space to work in
;output: si=start of decimal string
;NOTE: output string has leading zeros!!!
push di
push bx
push cx
push dx
mov bx,si
mov di,0
loop1itds:
;divide by powers of tens
mov cx,decimaldata[di]
mov dx,0
div cx
;convert result to a digit string
add al,40h
mov byte ptr [di][bx],al
;transfer remainder to ax
mov ax,dx
add di,2
cmp di,10
jb loop1itds
pop dx
pop cx
pop bx
pop di
ret
inttodecstring endp