assume cs:code, ds:data, ss:stack
data segment
db "Beginer's All - purpose symbolic instraction Code.",0
data ends
stack segment
db 128 dup(0)
stack ends
code segment
start: mov dx, stack
mov ss, dx
mov sp, 128
call clear_screen
call init_reg
mov si,0
mov di,160*10+20*2
call show_string
call up_Letter
mov di, 160*11 + 20*2
call show_string
mov ax, 4C00H
int 21H
;==========================================
up_Letter:
push ax
push bx
push cx
push dx
push si
push di
push ds
push es
upLetter: mov dl, ds:[si]
cmp dl,0
je upLetterRet ;如果dl 等于0
cmp dl, 'a'
jb nextLetter ; 如果dl小于'a'
cmp dl, 'z'
ja nextLetter ; 如果dl大于'z'
and byte ptr ds:[si], 11011111B
nextLetter:
inc si
jmp upLetter
upLetterRet:
pop es
pop ds
pop di
pop si
pop dx
pop cx
pop bx
pop ax
ret
;==========================================
show_string:
push ax
push bx
push cx
push dx
push si
push di
push ds
push es
showString: mov dl, ds:[si]
cmp dl,0
je showStringRet ; 等于0的话,跳到showStringRet
mov es:[di],dl
add di,2
inc si
loop showString
showStringRet: pop es
pop ds
pop di
pop si
pop dx
pop cx
pop bx
pop ax
ret
;==========================================
clear_screen: mov dx, 0B800H
mov es, dx
mov cx, 2000
mov bx,0
clrScr: mov dx, 0700H
mov es:[bx],dx
add bx,2
loop clrScr
ret
;==========================================
init_reg: mov dx, data
mov ds, dx
mov dx, 0B800H
mov es, dx
ret
code ends
end start