📄 string.asm
字号:
[bits 16]
global string_len,string_cmp
section code
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Input :
;; SI=pointer to string
;; Output:
;; CX=string length
string_len:
push ax
push si
xor cx,cx
.loop
lodsb
and al,al
jz .string_len_end
inc cx
jmp short .loop
.string_len_end
pop si
pop ax
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Input:
;; SI=pointer to string 1
;; DI=pointer to string 2
;; Output:
;; AX=1 strings are not equal
;; AX=0 strings are equal
string_cmp:
pusha
mov cx,0xffff
.string_cmp_loop
mov al,byte[ds:si]
and al,al
jz .string_cmp_test_end
cmpsb
jne .string_end_not
loop .string_cmp_loop
.string_end_equal
popa
xor ax,ax
ret
.string_cmp_test_end
mov al,byte[es:di]
and al,al
jz .string_end_equal
.string_end_not
popa
mov ax,1
ret
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -