stacksegmentdb512dup(?)stackendsdatasegmentinfoldb0dh,0ah,'input1,2,3:(1:bird,2:che,3:exit)$'dataendscodesegmentassumecs:code,ds:data,ss:stackstart:movax,datamovds,axmovah,0;设置显示方式为320*200彩色图形方式moval,04hint10h;设置显示方式movah,0bh;设置背景色movbh,0;非0为没有背景色movbl,1;背景为蓝色int10hleadx,infolmovah,9int21hmovah,0int16h;键盘中断cmpal,31hjnzbcallxiaob:cmpal,32hjnzfinishcallchexiaoprocnear;小鸟主程序movcx,0b0h;小鸟初始位置movdx,64h;1---------------------------------------------动画实现核心部分draw1:callclearcallbird;调用小鸟子程序;-------------------------------------------;2----------------------------------------------------------------方向控制模块again1:movah,0;接收键盘输入int16hcmpal,1bh;比较键盘事件jzstart;是否为Esc退出moval,ahcmpal,48h;是否为向上jnzdraw_d1decdxjmpdraw1draw_d1:cmpal,50h;向下?jnzdraw_l1incdxjmpdraw1draw_l1:cmpal,4bh;向左?jnzdraw_r1deccxjmpdraw1draw_r1:cmpal,4dh;向右jnzagain1inccxjmpdraw1;----------------------------------------------------------------------xiaoendpcheprocnear;小车主程序movcx,0b0h;小车初始位置movdx,64hdraw2:callclearcallcar;调用小车子程序again2:movah,0;接收键盘输入int16hcmpal,1bh;比较键盘事件jzstart;是否为Esc退出moval,ahcmpal,48h;是否为向上jnzdraw_d2decdxjmpdraw2draw_d2:cmpal,50h;向下?jnzdraw_l2incdxjmpdraw2draw_l2:cmpal,4bh;向左?jnzdraw_r2deccxjmpdraw2draw_r2:cmpal,4dh;向右jnzagain2inccxjmpdraw2cheendpfinish:movah,4chint21hclearprocnear;清屏子程序pushaxpushbxpushcxpushdxmovah,6;调用6号功能moval,0;设置整个屏幕为空白movcx,0movdh,24;窗口右下角(24行,79列)movdl,79int10hpopdxpopcxpopbxpopaxretclearendpbirdprocnear;小鸟绘图子程序pushaxpushbxpushcxpushdxmovah,0ch;小鸟初始位置开始写像素。moval,02hint10h;以下像素组成小鸟图案dx,行;cx,列decdxinccxint10hdecdxinccxint10h;左侧2点/incdxinccxint10hincdxinccxint10hincdxinccxint10hincdxinccxint10h;4左侧4点\decdxinccxint10hdecdxinccxint10hdecdxinccxint10hdecdxinccxint10h;右侧4点/incdxinccxint10hincdxinccxint10h;右侧2点\adddx,3subcx,9int10h;下1点.inccxint10hinccxint10hinccxint10hinccxint10hinccxint10hinccxint10h;横6点__popdxpopcxpopbxpopaxretbirdendp;3---------------------------------------------------小车绘图子程序carprocnearpushaxpushbxpushcxpushdxmovah,0ch;小车初始位置开始写像素。moval,02hint10h;chekuangmovbx,5heng1:inccxint10hdecbxjnzheng1movbx,2shu1:incdxint10hdecbxjnzshu1movbx,7heng2:inccxint10hdecbxjnzheng2movbx,4shu2:incdxint10hdecbxjnzshu2movbx,12heng3:deccxint10hdecbxjnzheng3movbx,6shu3:decdxint10hdecbxjnzshu3;chelun1adddx,7addcx,2int10hinccxint10hinccxint10hdecdxdeccxint10hadddx,2int10h;chelun2decdxaddcx,6int10hinccxint10hinccxint10hdecdxdeccxint10hadddx,2int10hpopdxpopcxpopbxpopaxretcarendp;----------------------------------------------------------------------------codeendsendstart注释如下:1.draw1:callclearcallbird;调用小鸟子程序这两句与下文与之对应的小车程序部分为此程序动画实现的核心。动画的实现是先调用一次清屏,清除到屏幕当前帖,并调用一次重新绘图(callbird,callcar),显示图形下一帖,以达到动画的效果。2.这部分是控制物体运动方向的,按方向键的上、下、左、右可控制物体相应的移动。如:cmpal,48h;是否为向上jnzdraw_d1decdxjmpdraw1若按的方向键上键,行位置dx减少1,即在初始位置dx,64h;cx,0a0h的基数上,dx减1即为63h.在新的基数上,执行draw,即清屏,重新绘图。3.绘图子程序,图形都是由像素构成的,确定像素显示的位置,再调用一次BIOS输出。如下:movbx,5heng1:inccx;像素初始行位置dx,列位置cx确定的前提下,增加或减少dx,cx的值,可显示另一个像素,一个像素的组合,即形成图形。int10h;调用bios中断输出这个像素。decbxjnzheng1第一句movbx,5是用循环控制输出的次数。即在同一行上输出5个像素,构成一行。BIOS呼叫INT10H,AH=00H設定螢幕影相模式(AL)=模式碼(正常為03h)模式碼:解析度顏色數目頁數位址文00H:40*2516色8頁B8000H~B87CFH字01H:80*2516色8頁B8000H~B87CFH模02H:80*2516色8頁B8000H~B8F9FH式03H:80*2516色8頁B8000H~B8F9FH07H:80*252色8頁B8000H~B8F9FH繪04H:320*2004色1頁B8000H~BBF3FH圖05H:320*2004色1頁B8000H~BBF3FH模06H:640*2002色1頁B8000H~BBF3FH式0DH:320*20016色8頁A0000H~A1F3FH0EH:640*20016色4頁A0000H~A3E7FH0FH:640*3502色2頁A0000H~A6D5FH10H:640*35016色2頁A0000H~A6D5FH11H:640*4802色1頁A0000H~A95FFH12H:640*48016色1頁A0000H~A95FFH13H:320*200256色1頁A0000H~AF9FFHBIOS呼叫INT10H,AH=01H設定游標形狀(CH)=游標的啟始線(0~15)----啟始線(CL)=游標的終止線(0~15)註:正常:CH=0DH,CL=0EH----終止線消失:CH=0FFH,CL=0FFHBIOS呼叫INT10H,AH=02H設定游標位置(DH)=游標的列數(0~24)(DL)=游標的行數(0~79)(BH)=頁碼BIOS呼叫INT10H,AH=03H取得游標位置(BH)=頁碼游標的列數=(DH)----啟始線游標的行數=(DL)游標的啟始線=(CH)----終止線游標的終止線=(CL)註:正常:CH=0DH,CL=0EH消失:CH=0FFH,CL=0FFHBIOS呼叫INT10H,AH=05H畫面頁區的號擇(AL)=頁碼INT10h,AH=06H把指定的視窗範圍上捲(AL)=捲動的列數,若為0則清除螢幕(BH)=捲動後空出位置放入的屬性(CH)=捲動範圍的左上座標列(CL)=捲動範圍的左上座標行(DH)=捲動範圍的右下座標列(DL)=捲動範圍的右下座標行顏色屬性:bh=b7b6b5b4b3b2b1b0bit0~2:字體顏色(0:黑,1:藍,2:綠,3:青,4:紅,5:紫,6:綜,7:白)bit3:字體亮度(0:字體正常,1:字體高亮度)bit4~6:背景顏色(0:黑,1:藍,2:綠,3:青,4:紅,5:紫,6:綜,7:白)bit7:字體閃爍(0:不閃爍,1:字體閃爍)INT10h,AH=07H把指定的視窗範圍下捲(AL)=捲動的列數,若為0則清除螢幕(BH)=捲動後空出位置放入的屬性(CH)=捲動範圍的左上座標列(CL)=捲動範圍的左上座標行(DH)=捲動範圍的右下座標列(DL)=捲動範圍的右下座標行顏色屬性:bh=b7b6b5b4b3b2b1b0bit0~2:字體顏色(0:黑,1:藍,2:綠,3:青,4:紅,5:紫,6:綜,7:白)bit3:字體亮度(0:字體正常,1:字體高亮度)bit4~6:背景顏色(0:黑,1:藍,2:綠,3:青,4:紅,5:紫,6:綜,7:白)bit7:字體閃爍(0:不閃爍,1:字BIOS呼叫INT10H,AH=08H讀取游標所在位置的字元及屬性(BH)=頁碼字元ascii=(AL)字元的屬性=(AH)顏色屬性:ah=b7b6b5b4b3b2b1b0bit0~2:字體顏色(0:黑,1:藍,2:綠,3:青,4:紅,5:紫,6:綜,7:白)bit3:字體亮度(0:字體正常,1:字體高亮度)bit4~6:背景顏色(0:黑,1:藍,2:綠,3:青,4:紅,5:紫,6:綜,7:白)bit7:字體閃爍(0:不閃爍,1:字體閃爍)BIOS呼叫INT10H,AH=09H寫入字元及屬性在游標所在位置,游標不動(繪圖模式亦能使用)(AL)=欲寫入的字元ascii(BL)=欲寫入之字元的屬性(CXword)=欲顯示的次數(BH)=頁碼顏色屬性:bl=b7b6b5b4b3b2b1b0bit0~2:字體顏色(0:黑,1:藍,2:綠,3:青,4:紅,5:紫,6:綜,7:白)bit3:字體亮度(0:字體正常,1:字體高亮度)bit4~6:背景顏色(0:黑,1:藍,2:綠,3:青,4:紅,5:紫,6:綜,7:白)bit7:字體閃爍(0:不閃爍,1:字體閃爍)BIOS呼叫INT10H,AH=0AH寫入字元在游標所在位置,游標不動,屬性不變(繪圖模式亦能使用)(AL)=欲寫入的字元ascii(CXword)=欲顯示的次數(BH)=頁碼(BL)=前景顏色(繪圖模式時)└┘┌┐BIOS呼叫INT10H,AH=0BH設定文字模式(0~3