80 x86汇编实例.doc_第1页
80 x86汇编实例.doc_第2页
80 x86汇编实例.doc_第3页
80 x86汇编实例.doc_第4页
80 x86汇编实例.doc_第5页
已阅读5页,还剩24页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

本人对80x86汇编编程的一些了解,在这里和大家分享。(1)显示“生日快乐”程序:DATAS SEGMENT db 12345678901234567890123456789012345678901234567890123456789012345;此处输入数据段代码 db * * * * * * * db * * * * * * * * * db * * * * * * * * * db * * * * * * * db * * * * * * * * * * * db * * * * * * * * * * db * * * * * * * * * DATAS ENDSSTACKS SEGMENT dw 20h dup(0) ;此处输入堆栈段代码STACKS ENDSCODES SEGMENT ASSUME CS:CODES,DS:DATAS,SS:STACKSSTART: MOV AX,DATAS MOV DS,AX MOV AX,STACKS MOV SS,AX mov sp,20h mov ax,0b800h mov es,ax mov si,65 mov bx,0 mov dx,7s: mov di,0 mov cx,60s0: mov al,simov es:di+bx+160*9+20,al inc si add di,2 loop s0 add si,5 add bx,160dec dxcmp dx,0jne s mov dx,12 mov bx,0s1: mov di,0mov cx,20s2: mov al,07hmov es:di+bx+1,al mov al,16hmov es:di+bx+41,almov al,25hmov es:di+bx+81,almov al,34hmov es:di+bx+121,aladd di,2dec cxcmp cx,0jne s2add bx,160dec dxcmp dx,0jne s1mov dx,12 mov bx,160*13s3: mov di,0mov cx,20s4: mov al,43hmov es:di+bx+1,al mov al,52hmov es:di+bx+41,almov al,61hmov es:di+bx+81,almov al,70hmov es:di+bx+121,aladd di,2dec cxcmp cx,0jne s4add bx,160dec dxcmp dx,0jne s3mov cx,65534s8:mov bx,100000s7: dec bxcmp bx,0jne s7 loop s8mov cx,4000mov di,1mov al,0mov ah,0int 16hcmp al,rje s5jmp s6s5:mov al,4ahmov es:di,aladd di,2loop s5jmp s9s6:mov al,0a4hmov es:di,aladd di,2loop s6s9:jmp s8 ;此处输入代码段代码 MOV AH,4CH INT 21HCODES ENDS END START(2)实时时钟程序:DATAS SEGMENT db Sunday db Monday db Tuesday db Wednesday db Thursday db Firday db Saturday ;此处输入数据段代码 DATAS ENDSCODES SEGMENT ASSUME CS:CODESSTART: MOV AX,0B800H MOV DS,AX MOV SI,0 MOV DL,9 MOV CH,3 S1: MOV AL,DL ;提取和显示年、月、日 OUT 70H,AL NOP NOP IN AL,71H MOV AH,0 MOV DH,AL MOV CL,4 SHL AX,CL MOV AL,DH ADD AL,0 AAA ADD AH,30H ADD AL,30H MOV SI+160*12+31*2,AH MOV SI+2+160*12+31*2,AL DEC CH CMP CH,0 JE S2 MOV AL,/ MOV SI+4+160*12+31*2,AL ADD SI,6 DEC DL JMP S1 S2: ADD SI,6 MOV DL,4 MOV CH,3 S3: MOV AL,DL ;提取和显示时、分、秒 OUT 70H,AL NOP NOP IN AL,71H MOV AH,0 MOV DH,AL MOV CL,4 SHL AX,CL MOV AL,DH ADD AL,0 AAA ADD AH,30H ADD AL,30H MOV SI+160*12+31*2,AH MOV SI+2+160*12+31*2,AL DEC CH CMP CH,0 JE S4 MOV AL,: MOV SI+4+160*12+31*2,AL ADD SI,6 DEC DL DEC DL JMP S3 S4: MOV AL,6 ;提取和显示星期 OUT 70H,AL NOP NOP IN AL,71H MOV BL,AL MOV AX,DATAS MOV ES,AX MOV DI,0 MOV SI,0 MOV AL,BL DEC AL MOV AH,0 MOV BH,10 MUL BH ADD DI,AX MOV CX,10S5: MOV AL,ES:DI MOV DS:SI+160*11+34*2,AL INC DI INC SI INC SI DEC CX CMP CX,0 JNE S5 MOV CX,4000 MOV SI,1S6: MOV AL,0CAH ;设置背景和字体颜色 MOV DS:SI,AL INC SI INC SI DEC CX CMP CX,0 JNE S6 JMP START MOV AH,4CH INT 21HCODES ENDS END START(3) 我自己写的一个小游戏程序:(大家可以将“分数”子程序的调用位置换一下,显示时就会实时更新)DATAS SEGMENT ;12345678901234567890 ;此处输入数据段代码 db * db * * db * * * db * * db * db * db * * db * db * * db * * db * * db * db * db * * db * * db * * db * db * * db * db * db * * db * * * db * * db * ;1234567890123456789012345678901234567890sm1 db up: w down: s left: a right: d sm2 db start: k exit: t replay: paa db 0a db 134234113241423312324123142342143124423132423422314132412134231 b db 142332314214132412342122342234114234234214213242312234412313434 f db 0001020304050607080910111213141516171819202122232425262728293031323334353637383940 db 41424344454647484950515253545556575859606162636465666768697071727374757677787980 db 818283848586878889909192939495969979899e db score: DATAS ENDSSTACKS SEGMENT dw 30h dup(0);此处输入堆栈段代码STACKS ENDSCODES SEGMENT ASSUME CS:CODES,DS:DATAS,SS:STACKSSTART: MOV AX,DATAS MOV DS,AX mov ax,0b800h mov es,ax mov ax,stacks mov ss,ax mov sp,30h call init call list mov ah,0 int 16hpa0:cmp al,t je tui pa1:cmp al,kjne pa0 mov al,0mov aa0,al mov bp,0 call init call right call up call down call left call background call fen call delay call delay mov si,0 mov cx,99g0: mov al,asiinc si cmp al,1 jne g2 call right1 call fen jmp gg2: cmp al,2 jne g3 call up1 call fen jmp gg3: cmp al,3 jne g4 call down1 call fen jmp g g4: call left1call fen jmp gg: loop g0 call fen jmp $tui: MOV AH,4CH INT 21H right:push axpush bxpush cxpush dxpush sipush dimov si,0 mov bx,0 mov dx,5 ;行号s0: mov di,0 mov cx,15;列号s1: mov al,simov es:di+bx+160+4,al inc si add di,2 loop s1 add bx,160dec dxcmp dx,0jne s0pop dipop sipop dxpop cxpop bxpop axretright1:push axpush bxpush cxpush dxpush sipush dimov dl,24 mov bx,24*160r: mov dh,5 ;行号 mov si,0r0: mov di,0 mov cx,15;列号r1: mov al,simov es:di+bx+4,almov al, mov es:di+bx+160+4,al inc si add di,2 loop r1 add bx,160dec dhcmp dh,0jne r0call delaycmp bp,0ja r4mov ah,1int 16hnopnopjz r3mov ah,0int 16hnopnopcmp al,tje tuicmp al,pje startcmp al,djne r3call tureRculorcall delaycall backgroundmov al,aa0inc almov aa0,alinc bpjmp r4r3:r4:sub bx,6*160dec dlcmp dl,0jne rcall meetRculorcall delaycall backgroundpop dipop sipop dxpop cxpop bxpop axmov bp,0retup:push axpush bxpush cxpush dxpush sipush di mov si,5*15mov bx,0mov dx,7 ;行号s2: mov di,0 mov cx,8;列号s3: mov al,simov es:di+bx+52,al inc si add di,2 loop s3 add bx,160dec dxcmp dx,0jne s2pop dipop sipop dxpop cxpop bxpop axretup1:push axpush bxpush cxpush dxpush sipush dimov dl,25 mov bx,24*160u: mov dh,7 ;行号 mov si,75u0: mov di,0 mov cx,8;列号u1: mov al,simov es:di+bx+52,almov al, mov es:di+bx+160+52,al inc si add di,2 loop u1 add bx,160dec dhcmp dh,0jne u0call delaycmp bp,0ja u4mov ah,1int 16hnopnopjz u3mov ah,0int 16hnopnopcmp al,tje tuicmp al,pje startcmp al,wjne u3call tureUculorcall delaycall backgroundmov al,aa0inc almov aa0,alinc bpjmp u4u3:u4:sub bx,8*160dec dlcmp dl,0jne ucall meetUculorcall delaycall backgroundpop dipop sipop dxpop cxpop bxpop axmov bp,0retdown:push axpush bxpush cxpush dxpush sipush dimov si,7*8+75mov bx,0mov dx,7 ;行号s4: mov di,0 mov cx,8;列号s5: mov al,simov es:di+bx+92,al inc si add di,2 loop s5 add bx,160dec dxcmp dx,0jne s4pop dipop sipop dxpop cxpop bxpop axretdown1:push axpush bxpush cxpush dxpush sipush dimov dl,25 mov bx,24*160do: mov dh,7 ;行号 mov si,75+56do0:mov di,0 mov cx,8;列号do1:mov al,simov es:di+bx+92,almov al, mov es:di+bx+160+92,al inc si add di,2 loop do1 add bx,160dec dhcmp dh,0jne do0call delaycmp bp,0ja do4mov ah,1int 16hnopnopjz do3mov ah,0int 16hnopnopcmp al,tje tuicmp al,pje startcmp al,sjne do3call tureDculorcall delaycall backgroundmov al,aa0inc almov aa0,alinc bpjmp do4do3:do4:sub bx,8*160dec dlcmp dl,0jne docall meetDculorcall delaycall backgroundpop dipop sipop dxpop cxpop bxpop axmov bp,0retleft:push axpush bxpush cxpush dxpush sipush dimov si,7*16+75 mov bx,0mov dx,5 ;行号s6: mov di,0 mov cx,15;列号s7: mov al,simov es:di+bx+160+124,al inc si add di,2 loop s7 add bx,160dec dxcmp dx,0jne s6pop dipop sipop dxpop cxpop bxpop axretleft1:push axpush bxpush cxpush dxpush sipush dimov dl,24 mov bx,24*160l: mov dh,5 ;行号 mov si,7*16+75l0: mov di,0 mov cx,15;列号l1: mov al,simov es:di+bx+124,almov al, mov es:di+bx+160+124,al inc si add di,2 loop l1 add bx,160dec dhcmp dh,0jne l0call delaycmp bp,0ja l4mov ah,1int 16hnopnopjz l3mov ah,0int 16hnopnopcmp al,tje tuicmp al,pje startcmp al,ajne l3call tureLculorcall delaycall backgroundmov al,aa0inc almov aa0,alinc bpjmp l4l3:l4:sub bx,6*160dec dlcmp dl,0jne lcall meetLculorcall delaycall backgroundpop dipop sipop dxpop cxpop bxpop axmov bp,0retbackground:push dxpush bxpush dipush cxpush axmov dx,50 mov bx,0s11:mov di,0mov cx,20s12:mov al,0fhmov es:di+bx+1,al mov al,1fhmov es:di+bx+41,almov al,2fhmov es:di+bx+81,almov al,3fhmov es:di+bx+160+121,aladd di,2dec cxcmp cx,0jne s12add bx,160dec dxcmp dx,0jne s11pop axpop cxpop dipop bxpop dxretdelay:push bxpush cxmov al,aa0cmp al,80ja d12cmp al,60ja d9cmp al,40ja d6cmp al,20ja d3mov cx,60000d1: mov bx,5000d2:dec bxcmp bx,0jne d2loop d1pop cxpop bxretd3: mov cx,60000d4: mov bx,3000d5: dec bxcmp bx,0jne d5loop d4pop cxpop bxretd6: mov cx,60000d7: mov bx,1500d8: dec bxcmp bx,0jne d8loop d7pop cxpop bxretd9: mov cx,60000d10:mov bx,1000d11:dec bxcmp bx,0jne d8loop d7pop cxpop bxretd12:mov cx,60000d13:mov bx,750d14:dec bxcmp bx,0jne d14loop d13pop cxpop bxretmeetUculor:push dxpush bxpush dipush cxpush axmov dx,25 mov bx,0mu1:mov di,41mov cx,20mu2:mov al,9chmov es:di+bx,aladd di,2loop mu2add bx,160dec dxcmp dx,0jne mu1pop axpop cxpop dipop bxpop dxretmeetRculor:push dxpush bxpush dipush cxpush axmov dx,25 mov bx,0m1: mov di,1mov cx,20m2: mov al,8chmov es:di+bx,aladd di,2loop m2add bx,160dec dxcmp dx,0jne m1pop axpop cxpop dipop bxpop dxretmeetDculor:push dxpush bxpush dipush cxpush axmov dx,25 mov bx,0md1:mov di,81mov cx,20md2:mov al,0achmov es:di+bx,aladd di,2loop md2add bx,160dec dxcmp dx,0jne md1pop axpop cxpop dipop bxpop dxretmeetLculor:push dxpush bxpush dipush cxpush axmov dx,24 mov bx,160ml1:mov di,121mov cx,20ml2:mov al,0bchmov es:di+bx,aladd di,2loop ml2add bx,160dec dxcmp dx,0jne ml1pop axpop cxpop dipop bxpop dxrettureRculor:push dxpush bxpush dipush cxpush axmov dx,25 mov bx,0tr1: mov di,1mov cx,20tr2: mov al,8ehmov es:di+bx,aladd di,2loop tr2add bx,160dec dxcmp dx,0jne tr1pop axpop cxpop dipop bxpop dxrettureUculor:push dxpush bxpush dipush cxpush axmov dx,25 mov bx,0tu1:mov di,41mov cx,20tu2:mov al,9ehmov es:di+bx,aladd di,2loop tu2add bx,160dec dxcmp dx,0jne tu1pop axpop cxp

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论