⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 course.asm

📁 这是用汇编语言编写的推箱子课程设计
💻 ASM
📖 第 1 页 / 共 3 页
字号:
;---------------------------------------------------------
INCtest       PROC      NEAR
               PUSH      AX
              PUSH      BX
              PUSH      CX
              PUSH      DX
              PUSH      DI
              MOV       WORD PTR[BX],0
              ADD       BX,2
              INC       WORD PTR[BX]
              CMP       WORD PTR[BX],60
              JNE       RETurn
              CALL      INCtest
 RETurn:     
              CALL      systime
              MOV        AH,2
              MOV       DH,16
              MOV       DL,54
              INT        10h
               MOV       AH,02h
              MOV       BX, DS:WORD PTR hours
              CALL      convert
              MOV       AH,02h
              MOV       DL,3ah
              INT       21h
              MOV       AH,02h
              MOV       BX,DS:WORD PTR min
              CALL      convert
              MOV       AH,02h
              MOV       DL,3ah
              INT       21h
              MOV       AH,02h
              MOV       BX,DS:WORD PTR sec
              CALL      convert
              POP       DI
              POP       DX
              POP       CX
              POP       BX
              POP       AX
              RET
INCtest       ENDP
convert       PROC      NEAR
              PUSH      AX
              PUSH      BX
              PUSH      CX
              PUSH      DX
              MOV       CX,10d
              MOV       AX,BX
              MOV       DX,0
              DIV       CX
              MOV       BX,DX
              
              MOV       DL,AL       
              ADD       DL,30h
              MOV       AH,02h
              INT       21h
              MOV       DL,BL
              ADD       DL,30h
              MOV       AH,02h
              INT       21h
              POP       DX
              POP       CX
              POP       BX
              POP       AX
              RET
convert       ENDP
;------------------------------------------------------------
systime PROC NEAR
              PUSH      AX
              PUSH      BX
              PUSH      CX
              PUSH      DX
              PUSH      DI
              PUSH      DS
en:
  setpos 19,54                      
  MOV   AH,2
  INT   1ah
  MOV   ran,CH
  MOV   rbn,CL
  MOV   rcn,DH
  MOV   BH,0h
  MOV	BL,ran
  CALL	binidec

  MOV   AH,02h
  MOV   DL,':'
  INT   21h

  MOV   BH,0h
  MOV	BL,rbn
  CALL	binidec

  MOV   AH,02h
  MOV   DL,':'
  INT   21h

  MOV   BH,0h
  MOV	BL,rcn
  CALL	binidec
  MOV   ren,10000
dely:
  DEC   ren
  MOV   rdn,1000
dely1:
  DEC   rdn
  CMP   rdn,0
  JNE   dely1
  CMP   ren,0 
  JNE   dely
exit8:        POP       DS
              POP       DI
              POP       DX
              POP       CX
              POP       BX
              POP       AX
  RET
systime ENDP
binidec PROC NEAR
   MOV	fla,0
   MOV	CX,1000h
   CALL	dec_div
   MOV	CX,100h
   CALL	dec_div
   MOV	CX,10h
   CALL	dec_div
   MOV	fla,1h
   MOV	CX,1h
   CALL	dec_div
   MOV	DL,20h
   MOV	AH,02h ;输出空格
   INT  21h
   RET
   binidec ENDP
dec_div PROC NEAR
   MOV	AX,BX
   MOV	DX,0
   DIV	CX
   MOV	BX,DX
   CMP	AL,0
   JE   cmpflag
   JNE  setflag 
  setflag:
   MOV	fla,1
  cmpflag:
   CMP  fla,0
   JNE	printal
   JE	notprintal
  printal:
   MOV	DL,AL
   ADD  DL,30h
   MOV	AH,02h
   INT  21h
  notprintal:
   RET   ;跳出
   dec_div ENDP
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
beepit        PROC      NEAR    ; 定义意外事件声音
              MOV       DI,800 		;定义声音频率
              MOV       BX,100
              CALL      beep		;定义延迟时间
              RET
beepit        ENDP
beep          PROC      NEAR
              PUSH      AX
              PUSH      BX
              PUSH      CX
              PUSH      DX
              PUSH      DI
              MOV       AL,0b6h
              OUT       43h,AL
              MOV       DX,12h
              MOV       AX,533h*896
              DIV       DI
              OUT       42h,AL
              MOV       AL,AH
              OUT       42h,AL
              IN        AL,61h
              MOV       AH,AL
              OR        AL,3
              OUT       61h,AL
WAIT1:        MOV       CX,0eeeeh
delay:        LOOP      delay
              DEC       BX
              JNZ       WAIT1
              MOV       AL,AH
              OUT       61h,AL              
              POP       DI
              POP       DX
              POP       CX
              POP       BX
              POP       AX
              RET
