《汇编语言程序设计课程设计》指导书
mov lea
extletter:
mov
cx, 78
si, letters ah, 02h
; 显示字母
mov dl, [si]
int 21h
inc si
loop nextletter
start_game:
mov ah, 2ch
int 21h ; inc dl ; cmp dl, 78 jna sg1 sub dl, 78 sg1:
mov present_position, dl
lea di, letters
add di, word ptr present_position ; dec di ; mov dl, present_position ; mov ah, 02h mov bh, 00h mov dh, 01h
int 10h ;
mov cx, 21d ; nextrow:
push cx
mov cx, speed ;
wait_for_key:
delay:
; 延迟
push cx
mov cx,1000
loop delay push dx mov mov
ah, 06h dl, 0ffh
8
; 从键盘输入字符
《汇编语言程序设计课程设计》指导书
int pop jz cmp je cmp jne
21h dx pass al, 1bh to_start al, \ pass0
; 暂停处理
; 如果键入SPACE,则游戏暂停
; 如果键入ESC,则返回主菜单
pause: push dx mov mov int pop cmp jne jmp
to_start:
jmp
pass0: cmp
pass:
down:
je
ah, 06h dl, 0ffh 21h dx
al, \ pause pass
; ;
start al,[di] disappear
; ;
; 输入字母正确!则字母消失
pop cx LOOP wait_for_key
mov mov mov mov int inc mov mov int
ah, 0ah al, \bh, 00h cx, 01h 10h dh
; 在当前光标位置写空格
; ;
; 改变光标位置
ah, 02h bh, 00h 10h
9
《汇编语言程序设计课程设计》指导书
mov mov mov mov int pop
ah, 0ah al, [di] bh, 00h cx, 01h 10h cx
; 在当前光标位置写字母
;
loop nextrow
ah, 0ah al, \bh, 00h cx, 01h 10h dh ah, 02h bh, 00h 10h ah, 0ah al, \ bh, 00h cx, 01h 10h
; 下一行 ;
letter_over: mov mov mov mov int
inc mov mov int
mov mov mov mov int
jmp
disappear: pop pop mov mov mov mov int
next_letter:
mov
mov
; ;
;
;
next_letter
; 击中字母后输出空格
cx cx
ah, 0ah al, \ bh, 00h cx, 01h 10h
; ;
;
ah, 02h bh, 00h
10
; ;
《汇编语言程序设计课程设计》指导书
mov mov int mov
dh, 01h
dl, present_position 10h al, [di]
; ;
; 出现下一个新字母的算法 ;
add al, 7 cmp al, 7ah
jna next_letter1 sub al, 26 next_letter1:
mov ah, 0ah
mov bh, 00h mov cx, 01h
int 10h
mov [di], al jmp start_game
main endp code ends end start
;
11