. : : Assembly Language : : .  |  首页  |  我提出的问题  |  我参与的问题  |  我的收藏  |  消息中心   |  游客  登录  | 
刷新 | 提问 | 未解决 | 已解决 | 精华区 | 搜索 |
  《汇编语言》论坛 ->外中断
  管理员: assembly   [回复本贴] [收藏本贴] [管理本贴] [关闭窗口]
主题 : :  类似有C中switch..case,有没有更好的写法  [待解决] 回复[ 0次 ]   点击[ 231次 ]  
jayh
[帖 主]   [ 发表时间:2014-11-23 14:45 ]   [引用]   [回复]   [ top ] 
荣誉值:0
信誉值:0
注册日期:2014-11-08 22:37
代码中要处理A的弹起和ESC的按下两种按键。虽然已通过,不知道有没有更好的写法

assume cs:code
stack segment
dw 128 dup(0) 
stack ends
code segment
start:mov ax,stack
        mov ss,ax
        mov sp,128
        mov ax,cs
        mov ds,ax
        mov si,offset int9h
        mov ax,0
        mov es,ax
        mov di,204h
        mov cx,offset int9hend-offset int9h
        cld
        rep movsb
        push es:[9*4]
        pop es:[200h]
        push es:[9*4+2]
        pop es:[200h+2]
        cli
        mov word ptr es:[9*4],200h
        mov word ptr es:[9*4+2],0h
        sti
        mov ax,0b800h
        mov es,ax
        mov di,[160*12]
        mov ah,'a'
s:        mov es:[di],ah
        call delay
        cmp ah,'z'
        inc ah
        jna s
        mov ax,0
        mov es,ax
        push es:[200h]
        pop es:[9*4]
        push es:[202h]
        pop es:[9*4+2]
        mov ax,4c00h
        int 21h
delay:        push ax
        push dx
        mov dx,1000h
        mov ax,0h
s2:        sub ax,1
        sbb dx,0
        cmp ax,0
        jne s2
        cmp dx,0
        jne s2
        pop dx
        pop ax
        ret 
int9h:        push ax
        push bx
        push cx
        push es
        in al,60h
        pushf
        push es
        mov bx,0
        mov es,bx
        call dword ptr es:[200h]
        pop es
        cmp al,09Eh
        jne colo
        mov ax,0b800h
        mov es,ax
        mov bx,0
        mov cx,2000
        mov al,'A'
disA:        mov es:[bx],al
        inc bx
        inc bx
        loop disA
        jmp short int9ret
colo:         cmp al,01h
        jne int9ret
        mov ax,0b800h
        mov es,ax
        inc byte ptr es:[12*160+1]
        jmp short int9ret
int9ret:pop es
        pop cx
        pop bx
        pop ax
        iret
int9hend:nop
code ends
end start
需要登录后才能回帖 -->> 请单击此处登录
    Copyright © 2006-2024   ASMEDU.NET  All Rights Reserved