1.用汇编语言编写一个推箱子游戏
出来了,代码如下:data segmentcar db 2,2,2,2,2,2,2,2,2,2db 2,2,2,2,2,2,0,0,0,2db 2,2,2,2,2,2,0,0,0,2db 2,2,2,2,2,2,0,0,0,2db 2,2,2,2,2,2,2,2,2,2db 2,2,2,2,2,2,2,2,2,2db 0,0,2,0,0,0,0,2,0,0db 0,2,0,2,0,0,2,0,2,0db 0,0,2,0,0,0,0,2,0,0x dw 10y dw 10msg db 'car program finish!!$'speed dw 5data endscode segmentassume cs:code,ds:datastart:mov ax,datamov ds,axmov ax,0a000hmov es,axmov ax,13h int 10hcall pictureag: mov ah,7int 21hcmp al,'s'jne agstart1: in al,60hcmp al,80h ;if release keyjae keyreleasecmp al,2 ;1 keyjz upspeedcmp al,3 ;2 keyjz downspeedjmp keyreleaseupspeed:mov si,speedinc simov speed,sijmp keyreleasedownspeed:mov si,speeddec simov speed,sijmp keyrelease keyrelease:call clearpicturemov si,speedadd si,xmov x,sicall picturecall delaymov si,xcmp si,310jc start1mov ah,9mov dx,offset msgint 21hmov ah,7int 21h mov ax,4c00hint 21hpicture proc nearmov dx,ymov bx,0again: cmp dx,0je overadd bx,320dec dxjmp again over: mov dx,9lea si,carnext1: mov cx,10mov di,xnext: mov al,[si]mov es:[bx+di],alinc siinc diloop nextadd bx,320dec dxjne next1retpicture endpclearpicture proc nearmov dx,ymov bx,0again2: cmp dx,0je over2add bx,320dec dxjmp again2 over2: mov dx,9next12: mov cx,10mov di,xnext2: mov al,0mov es:[bx+di],alinc diloop next2add bx,320dec dxjne next12retclearpicture endpdelay proc nearpush bxpush cxmov bx,1234back:mov cx,66push axwait1:in al,61hand al,10hcmp al,ahje wait1 mov ah,alloop wait1pop axdec bxjne backpop cxpop bxretdelay endpcode endsend start。
2.用汇编语言编写一个推箱子游戏
出来了,代码如下:data segmentcar db 2,2,2,2,2,2,2,2,2,2db 2,2,2,2,2,2,0,0,0,2db 2,2,2,2,2,2,0,0,0,2db 2,2,2,2,2,2,0,0,0,2db 2,2,2,2,2,2,2,2,2,2db 2,2,2,2,2,2,2,2,2,2db 0,0,2,0,0,0,0,2,0,0db 0,2,0,2,0,0,2,0,2,0db 0,0,2,0,0,0,0,2,0,0x dw 10y dw 10msg db 'car program finish!!$'speed dw 5data endscode segmentassume cs:code,ds:datastart:mov ax,datamov ds,axmov ax,0a000hmov es,axmov ax,13h int 10hcall pictureag: mov ah,7int 21hcmp al,'s'jne agstart1: in al,60hcmp al,80h ;if release keyjae keyreleasecmp al,2 ;1 keyjz upspeedcmp al,3 ;2 keyjz downspeedjmp keyreleaseupspeed:mov si,speedinc simov speed,sijmp keyreleasedownspeed:mov si,speeddec simov speed,sijmp keyrelease keyrelease:call clearpicturemov si,speedadd si,xmov x,sicall picturecall delaymov si,xcmp si,310jc start1mov ah,9mov dx,offset msgint 21hmov ah,7int 21h mov ax,4c00hint 21hpicture proc nearmov dx,ymov bx,0again: cmp dx,0je overadd bx,320dec dxjmp again over: mov dx,9lea si,carnext1: mov cx,10mov di,xnext: mov al,[si]mov es:[bx+di],alinc siinc diloop nextadd bx,320dec dxjne next1retpicture endpclearpicture proc nearmov dx,ymov bx,0again2: cmp dx,0je over2add bx,320dec dxjmp again2 over2: mov dx,9next12: mov cx,10mov di,xnext2: mov al,0mov es:[bx+di],alinc diloop next2add bx,320dec dxjne next12retclearpicture endpdelay proc nearpush bxpush cxmov bx,1234back:mov cx,66push axwait1:in al,61hand al,10hcmp al,ahje wait1 mov ah,alloop wait1pop axdec bxjne backpop cxpop bxretdelay endpcode endsend start。