Professional Documents
Culture Documents
; BIN is plain binary format similar to .com format, but not limited to 1 segment;
; All values between # are directives, these values are saved into a separate .binf
file.
; Before loading .bin file emulator reads .binf file with the same file name.
; All directives are optional, if you don't need them, delete them.
; set stack
#SS=0000h# ; same as loading segment
#SP=FFFEh# ; set to top of loading segment
jmp start1
db 381 dup(0)
;main program
start1: cli
;initialise ds,es,ss to start of RAM
mov ax,0200h
mov ds,ax
mov es,ax
mov ss,ax
mov sp,0FFFEh
;initialize 8255
mov al, 10010001b ;PortA: i/p, PortCd: i/p, PortB: o/p, PortCu:
o/p, Mode 0
out 36h, al
;initialize 8253[1] mock, base address 10h
mov al, 00110100b ;Mode 2 counter 0 binary
out 16h, al
mov al, 01110100b ;Mode 2 counter 1 binary
out 16h, al
mov al, 10110100b ;Mode 2 counter 2 binary
out 16h, al
;initialize 8253[2] mock, base address 20h
mov al, 00010100b ;mode 2 counter 0 binary
out 26h, al
mov al, 01011010b ;mode 5 counter 1 binary
out 26h, al
mov al, 10011010b ;mode 5 counter 2 binary
out 26h, al
;CW initialisations for the original counter set is the same as that of the mock
counter set
;initialize 8253[1], base address 50h
mov al, 00110100b
out 56h, al
mov al, 01110100b
out 56h, al
mov al, 10110100b
out 56h, al
;initialize 8253[2], base address 60h
mov al, 00010100b
out 66h, al
mov al, 01011010b
out 66h, al
mov al, 10011010b
out 66h, al
sti
;8255 starting addrsess 30h
;read i/p from PA
;PortA: i/p, PortCd: i/p, PortB: o/p, PortCu: o/p, Mode 0
;i/p bit 1 means watering is needed
isr_60: in al,30h ;read i/p from PA
;call delay_0.04s
mov cx,0
cmp bx,cx ;check if all of them are zero
jne isr_60
iret