You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
973 B
57 lines
973 B
BITS 16
|
|
; Compares two strings
|
|
; IN si: the first (zero terminated) string
|
|
; IN di: the second (zero terminated) string
|
|
; OUT SF and ZF (same semantics as cmp)
|
|
stringcompare:
|
|
push bx
|
|
push si
|
|
push di
|
|
.loop:
|
|
mov bl, [si]
|
|
mov bh, [di]
|
|
cmp bl, bh
|
|
jne .end
|
|
test bl, bl ; bl and bh are the same, so bl = 0 => dl = 0
|
|
jz .end
|
|
inc si
|
|
inc di
|
|
jmp .loop
|
|
.end:
|
|
pop di
|
|
pop si
|
|
pop bx
|
|
|
|
ret
|
|
|
|
zstring_to_integer:
|
|
;IN: si Pointer to string
|
|
;OUT: ax result in binary
|
|
push bx
|
|
push si
|
|
push cx
|
|
push dx
|
|
xor ax, ax
|
|
xor bx, bx
|
|
xor cx, cx
|
|
xor dx, dx
|
|
mov bx, 10
|
|
.loop:
|
|
mov cl, [si]
|
|
cmp cl, 0
|
|
je .end
|
|
sub cl,'0'
|
|
cmp cl, 9
|
|
ja .end ; next number is not a number, or its a zero, and then we are done
|
|
; multiply by 10, and add the new number.
|
|
mul bx
|
|
add ax, cx
|
|
inc si
|
|
jmp .loop
|
|
|
|
.end:
|
|
pop dx
|
|
pop cx
|
|
pop si
|
|
pop bx
|
|
ret
|
|
|