; Tareq Shannak 1181404 CODE SEGMENT PARA 'CODE' ASSUME CS:CODE, DS:DATA, SS:STAK STAK SEGMENT PARA STACK 'STACK' DW 20 DUP(?) STAK ENDS DATA SEGMENT PARA 'DATA' ; 0 for lighting, 1 otherwise DIGITS DB 0C0h, 0F9h, 0A4h, 0B0h, 99h, 92h, 82h, 0F8h, 80h, 90h, 088h, 083h, 0C6h, 0A1h, 86h, 8Eh , 00 ; 0 to F DATA ENDS START PROC MOV AX, DATA MOV DS, AX CALL INSERT_ISR_INTO_VECTOR_TABLE CALL SETUP_8259 ;; Address of 8253: 78h ;; Addrss of 8255: 70h ;; Address of 8259: 10h MOV AL, 81h ; TODO: 1000 0001b OUT 76h, AL ; Setup 8255 as all ports mo0 output CALL SETUP_8253 STI XOR AX,AX ENDLESS: CALL SHOW_AX ;CMP AX, 10h ;JNZ ENDLESS ;MOV AX, 0h ; MAke AX 0 after reaching 16 JMP ENDLESS RET START ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Common Anode Seven Segmeent ; 0 for lighting, 1 otherwise SHOW_AX PROC NEAR PUSH AX XOR BX, BX MOV BL, AL MOV AL, DIGITS[BX] OUT 72h, AL ; 8255's Port B at 72h POP AX RET SHOW_AX ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; SETUP_8253 PROC NEAR ;; SETUP 8253 ; --> Used to Divide 4Mhz Clock to 2000 so that we get 2Khz Output MOV AL, 00110111b ; 00 [counter 0], 11[ 2 byte data], 010 [ with mod 3], 1 [BCD] OUT 7Eh, AL ; configure the counter 0 of 8253 ; --> Pulse Wave :: MOD 2 of 8253 MOV AL, 01110111b ; 01 [counter 1], 11[ 2 byte data], 010 [ with mod 3], 1 [BCD] OUT 7Eh, AL ; configure the counter 1 of 8253 MOV AL, 00h OUT 78h, AL ; Send first byte of Counter 0 MOV AL, 20h OUT 78h, AL ; Send second byte of Counter 0 ;;--> Counter0 : 2000h ; send BCD 2000 to counter 0 MOV AL, 00h OUT 7Ah, AL ; Send first byte of Counter 1 MOV AL, 20h OUT 7Ah, AL ; Send second byte of Counter 1 ;;--> Counter1 : 5h ; send BCD 5 to counter 1 RET SETUP_8253 ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; SETUP_8259 PROC NEAR MOV AL, 00010011b ; ICW1 : Edge Triggered - 1 Master - ICW4 Needed OUT 10h, AL ; SET InputControlWord1 MOV AL, 40h ; ICW2 : 40h OUT 12h, AL ; SET InputControlWord2 MOV AL, 03h ; AEOI(Automatic Interrupt) = 1, 8086= 1 OUT 12h, AL ; SET InputControlWord4 MOV AL,1011110B; mask OUT 12H,AL RET SETUP_8259 ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; INSERT_ISR_INTO_VECTOR_TABLE PROC NEAR XOR AX, AX MOV ES, AX MOV AL, 40H MOV AH, 4 MUL AH MOV BX, AX LEA AX, INC_AX_PER_15_SEC MOV WORD PTR ES:[BX], AX MOV AX, CS MOV WORD PTR ES:[BX+2], AX XOR AX, AX MOV ES, AX MOV AL, 45H MOV AH, 4 MUL AH MOV BX, AX LEA AX, STORE_VALUE MOV WORD PTR ES:[BX], AX MOV AX, CS MOV WORD PTR ES:[BX+2], AX RET INSERT_ISR_INTO_VECTOR_TABLE ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Interrupt Routine INC_AX_PER_15_SEC PROC FAR INC AX CMP AX, 10h JNZ BACK1 MOV AX, 0h BACK1: IRET INC_AX_PER_15_SEC ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Interrupt Routine STORE_VALUE PROC FAR IN AL,74H IRET STORE_VALUE ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; CODE ENDS END START