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

📄 re5.asm

📁 用汇编语言编写的电梯监控系统设计 程序。
💻 ASM
📖 第 1 页 / 共 3 页
字号:

.486
;*******************************
ubdel macro name                 ;upbuffer delete
    local ubdel1,ubdel2,ubdel3
    cmp  upeffect ,1
    jne  ubdel3
    push ax
    push cx
    push si
    mov si ,offset up_buffer 
    mov al ,bh
    add al ,30h
    mov cx ,1000
ubdel1:    
    cmp al ,[si]
    jne ubdel2
    mov ah,0
    mov [si],ah

ubdel2:    
    inc si
    dec cx
    cmp cx,0
    jne ubdel1  
    push si
    pop cx
    pop ax
    nop
    nop
    nop
ubdel3:
    jmp name
    endm
    ;ubdel endp
;*******************************
dbdel macro name
    local dbdel1,dbdel2,dbdel3
    cmp downeffect,1
    jne dbdel3
    push ax 
    push cx
    push di
    mov di ,offset down_buffer 
    mov al ,bh
    add al ,30h
    mov cx ,1000
dbdel1:    
    cmp al ,[di]
    jne dbdel2
    mov ah,0
    mov [di],ah

dbdel2:    
    inc di
    dec cx
    cmp cx,0
    jne dbdel1  
    push di
    pop cx
    pop ax
    nop
    nop
    nop
dbdel3:
    jmp name
    endm
;**************************************
huaxian1 macro yanse,hang,lie,jueli  ; used rigister is dx cx ax
      local lop1                     ; no feedback data 
      pusha
      mov dx,hang
      mov cx,lie
 lop1:mov ah,0ch
      mov al,yanse

      int 10h
      inc dx
      cmp dx,jueli
      jnz  lop1
      popa
      endm

huaxian2 macro yanse,hang,lie,jueli  ;no feedback data
      local lop2
      pusha
      mov dx,hang
      mov cx,lie
 lop2:mov ah,0ch
      mov al,yanse
      int 10h
      inc cx
      cmp cx,jueli
      jnz  lop2
      popa
      endm

xiezi macro hang,lie,rensu,yanse
      pusha
      push  bx     
      mov ah,02h
      mov bh,0
      mov dh,hang
      mov dl,lie
      int 10h

      mov ah,09h
      mov al,1
      mov bl,yanse
      mov cx,rensu
      int 10h
      pop bx
      popa
      endm

xiezi1 macro  hang,lie,zi,yanse     ;no feedback data  
      pusha
      mov ah,02h
      mov bh,0
      mov dh,hang
      mov dl,lie
      int 10h

      mov ah,09h
      mov al,zi
      mov bl,yanse
      mov cx,1
      int 10h
      popa
      endm
;&************************************
  
   disp macro name               ;显示宏定义
       push dx
      
       push ax
       mov ah ,09h
       mov dx ,seg name
       mov ds ,dx
       mov dx ,offset name
       int 21h
       pop ax
       
       pop dx
       endm
  
  arraycopy macro name           ;字符串复制的宏定义 
       push cx
       push si
       push di
       mov si ,offset name
       mov di ,offset copydata
       mov cx ,1000
       cld
       rep movsb  
       pop di
       pop si
       pop cx
       endm
         
  arrayclear macro name           ;字符串清除的宏定义 
       push di
       push ax
       mov al ,00h
       mov di ,offset name
       mov cx ,1000
       cld
       rep stosb 
       pop ax
       pop di 
       endm
  


  data segment
  distance    db ?
  floor       db ?                                    ;(1-9) replce it with bh
  nextfloor   db ?                                    ;
  nextstop    db ?                                    ;1/0其运动方向上下一层要/不要停              distance    db ?
  direction   db ?                                    ;0为向上,1为向下,2为静止,用Bl代替
  speed       db ?                                    ;0静止,1-3档位
  ubstate     db ?                                    ;up_buffer state=1(not empty)0r0(empty)
  dbstate     db ?                                    ;down_buffer state=1(not empty)0r0(empty)
  bufferstate db ?                                    ;empty(0) or noempty(1)
  inputvalue  db ?                                    ;1-9  
  upeffect    db ?
  downeffect  db ?  
  renshu      db ?                                    ;电梯内人数                                   
  up_buffer   db 1000 dup (?),'$'                     ;楼层内向上键缓存
  down_buffer db 1000 dup (?),'$'                     ;楼层内向下键缓存
  
  
  copydata db 1000 dup (?) 
  empty    db 1000 dup (0),'$'                          ;参比数组,用来比较BUFFER是否为空 
  ;msg1 db 'Please input the number:',0ah,0dh,'$'       
  msg2 db 'Do you want to quit?(Y/N)',0ah,0dh,'$'     ;退出时语句
  ;msg3 db 'Those who want the lift up is on these floors:',0ah,0dh,'$'
  ;msg4 db 'Those who want the lift down is on these floors:',0ah,0dh,'$'
  ;msg5 db 'The next floor is:',0ah,0dh,'$'
  ;msg6 db 'The elivater is still.',0ah,0dh,'$'
  ;msg7 db 'Please input floor:',0ah,0dh,'$'
  ;msg8 db 'Please input speed:',0ah,0dh,'$'
  ;msg9 db 'Please input juli:',0ah,0dh,'$'
