assume cs:codesg

datasg segment

    db "Beginner's All-purpose Symbolic Instruction Code.",0

datasg ends

codesg segment
    start:
        mov ax, datasg
        mov ds, ax
        mov si, 0
        
        mov dh, 15
        mov dl, 0
        mov cx, 00024h
        call show_str

        call letterc
        
        mov dh, 17
        mov dl, 0
        mov cx, 00024h
        call show_str
        mov ax, 4c00h
        int 21h

letterc:
    pushf
    push si
    push ax
    push cx
    
    
    mov ah, 0
begin_letterc_loop:
    mov al, ds:[si]
    mov cx, ax
    jcxz back_letterc
    cmp al, 'a'
    jb otherletter
    cmp al, 'z'
    ja otherletter
    
lower2capital:
    and al,0dfh
    mov [si], al
otherletter:
    inc si
    jmp short begin_letterc_loop
    
back_letterc:    
    pop cx
    pop ax
    pop si
    popf
    ret

        ;dh  行号,dl 列号  cl  颜色 ,遇到0返回
show_str:

    push ax
    push bx
    push es
    push di
    push si
    push cx
    
    ; 计算偏移量
    mov al, 160
    mul dh
    mov bx, ax
    mov al, 2
    ;mov dl, 2
    mul dl
    add bx, ax
    ; 偏移量存储在bx中
    mov ax, 0b800h
    mov es, ax
    mov di, 0
    mov ah, cl
    mov ch, 0
print:
    mov cl, ds:[si]
    jcxz backshow_str
    mov al, cl
    mov es:[bx + di], ax
    add di, 2
    inc si
    jmp short print
    
backshow_str:
    pop cx
    pop si
    pop di
    pop es
    pop bx
    pop ax
    ret

codesg ends
end start

posted on 2014-05-07 00:08  Notflybird  阅读(154)  评论(0)    收藏  举报