|
主题 : : 11关已过,记录一下 [待解决] |
回复[ 0次 ]
点击[ 292次 ] | |
荣誉值:0
信誉值:0
注册日期:2014-11-08 22:37 |
assume cs:code
data segment
db "Beginner's All-purpose Symbolic Instruction Code.",0
data ends
code segment
begin:mov ax,data
mov ds,ax
mov si,0
call letterc
mov si,0
mov bh,8
mov bl,1
mov cl,2
call show_str
mov ax,4c00h
int 21h
;----------------letter conversion from lowercase to uppercase-------------------
;Input:
;ds,si
;Output:
;ds,si
;Result:
;convert a string with 0 ending from lowercase to uppercase
;------------------------------
letterc:
push ax
push cx
push ds
push si
s: mov cl,[si]
mov ch,00h
mov al,cl
cmp al,61h; compare with letter 'a'
jb save; smaller than 'a'
cmp al,7Ah; compare with letter 'z'
ja save; greater then 'z'
sub al,20h; lowercase --> uppercase
save:mov [si],al
jcxz ok
inc si
jmp short s
ok: pop si
pop ds
pop cx
pop ax
ret
;----------------show string-------------------
;Input:
;ds,si,bh,bl,cl
;Output:
;non
;Result:
;display color string on the monitor
;------------------------------
show_str:
push ax
push bx
push cx
push dx
push es
push di
push si
mov si,0
mov dx,bx
mov al,dh
sub al,1
mov ah,0A0h
mul ah;calculate the beginning index of row dh
mov bx,ax
mov al,dl
sub al,1
mov ah,2h
mul ah; calculate the offset addr of column dl
add bx,ax;the total offset of dispaly reg
mov ax,0b800h
mov es, ax
mov al,cl;color of the string display
mov di,0
;mov si,0
s2: mov cl,ds:[si]
mov ch,00h
jcxz ok2
mov es:[bx+di],cl
mov es:[bx+di].1,al
add si,1
add di,2
jmp short s2
ok2: pop si
pop di
pop es
pop dx
pop cx
pop bx
pop ax
ret
code ends
end begin | | |