FREQ   DW 523,440,523,440,392,440,392,0,523,440,523,440,131,440,392
       DW 523,392,440,131,440,131         ;在这里增加了退出
       DW 523,392,440,131,440,147,523,392,440,131,440,392,165
       DW 165,147,165,175,165,147,131,131                             
       DW 523,440,392,440,131,440,131,523,392,392,440,131,440,147
       DW 523,392,392,440,131,440,392,165
TIME   DW 6 dup(25),50,6 DUP(25),50
       DW 50,4 DUP(25),50
       DW 50,4 DUP(25),50,50,6 DUP(25)
       DW 8 DUP(25)
       DW 6 DUP(25),50,6 DUP(25),50
       DW 8 DUP(25)
  MUS_FREQ   DW  196,262,294,330,349,330,262,-1,294,262,220,262,196,262,294,330,330,349
             DW  392,262,349,330,392,294,330,330,294,294,330,392,492
             DW  492,440,440,392,392,440,492,440,392,330,349,349,392,440,392,349,330,294
             DW  247,247,220,196,220,262,523,440,349,392,440
             DW  492,492,492,492,440,392,330,523,440,349,392,5 DUP (440),349,330,392
             DW  -1

   MUS_TIME  DW  100,70,50,75,25,50,50,100,50,50,200,100,50,50,50,25,25
             DW  50,50,75,25,50,25,25,25,25,200,100,50,50
             DW  75,50,100,50,25,25,50,25,25,300,75,25,50,50,50,25,25,50
             DW  50,25,25,25,25,300,100,100,75,25,100
             DW  50,25,25,50,25,25,300,100,100,75,25,100,50,25,25,50,25,25,200  
  data ends

 
  code segment 

main proc far                                      ;电梯启动程序
       assume cs:code,ds:data,es:data

       mov ax ,data
       mov ds ,ax
       mov ax ,data
       mov es ,ax

start:
       ; disp msg7
;**************************************************;初始化       
       mov ah    ,0
       int 16h
       sub al    ,30h
       mov bh    ,al                      ;manually input the floor
       
       ;disp msg8
       
       mov ah    ,0
       int 16h
       mov speed ,al                      ;manually input the speed

       ;disp msg9
       
       mov ah    ,0                       ;manually input the distance
       int 16h
       mov distance ,al  
       
       
       

;*********************************************
       pusha
       mov ah,0     ;ding yi tuxing fang shi
       mov al,04h   ;320x200 
       int 10h
       mov ah,0bh   ;beijing
       mov bh,0
       mov bl,0
       int 10h
      
       mov ah,0bh   ;xieziban yanse
       mov bh,1
       mov bl,0
       int 10h
       
       
       huaxian1 5,20,240,50     ;hua xianshijiemian
       huaxian1 5,20,310,50
       huaxian2 5,20,240,310
       huaxian2 5,50,240,311

       xiezi1 3,31,'s',2
       xiezi1 3,32,'u',2
       xiezi1 3,33,'d',2
       xiezi1 3,34,'u',2
       xiezi1 3,35,':',2
       xiezi1 5,31,'j',2
       xiezi1 5,32,'u',2
       xiezi1 5,33,'l',2
       xiezi1 5,34,'i',2
       xiezi1 5,35,':',2
;**************************************** image of lift
      huaxian1 3,175,117,185
      huaxian1 3,175,118,185
      huaxian2 3,155,113,120
      huaxian1 3,155,120,160
      huaxian2 3,160,113,121
      huaxian2 3,165,113,121
      huaxian1 3,160,113,165
      huaxian2 3,135,113,120
      huaxian2 3,140,113,121
      huaxian2 3,145,113,121
      huaxian1 3,135,120,145
      huaxian1 3,115,113,120
      huaxian2 3,120,113,121
      huaxian1 3,115,120,125
      huaxian2 3,95,113,121
      huaxian2 3,100,113,121
      huaxian2 3,105,113,121
      huaxian1 3,95,113,100
      huaxian1 3,100,120,105
      huaxian2 3,75,113,121
      huaxian2 3,80,113,121
      huaxian2 3,85,113,121
      huaxian1 3,75,113,85
      huaxian1 3,80,120,85
      huaxian2 3,55,113,121
      huaxian1 3,55,120,65
      huaxian2 3,35,113,121
      huaxian2 3,40,113,121
      huaxian2 3,45,113,121
      huaxian1 3,35,113,45
      huaxian1 3,35,120,45
      huaxian2 3,15,113,120
      huaxian2 3,20,113,121
      huaxian2 3,25,113,121
      huaxian1 3,15,120,25
      huaxian1 3,15,113,20

      huaxian1 2,9,100,191
      huaxian1 2,9,230,191
      huaxian1 2,9,135,191
      huaxian1 2,9,160,191

      huaxian2 2,9,100,230
      huaxian2 2,10,100,135
      huaxian2 2,10,160,230
      huaxian2 2,30,100,135
      huaxian2 2,30,160,230
      huaxian2 2,50,100,135
      huaxian2 2,70,100,135
      huaxian2 2,90,100,135
      huaxian2 2,110,100,135
      huaxian2 2,130,100,135
      huaxian2 2,150,100,135
      huaxian2 2,170,100,135
      huaxian2 2,190,100,135
      huaxian2 2,50,160,230
      huaxian2 2,70,160,230
      huaxian2 2,90,160,230
      huaxian2 2,110,160,230
      huaxian2 2,130,160,230
      huaxian2 2,150,160,230
      huaxian2 2,170,160,230
      huaxian2 2,190,100,230
      huaxian2 2,191,100,230
      huaxian2 2,9,100,230
      huaxian2 1,190,136,160
      huaxian2 1,170,136,160
