You are on page 1of 5

; This is a simple program to test the 8259A with 16 bit systems for ; the S-100 PIC/RTC Board ; John

Monahan (monahan@vitasoft.org) 7/7/2010 ; LF equ 0ah CR equ 0dh ; SDSTAT EQU 0H ;Consol Output Status port SDDATA EQU 1H ;Consol Output Data port ; NSEOI equ 20h ;Non specific end of interrupt command MasterPICPORT equ 20h ;Hardware port the 8259A is assigned (two ports 20H & 21H) MasterICW1 MasterICW2 as IBM-PC) MasterICW3 MasterICW4 cseg org ; DB 0DBH,0EDH in the 8086 location 500H in RAM org 0500H ; init: cld cli mov ax,cs mov ds,ax mov es,ax mov ss,ax mov sp,offset stack mov bx,offset SIGNON call print CALL CI mov bx,offset CRLFMSG call print mov out mov out mov out mov out MOV MOV More: MOV INC INC MOV INC INC CMP JNZ MOV on bus) MOV al,MasterICW1 MasterPICPORT,al al,MasterICW2 MasterPICPORT+1,al al,MasterICW4 MasterPICPORT+1,al ;CPM3/Z80 code. This will input port ED. This switches ;The 8086 monitor after initilization, will jump to equ equ equ equ 0H 100H 00010111B 8H 0H 00000011B ;EDGE triggered, 4 bytes, single Master,ICW4 needed ;Base address for 8259A Int Table (8H X 4 = 20H), (Same ;No slave ;No special mode, non buffer, Auto EOI, 8086. ;Everything in this simple program will be at CS: 0H

;Set direction up ;Disabel interrupts ;Note CS will be 0H ;As will DS here ;Stack in same segment ;Must point to a RAM area ;Send a signon message ;Wait for stat key ;Send a CRLF ;Initilize the 8259A PIC Controller ;Ints start at 20H in RAM ;No slaves above, so 8259 does not expect ICW3

al,0h ;NO mask (i.e. all 8 int lines will be accepted) MasterPICPORT+1,al DI,0 ;Set up Software INT vectors in low memory: AX,Offset TrapInt ;Location of default interrupt. If chip is programmed [DI],Word Ptr AX ;wrong, it MAY end up here. DI DI [DI],CS DI DI DI,400H ;Do from 0 to 3ffH More DI,3FCH AX,Offset TrapFFInt ;Location of INT FF (8259A is not putting vector

MOV MOV MOV MOV INC INC MOV MOV MOV MOV INC INC MOV INC INC MOV MOV INC INC MOV INC INC MOV MOV INC INC MOV INC INC MOV MOV INC INC MOV INC INC MOV MOV INC INC MOV INC INC MOV MOV INC INC MOV INC INC MOV MOV INC INC MOV

[DI],Word Ptr AX DI,000CH ;Location for single byte 8086 CC debug trap AX,Offset DebugTrap ;Location of Hardware Int V0 routine [DI],Word Ptr AX ;We will now (one by one) put in the 8 DI ;interrupt jump locations. DI [DI],CS DI,MasterICW2*4 AX,Offset V0int [DI],Word Ptr AX DI DI [DI],CS DI DI AX,Offset V1int [DI],Word Ptr AX DI DI [DI],CS DI DI AX,Offset V2int [DI],Word Ptr AX DI DI [DI],CS DI DI AX,Offset V3int [DI],Word Ptr AX DI DI [DI],CS DI DI AX,Offset V4int [DI],Word Ptr AX DI DI [DI],CS DI DI AX,Offset V5int [DI],Word Ptr AX DI DI [DI],CS DI DI AX,Offset V6int [DI],Word Ptr AX DI DI [DI],CS ;Now setup the 8 jump locations for the hardware ;<---- Location of 8259A INT table ;Location of Hardware Int V0 routine ;We will now (one by one) put in the 8 ;interrupt jump locations.

;Location of Hardware Int V1 routine

;Location of Hardware Int V2 routine

;Location of Hardware Int V3 routine

;Location of Hardware Int V4 routine

;Location of Hardware Int V5 routine

;Location of Hardware Int V6 routine

INC INC MOV MOV INC INC MOV INC INC

DI DI AX,Offset V7int [DI],Word Ptr AX DI DI [DI],CS DI DI ;Location of Hardware Int V7 routine

;All setup, now allow int's LOOP: cli mov call sti JMP cl,'.' CO LOOP ;Just to be safe, stop ints during consol I/O ;For testing puroses just put the 8086 in a loop ;Are there any Ints? ;For ever until you hit reset

; ;------------------------ SUPPORT ROUTINES --------------------------; ; ROUTINE TO PRINT A STRING BX = START OF STRING $ = FINISH ; print: push cx print1: mov al,[bx] inc bx cmp al,'$' jnz print2 pop cx ret print2: mov cl,al call CO jmp print1 ; ; ; BINARY OUTPUT ;send what is in [al] ; ZBITS: push cx mov cx,8 binout1: push cx shl al,1 jb bout1 mov cl,'0' push ax call CO pop ax jmp binend bout1: mov cl,'1' push ax call CO pop ax binend: pop cx loop binout1 pop cx ; mov cl,CR ;Finish with a CR/LF call CO mov cl,LF call CO ret ; ;<<<<<<<<<<<<<<<<<<<<<< MAIN CONSOL OUTPUT ROUTINE >>>>>>>>>>>>>>> ; CO: IN AL,SDSTAT ;SD SYSTEMS VIDIO BOARD PORT TEST AL,4H

LX2:

JZ MOV CMP JNZ RET OUT RET

CO AL,CL AL,0H LX2 SDDATA,AL AL,SDSTAT AL,02H NONE AL,AL AL

;SD BOARD CANNOT TAKE A NULL

CSTS: IN TEST JZ XOR DEC RET NONE: XOR RET CI: CALL JZ IN RET

;RETURN WITH 0FFH IN [A] IF SOMETHING AL,AL CSTS CI AL,SDDATA ;Wait until something is there

;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ; ORG 700H signon DB CRLFMSG DB '8086 test of Interrupts on PIC/RTC board 'Press any key to start...$' DB CR,LF,'$' 7/6/2010',CR,LF

TrapIntMSG DB TrapFFIntMSG hardware assigned DebugTrapMSG ORG Int0MSG Int1MSG Int2MSG Int3MSG Int4MSG Int5MSG Int6MSG Int7MSG 900H DB DB DB DB DB DB DB DB RW

'Trap interrupt detected at a non-hardware assigned location.$' DB 'Trap interrupt detected at 0FFH in RAM. This is a nonlocation.$' DB 'Trap interrupt detected Software Debug INT at 0CH in RAM.$'

'V0 'V1 'V2 'V3 'V4 'V5 'V6 'V7 100

$' $' $' $' $' $' $' $' ;50 level Program stack (way more than needed!)

stack DW 0H ;Put stack here ; ;-------------------------------------------------------------------; Interrupt Routine(s) go here ;-------------------------------------------------------------------org 0B00H TrapInt: Cli MOV jmp TrapFFInt: Cli MOV jmp ;Critical area**** BX,Offset TrapIntMSG Int_msg ;Critical area**** BX,Offset TrapFFIntMSG Int_msg

DebugTrap: Cli MOV CALL IRET V0int: MOV jmp V1int: MOV jmp V2int: MOV jmp V3int: MOV jmp V4int: MOV jmp V5int: MOV jmp V6int: MOV jmp V7int: MOV jmp Int_msg: CALL ; Mov ; OUT ; IN ; CALL ; Mov interrupt ; OUT IRET ;
;END

;Critical area**** BX,Offset DebugTrapMSG print ;General info dump routine

Cli ;Critical area**** BX,Offset Int0MSG ;Will arrive here from int vector at 20H in RAM Int_msg Cli BX,Offset Int1MSG Int_msg Cli BX,Offset Int2MSG Int_msg Cli BX,Offset Int3MSG Int_msg Cli BX,Offset Int4MSG Int_msg Cli BX,Offset Int5MSG Int_msg Cli BX,Offset Int6MSG Int_msg Cli BX,Offset Int7MSG Int_msg print ;General info dump routine Al,00001011B ;Send OCW3 (Read 8259A Interrupt Service Reg) MASTER_PIC_PORT,al AL,MasterPICPORT ;Get and show Bit pattern returned. ZBITS ;Send bit pattern along with a CR/LF Al,NS_EOI MASTER_PIC_PORT,al ;8259A End of Interrupt command, can now allow another ;Will arrive here from int vector at 24H in RAM

;Will arrive here from int vector at 28H in RAM