beep          ENDP
;-------------------------------------------------------
music         PROC      NEAR
              MOV       DX,SEG mdata_seg
              MOV       DS,DX
              LEA       SI,mus_freq
              LEA       BP,DS: mus_time
freq:         MOV       DI,[SI]
              CMP       DI,-1
              JE        END_mus
              MOV       BX,DS:[BP]
              CALL      beep
              ADD       SI,2
              ADD       BP,2
              JMP       freq
END_mus:      
              RET      
music         ENDP
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Option        PROC      NEAR		;选项模块
              PUSH      AX
              PUSH      BX
              PUSH      CX
              PUSH      DX
              PUSH      DI     
              DIsplaymsg Optionmsg
              MOV       AH,0
              INT       16h
              CMP       AH,2
              JE        c1
              CMP       AH,3
              JE        c2
              CMP       AH,4
              JE        c3
              CMP       AH,5
              JE        c4
              CMP       AH,6
              JE        c5
              CMP       AH,7
              JE        c6
              CMP       AH,8
              JE        c7
              CMP       AH,9
              JE        c8
              CMP       AH,10
              JE        c9
              CMP       AH,11
              JE        c0
c1:           setcolor  0
              JMP       exit12
c2:           setcolor  12
              JMP       exit12
c3:           setcolor  13
              JMP       exit12
c4:           setcolor  14
              JMP       exit12
c5:           setcolor  11
              JMP       exit12
c6:           setcolor  5
              JMP       exit12
c7:           setcolor  6
              JMP       exit12
c8:           setcolor  4
              JMP       exit12
c9:           setcolor  2
              JMP       exit12
c0:           setcolor  9
exit12:       
              show_char 23,3,00000000b,' ',51
              POP       DI
              POP       DX
              POP       CX
              POP       BX
              POP       AX
              RET
Option        ENDP
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
LoadGame      PROC      NEAR
              PUSH      AX		;文件操作子过程
              PUSH      BX
              PUSH      DX
              PUSH      CX
              MOV       AX,SEG Fdata_seg
              MOV       DS,AX
              MOV       AH,3dh
              MOV       AL,00
              LEA       DX,fname
              INT       21h
              JC        operr
              MOV       fhle,AX           ;open file for read
              JMP       go_on
operr:        
              DIsplaymsg err2   
              JMP       exitl
     go_on:            
              MOV       AH,3fh
              MOV       BX,fhle
              MOV       CX,2
              LEA       DX,relist
              INT       21h                  ;read it
              JC        rerr
              
              MOV       AH,3eh
              MOV       BX,fhle
              INT       21h          ;close the file
              JC        closeerr
              CALL      ok
              POP       CX
              MOV       CH,manx
              MOV       CL,many
              JMP       exitl
closeerr:  
              DIsplaymsg err5
              JMP       exitl 
rerr:         DIsplaymsg err3
exitl:        
              POP       DX
              POP       BX
              POP       AX              
              RET                                                            
LoadGame      ENDP 
;------------------------------------------------------------------------                                                                                   
SaveGame     PROC      NEAR
		PUSH      AX
              PUSH      BX
              PUSH      CX
              PUSH      DX
              MOV       AX,SEG Fdata_seg
              MOV       DS,AX
              MOV       AH,ES:manx
              MOV       x,AH
              MOV       AH,ES:many
              MOV       y,AH
              MOV       AH,3dh
              MOV       AL,01
              LEA       DX,fname
              INT       21h
              JC        oerr
              MOV       fhle,AX           ;open for write
              JMP       goon
oerr:  
              DIsplaymsg err2
              JMP       exits
   goon:      MOV       AH,40h
              MOV       BX,fhle
              MOV       CX,2
              LEA       DX,relist
              INT       21h                ;write file
              JC        werr
              MOV       AH,3eh
              MOV       BX,fhle
              INT       21h                ;close the file
              JC        clserr
              CALL      ok
              JMP       exits
clserr: 
              DIsplaymsg err5
              JMP       exits
werr:         DIsplaymsg err4
exits:        POP       DX
              POP       CX
              POP       BX
              POP       AX              
              RET 
SaveGame     ENDP
;--------------------------------------------------------
ok            PROC      NEAR
              setpos    manx,many
              show_char manx,many,10001110b,' ',2
              MOV       AH,x
              MOV       ES:manx,AH
              MOV       AH,y
              MOV       ES:many,AH
              setpos    manx,many 
              show_char manx,many,10001110b,234,2
              DIsplaymsg Correct
              RET
ok            ENDP                                                                                    
;===============================================================================              
CODE_SEG      ENDS
;******************************************************
              END       START    ;程序结束

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -