506寝室吧 关注:10贴子:864
  • 9回复贴,共1

微机课程设计 实验程序

取消只看楼主收藏回复

CODE       SEGMENT        
ASSUME CS:CODE
INTPORT1   EQU         0FF80H
INTPORT2   EQU         0FF81H
INTQ4        EQU         INTREEUP4
INTQ5        EQU         INTREEUP5
INTQ6     EQU         INTREEUP6
TCONTR0     EQU         0043H
TCON0      EQU         0040H
TCON1      EQU         0041H
IOCONPT    EQU         0FF2BH
IOCPT         EQU         0FF2AH
IOBPT         EQU         0FF29H
IOAPT         EQU          0FF28H
PA           EQU            0FF20H ;字位口
PB           EQU            0FF21H ;字形口
PC           EQU            0FF22H ;键入口
ADPORT    EQU      0FE00H
            ORG 12D0H
START:     JMP START0
BUF        DB ?,?,?,?,?,?
intcnt        db ?
intcnt1       dw ?
intcnt2      dw ?
WEIKONG    DB   ?
data1        db 0c0h,0f9h,0a4h,0b0h,99h,92h,82h,0f8h,80h,90h,88h,83h,0c6h      
            db 0a1h,86h,8eh,0ffh,0ch,89h,0deh,0c7h,8ch,0f3h,0bfh,8FH ,0CEH,91H
START0:       CLD
              CALL    WRINTVER
              MOV    DX   ,0FF2BH
              MOV    AL, 81H       
              OUT    DX, AL                          ;8255初始化



1楼2011-01-12 21:16回复
                  CALL    BUF1
    WAITING1:   CALL    DISP                          ;显示READY;
    MOV    DX   ,IOCPT
                  IN    AL, DX    
                  TEST    AL ,01
                  JZ   WAITING1                          ;未启动等待;    
                  MOV AL,13H
                  MOV   DX,    INTPORT1
                  OUT DX,AL
                  MOV AL,08H
                  MOV DX,INTPORT2
                  OUT DX,AL
                  MOV AL,09H
                  OUT DX,AL
                 MOV AL,0AFH
                 OUT DX,AL               ;8259初始化
                              MOV intcnt,25             ;软件计数25(0.5秒=20ms*25)
                 MOV DX,TCONTR0
                 MOV AL,76H
                 OUT DX,AL
                 MOV DX,TCON1              ;计数器1定时20ms
                 MOV AX,40000
                 OUT DX,AL
                 MOV   AL,AH
                 OUT DX,AL                   ;8253初始化
    


    2楼2011-01-12 21:16
    回复
                   MOV DX ,0FF2BH
                              
                   MOV   AL,09H
                   OUT   DX,AL                  ;PC4置一,系统投入工作
                   MOV   AL,0CH
                   OUT DX,AL                    ;PC6置0,清除报警
                   MOV DX,IOAPT
                   MOV   AL,0FEH
                   OUT DX,AL                    ;初态110,升温
                   MOV   INTCNT,25
                   MOV BL, 0
                     STI
                   CALL BUF2
      WAITING2:   CALL DISP
                   JMP   WAITING2                ;显示
      WRINTVER:     MOV AX,0H
                    MOV ES,AX
                 MOV DI,0030H
                    LEA AX,INTQ4
                    STOSW
                    MOV AX,0000h
                    STOSW                 ;装填中断向量
                       
                               MOV DI,0034H
                    LEA AX,INTQ5
                    STOSW
                    MOV AX,0000h
      


      3楼2011-01-12 21:16
      回复
                      STOSW
                                 MOV DI,0038H
                      LEA AX,INTQ6
                      STOSW
                      MOV AX,0000h
                      STOSW
                      RET                              ;装填中断向量
           INTREEUP5:    DEC   intcnt2
                         JZ QQ1
                         JMP     INTRE5
        QQ1:             MOV AX,0                     (半分钟中断)
                          MOV   DX,ADPORT
                          OUT DX,AL
                          MOV CX,0500H                ;启动A/D
              DELAY1:      LOOP   DELAY1                     
                          IN   AL,DX                    ;读入转换结果
                          CMP AL,0BCH
                          JA    NEXT2                   ;大于370转
                          CMP   AL,9EH
                          JB    NEXT3                  ;小于等于310转
        


        4楼2011-01-12 21:16
        回复
          NEXT2:           MOV DX, 0FF2BH
                            MOV AL,08H
                            OUT    DX,AL                   ;PC4置零,切断系统          
          NEXT3:        
                         MOV AL,0DH
                         OUT   DX,AL             ;PC6置1,报警响
          INTRE5:        MOV AL,20H
                           MOV DX,INTPORT1
                           OUT DX,AL
                           IRET                        ;中断结束,返回          
             INTREEUP4:                (故障中断)
                                       MOV DX,0FF2BH
                                        MOV   AL,0DH
                                        OUT   DX, AL                ;PC6置一,声光报警
                                       MOV intcnt2,250       ;软件计数1500(30秒=20ms*1500)
                            MOV DX,TCONTR0
                            MOV AL,34H              ;0通道半分钟中断
                            OUT   DX,AL
                            MOV DX,TCON0              ;计数器0定时30S
          


          5楼2011-01-12 21:16
          回复
                              MOV AX,40000
                              OUT DX,AL
                              MOV AL,AH
                              OUT DX,AL
                INTRE4:                    MOV AL,20H
                                MOV DX,INTPORT1
                                  OUT DX,AL
                                        IRET      
            INTREEUP6:    DEC   INTCNT             ;计数值减一            (半秒中断)
                          JZ QQQQ
                           JMP   INTRE6
            QQQQ:       MOV   INTCNT ,25       ;重装计数值
                           MOV AX,00
                           MOV   DX,ADPORT
                           OUT   DX,AL             ;启动A/D
                           MOV CX,0500H
                 DELAY2:    LOOP   DELAY2
                            IN   AL,DX                ;读入转换结果
            MOV BL,AL                 ;结果送BL
                        
                           CALL CONVERS
                   
                           CMP BL,0BCH
            JA   NEXT4                 ;大于370转
            CMP BL,0B2H
            JA   NEXT5                 ;大于350转
            


            6楼2011-01-12 21:16
            回复
              CMP   BL,9EH            
              JB   NEXT7                 ;小于310转
              CMP BL,0A8H
              JB NEXT6                   ;小于330转
                             MOV DX,IOAPT
                             MOV   AL,0FDH
              OUT DX,AL                 ;110保温
              INTRE6:       MOV AL,20H
                               MOV DX,INTPORT1
                               OUT DX,AL
                              IRET                         ;中断结束,返回
              NEXT4:        MOV DX, IOAPT
                             MOV   AL, 0F8H
                             OUT DX,AL
                              MOV DX, 0FF2BH
                                MOV AL,0DH
                                OUT    DX,AL    ;000超限报警
                                 MOV DX, IOAPT
                             JMP   CONT
              NEXT5:
              MOV DX   ,IOAPT
                              MOV AL,0FBH
              OUT DX,AL                 ;011降温
                                MOV DX, 0FF2BH
                                MOV AL,0CH
                                OUT    DX,AL  
              JMP CONT
              NEXT7:       MOV   DX,IOAPT
                           MOV   AL,0FFH
                           OUT   DX,AL
              


              7楼2011-01-12 21:16
              回复
                             MOV DX, 0FF2BH
                             MOV AL,0CH
                             OUT    DX,AL  
                             
                             JMP   CONT1
                NEXT6:       MOV DX,IOAPT
                              MOV AL ,0FEH
                                 OUT DX,AL   
                                   MOV DX, 0FF2BH
                                  MOV AL,0CH
                                  OUT    DX,AL  
                                    ;110升温
                CONT1:       MOV   DX,0FF2BH
                               MOV   AL,09H         
                               OUT   DX,AL
                               JMP CONT2               ;PC4置一,接通系统
                CONT:        MOV DX,0FF2BH
                              MOV AL ,08H                     ;PC4置零,切断系统
                              OUT DX,AL
                CONT2:        MOV AL,20H
                        MOV DX,INTPORT1
                            OUT DX,AL
                                 IRET
                CONVERS:      MOV   AL,BL
                               AND AL,0FH
                               MOV SI,OFFSET BUF
                               MOV [SI+5] ,AL
                               MOV AL,BL
                               AND AL,0F0H
                


                8楼2011-01-12 21:16
                回复
                                 MOV CL,4
                                 SHR AL,CL
                                 MOV [SI+4],AL
                                
                                 RET                            ;显示温度
                  DISP:         MOV AL,0FFH                    ;00H
                               MOV DX,PA
                               OUT DX,AL
                               MOV CL,0DFH                    ;20H         
                               MOV BX,OFFSET BUF
                  DIS1:          MOV DX,PC
                               OUT DX,AL
                               MOV AL,[BX]
                               MOV AH,00H
                               PUSH BX
                               MOV BX,OFFSET DATA1
                               ADD BX,AX
                               MOV AL,[BX]
                               POP BX
                               MOV DX,PB
                               OUT DX,AL
                               MOV AL,CL
                               MOV DX,PA
                               OUT DX,AL
                               PUSH CX
                  DIS2:         MOV CX,0500H
                               LOOP $
                               POP CX
                               CMP CL,0FEH   ;01H
                               JZ LX1
                  


                  9楼2011-01-12 21:16
                  回复
                                 INC BX
                                 ROR CL,1     
                                 JMP DIS1
                    LX1:         MOV AL,0FFH
                                 MOV DX,PB
                                 OUT DX,AL
                                 RET                              ;动态显示
                    BUF1:        MOV BUF,19H
                                 MOV BUF+1,0eH
                                 MOV BUF+2,0aH
                                 MOV BUF+3,0dH
                                 MOV BUF+4,1aH
                                 MOV BUF+5,10H
                                 RET
                    BUF2:           MOV BUF,10H
                                 MOV BUF+1,10H
                                 MOV BUF+2,10H
                                 MOV BUF+3,10H
                                 MOV BUF+4,00H
                                 MOV BUF+5,00H
                                 RET
                    code   ends
                         end    start
                                 


                    10楼2011-01-12 21:16
                    回复