这道题比较简单,直接上代码吧。
data segment
db "Beginner's All-purpose Symbolic Instruction Code.",0
ends
stack segment
dw 128 dup(0)
ends
code segment
start:
; set segment registers:
mov ax, data
mov ds, ax
mov ax,stack
mov ss,ax
mov sp,256
; add your code here
mov si,0
call ltou
mov dh,8 ; line=8
mov dl,3 ; column=3
mov bl,7 ;color=white/black
call show_str
mov ax, 4c00h ; exit to operating system.
int 21h
;
;str:[ds:si]
;
ltou:
push si
push ax
mov ah,0
L40:
;get next char
mov al,[si]
cmp al,0
jz end
cmp al,97
jb skip_trans
cmp al,122
ja skip_trans
and al,11011111b
mov [si],al
skip_trans:
inc si
jmp short L40
end:
pop ax
pop si
ret
;show string
;dh:line(0-24) dl:column(0,79),bl:color ds:si string start addr
;es:bx->0b800:offset
show_str:
;save registers
push cx
push ax
push es
push bx
push dx
push bx ;save color
;init es
mov ax,0b800h
mov es,ax
;calc display memory offset according to line and columm
mov al,dh
mov cl,160
mul cl; 160 bytes per line
mov dh,0
add ax,dx ;offset = 160*line + 2*column
add ax,dx
mov bx,ax
pop ax ;restore color
mov ah,al
l:
;string end?
mov cl,[si]
mov ch,0
jcxz ok
;begin write
mov al,cl
mov es:[bx],al
;write color
mov es:[bx+1],ah
;update indexs
inc bx
inc bx
inc si
jmp short l
ok:
;recover registers
pop dx
pop bx
pop es
pop ax
pop cx
ret
ends
end start ; set entry point and stop the assembler.