📄 string.inc
字号:
;===========================================================
;
; WarmOS
; by HotHeart(xujiwei)
; Email: vipxjw@163.com
;
; String
; string operate
;
; History:
; 2005.08.29 finished UpCase
; 2005.08.28 finished strcmp,strlen,strcpy,strcat
; 2005.08.28 file created
;
;===========================================================
;===========================================================
; string cmpare
; in si first,end mark 0
; di second
; out ax 0 equ
; other not equ
;===========================================================
align 4
strcmp:
push si
push di
cld
.next:
lodsb
or al,al
je .last
cmp al,[es:di]
jne .last
inc di
jmp .next
.last:
cmp al,[es:di]
je .equ
jb .less
.large:
sub al,[es:di]
mov ah,0
jmp .done
.equ:
mov ax,0
jmp .done
.less:
mov ah,[di]
sub ah,al
mov al,ah
and ax,0xFF
neg ax
.done:
pop di
pop si
ret
;===========================================================
; string lenght
; in si string start,end mark 0
; out ax string length,didn't contain 0
;===========================================================
align 4
strlen:
push si
push bx
xor ax,ax
cld
.next:
mov bl,[si]
cmp bl,0
je .done
inc ax
inc si
jmp .next
.done:
pop bx
pop si
ret
;===========================================================
; string copy
; didn't check buffer length
; in ds:si string start,end mark 0
; es:di destination
; out nothing
;===========================================================
align 4
strcpy:
push si
push di
cmp [si],byte 0
je .done
.loop:
movsb
cmp [si],byte 0
jnz .loop
.done:
mov [es:di],byte 0
pop di
pop si
ret
;===========================================================
; strcat
; link the first string to second
; in si the first string
; di the second string
;===========================================================
align 4
strcat:
push si
push di
.getend:
cmp [di],byte 0
je .copy
inc di
jmp .getend
.copy:
call strcpy
.done:
pop di
pop si
ret
;===========================================================
; strcat
; link the first string to second
; in si string, end with 0
;===========================================================
align 4
UpCase:
push si
push ax
.next:
mov al,[si]
or al,al
jz .done
cmp al,'a'
jb .donext
cmp al,'z'
jg .donext
sub [si],byte 0x20
.donext:
inc si
jmp .next
.done:
pop ax
pop si
ret
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -