样例程序简析.docVIP

  • 5
  • 0
  • 约8.17千字
  • 约 15页
  • 2016-12-26 发布于湖北
  • 举报
stack segment db 512 dup(?) stack ends data segment infol db 0dh,0ah,input 1,2,3:(1:bird,2:che,3:exit) $ data ends code segment assume cs:code,ds:data,ss:stack start: mov ax,data mov ds,ax mov ah,0;设置显示方式为320*200彩色图形方式 mov al,04h int 10h ;设置显示方式 mov ah,0bh;设置背景色 mov bh,0;非0为没有背景色 mov bl,1;背景为蓝色 int 10h lea dx,infol mov ah,9 int 21h mov ah,0 int 16h;键盘中断 cmp al,31h jnz b call xiao b:cmp al,32h jnz finish call che xiao proc near;小鸟主程序 mov cx,0b0h;小鸟初始位置 mov dx,64h ;1---------------------------------------------动画实现核心部分 draw1: call clear call bird;调用小鸟子程序 ;------------------------------------------- ;2----------------------------------------------------------------方向控制模块 again1: mov ah,0;接收键盘输入 int 16h cmp al,1bh;比较键盘事件 jz start;是否为Esc退出 mov al,ah cmp al,48h;是否为向上 jnz draw_d1 dec dx jmp draw1 draw_d1:cmp al,50h; 向下? jnz draw_l1 inc dx jmp draw1 draw_l1:cmp al,4bh;向左? jnz draw_r1 dec cx jmp draw1 draw_r1:cmp al,4dh ; 向右 jnz again1 inc cx jmp draw1 ;---------------------------------------------------------------------- xiao endp che proc near;小车主程序 mov cx,0b0h;小车初始位置 mov dx,64h draw2: call clear call car;调用小车子程序 again2: mov ah,0;接收键盘输入 int 16h cmp al,1bh;比较键盘事件 jz start;是否为Esc退出 mov al,ah cmp al,48h;是否为向上 jnz draw_d2 dec dx jmp draw2 draw_d2:cmp al,50h; 向下? jnz draw_l2 inc dx jmp draw2 draw_l2:cmp al,4bh;向左? jnz draw_r2 dec cx jmp draw2 draw_r2:cmp al,4dh ; 向右 jnz again2 inc cx jmp draw2 che endp finish: mov ah,4ch int 21h clear proc near;清屏子程序 push ax push bx push cx push dx mov ah,6;调用6号功能 mov al,0;设置整个屏幕为空白 mov cx,0 mov dh,24;窗口右下角(24行,79列) mov dl,79 int 10h pop dx pop cx pop bx pop ax ret clear endp bird proc near;小鸟绘图子程序 push ax push bx push cx push dx mov ah,0ch;小鸟初始位置开始写像素。 mov al,02h int 10h ; 以下像素组成小鸟图案 dx,行;cx,列 dec dx inc cx int 10h dec dx inc cx int 10h;左侧2点/ inc dx inc cx int 10h inc dx inc cx int 10h inc dx inc cx int 10h inc dx inc cx int 10h;4左侧4点\ dec dx inc cx int 10h dec dx inc cx int 10h dec dx inc cx int 10h dec dx inc cx int 10h;右侧4点/ inc dx in

您可能关注的文档

文档评论(0)

1亿VIP精品文档

相关文档