;**************************************  hua men
      huaxian1 3,50,20,150
      huaxian1 3,50,70,150
      huaxian2 3,50,20,70
      huaxian2 3,150,20,71
      
      huaxian1 3,50,20,150
      huaxian1 3,50,70,150
      huaxian2 3,50,20,70
      huaxian2 3,150,20,71

      mov ax,0021
      mov bx,0069
lp300:push ax
      huaxian1 3,51,bx,150
      dec bx           
      pop ax
      push ax
      huaxian1 3,51,ax,150
      pop ax
      inc ax
      cmp ax,46
      jnz lp300
;************************************* virtue keyboard
      huaxian1 5,130,240,195
      huaxian1 5,130,310,195
      huaxian2 5,130,240,310
      huaxian2 5,195,240,311
      
      xiezi1 17,32,'9',1
      xiezi1 17,34,'8',1
      xiezi1 17,36,'7',1
      xiezi1 19,32,'6',1
      xiezi1 19,34,'5',1
      xiezi1 19,36,'4',1
      xiezi1 21,32,'3',1
      xiezi1 21,34,'2',1
      xiezi1 21,36,'1',1
      xiezi1 23,32,'<',1
      xiezi1 23,36,'>',1
      popa
;***************************************  ;decide the direction
       mov renshu ,0
       mov si,offset up_buffer
       mov di,offset down_buffer
       arrayclear up_buffer
       arrayclear down_buffer
       arrayclear copydata
       arrayclear empty
       mov bl    ,2                       ;set direction 2,means the lift is on the floor
       call disp1  
scant:       
       call epttest
       cmp bufferstate,0
       jne one
zero:  
       call scanstore                     ;返回扫描到的ASK2码
      
       call disp2
       jmp scant        

one:
        
        mov ah  ,inputvalue               ;Find the firstinput value.given during the ss/up.down_convert 
        cmp ah  ,bh
        jge l1                          
        
        mov bl  ,1                        ;down
        

l0:     call CC        
        call CC
        call nfsjudge                     ;Juidge whether it will stop on the next floor.        
        dec bh
        mov al  ,nextstop
        cmp al,1                   
        
        je  l00
        jmp l0

l00:    call cc
        call CC
       
        ubdel l000
l000:   dbdel l0000
l0000:  
        call music   
        call disp3            
        call delay
        call CC
        call CC
        call CC                           ;REPLACE WAITINPUT
        call CC
        call directionjudge               ;Juidge the would-be direction
        jmp DCMP
;******************************************
l1:     cmp ah  ,bh                       ;up
        je l2         
        
        mov bl  ,0
l10:    call CC
        call CC
        call nfsjudge
        inc bh
        mov al  ,nextstop
        cmp al,1
        je  l11
        jmp l10
l11:    
        call CC 
        call CC
        
       
        ubdel l111
l111:   dbdel l1111
l1111:  ;call delay
        call music
        call disp3  
        call delay
        call CC
        call CC
        call CC                           ;REPLACE WAITINPUT
        call CC
        call directionjudge               ;Juidge the would-be direction
        jmp DCMP
        

l2:     mov bl   ,2                       ;If the firstinput=given floor. Door is open.
        
        ubdel l22
l22:
        dbdel l222
l222:
        ;call delay
        call music
        call disp3
        call delay
        mov bl ,2
        
 
DCMP:   
        cmp bl ,1
        je l0 
        cmp bl ,0
        je l10       
        jmp scant
          
        main endp

;************************************************       
CC      proc near                                  ;a big problem
        push cx
        mov cx,0ffffh                                 ;THIS VALUE MUST CHANGE LATER
cc0:  
        call scanstore   
        call disp2                                  ;how to call disp,what's the input value
        call delay1
        dec cx
        cmp cx,1

⌨️ 快捷键说明

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