Programming

Introduction:

The programming information here is geared towards my 8088 PBC. The I/O port addresses and memory map may be different on your 8088 depending on how you built it. You should be able to modify my code to match your needs.

To program your 8088 your going to need a good 8088 Assembler. My choice assembler is Netwide Assembler (NASM). NASM HOME PAGE



8255A:

To communicate with the 8255 it is simple, you just set the operating mode in the control register. Then you can communicate in or out with Port A, B, or C. The three ports are divided into two groups when setting port modes. Group A is Port A and the upper 4 bits of Port C. Group B is Port B and the lower 4 bits of Port C. When setting the mode Group B has two options and Group A has three options. Mode 0 is basic Input/Output , Mode 1 Strobed Input/Output, Mode 2 Strobed Bidirectional Bus I/O.


For my 8088 PCB's the base port for the 8255 is address 0x00


To set Port A, Port B, Port C as all outputs

MOV AL, 0x80 ;Set AL 10000000 = Port active \ A,B,C Outputs and mode 0

OUT 0x63, AL ;Store the value in the Control Port

or

set Port A, Port B, Port C as all inputs

MOV AL, 0x9B ;Set AL 10011011 = Port active \ A,B,C Inputs and mode 0.

OUT 0x63, AL ;Store the value in the Control Port


More to come on bidirectional communication................................



8259A - PROGRAMMABLE INTERRUPT CONTROLLER:

The programmable interrupt controller has two writable port addresses that are used during the setup of the 8259A. Address line A0 selects which port you are writing to. To set up the controller you send Initialization Command Words to the 8259A to determine how you want the controller to function.


Initialization Command Word 1


A0 D7 D6 D5 D4 D3 D2 D1 D0

0 A7 A6 A5 1 LTIM ADI SNGL ICW4


ICW4

1 = ICW4 NEEDED

0 = NO ICW4 NEEDED


SNGL

1 = SINGLE

0 = CASCADE MODE


ADI CALL ADDRESS INTERVAL

1 = INTERVAL OF 4

0 = INTERVAL OF 8


LTIM

1 = LEVEL TRIGGERED MODE

0 = EDGE TRIGGERED MODE


A7 - A5

NOT USED 8085 ONLY

A7 - A5 OF INTERRUPT VECTOR ADDRESS


Initialization Command Word 2

A0 D7 D6 D5 D4 D3 D2 D1 D0

1 T7 T6 T5 T4 T3

T7 - T3 = OFFSET INTERRUPT ADDRESS


Initialization Command Word 3 (Only require if you are in cascade mode)

A0 D7 D6 D5 D4 D3 D2 D1 D0

1 S7 S6 S5 S4 S3 S2 S1 S0


S7 - S0 1 IR INPUT HAS SLAVE

1 = IR INPUT HAS SLAVE

0 = IR INPUT DOES NOT HAVE SLAVE


Initialization Command Word 4 (Required if ICW1 - D0 = 1)

A0 D7 D6 D5 D4 D3 D2 D1 D0

1 0 0 0 SFNM BUF M/S AEOI PM

SFNM

1 = SPECIAL FULLY NESTED MODE

0 = NOT SPECIAL FULLY NESTED MODE


BUF, M/S

0, X NON BUFFERED MODE

1, 0 = BUFFERED MODE/SLAVE

1, 1 = BUFFERED MOVE/MASTER


AEOI

1 = AUTO END OF INTERRUPT

0 = NORMAL END OF INTERRUPT


PM

1 = 8086/8088 MODE

0 = 8085 MODE


Code:

This code example is with the base address of the 8259A at port 0x20


ICW1: (Single 8259A, ICW4 required)

MOV AL, 0x13

OUT 0x20, AL


ICW2: (Starting interrupt # 0x08)

MOV AL, 0x08

OUT 0x21, AL


ICW3: (Not needed because there are no slave 8259A)


ICW4: (8088 mode)

MOV AL, 0x09

OUT 0x21, AL


Note:

If you don't auto end your interrupts you have to send an end of interrupt command to the 8259A using an Operation Control Word. This is done at the end of your interrupt sub routine.


Operation Control Word 2


A0 D7 D6 D5 D4 D3 D2 D1 D0

0 R SL EOI 0 0 L2 L1 L0


OCW2: EOI

MOV AL, 0x20

OUT 0x20, AL


OCW1: Mask interrupts 1=maksed

MOV AL, 0xFF

OUT 0x21, AL


8253A - PROGRAMMABLE INTERVAL TIMMER:

The 8253 has 3 programmable channels. That have 6 modes of operations. On my PC and most PC's. Channel 0 is connected to IRQ0 / INT 0x08 (after set up). Channel 1 is connected to DRQ1 and is used for DRAM refresh. Channel 2 is connected to The PC speaker.


The mode for any channel is set up through a single register at port 0x43.

The count for each channel is loaded into its corresponding register 0x40-0x42


Control Register:


D7 D6 D5 D4 D3 D2 D1 D0

SC1 SC0 RL1 RL0 M2 M1 M0 BCD


SC1/0

Selects the counter being programmed 0-2


RL1/0

00 = Counter Latching operations

01 = Read/Write low byte of counter value only

10 = Read/Write high byte of counter value only

11 = Read/Write low byte then high byte of counter value


M2-0

Selects the mode of operation 0-5


BCD

0 = 1 Counter is a 16-bit binary

1 = Counter is a 4-digit binary coded decimal counter


Sample code to set up Channel 0 (IRQ0)

MOV AL, 0X36 ;00110110b

;CHANNEL 0

;WRITE LOW BYTE THEN HIGH BYTE

;MODE 3

;16 BIT COUNTER

OUT 0X43, AL ;CONTROL REG


MOV CX, 0XFFFF ;COUNT


MOV AL, CL ;WRITE LOW BYTE OF COUNT

OUT 0X40, AL ;PORT 0X40

;INTERNAL FLIP-FLOP INC

MOV AL, CH ;WRITE HIGH BYTE OF COUNT

OUT 0X40, AL ;PORT 040


LCD 4x20

For my project I connected the LCD screens data pins to Port B and the LCD control pins to the lower part of Port C of the 8255 or 71055.


Conecting 8255/71055 to LCD:


Port B LCD

PB0 - PB7 = Data Pin 0 - Data Pin 7


Port C LCD

PC0 = Enable

PC1 = Read/Write

PC2 = Resister Select


Code:

Download: LCD source code

Basic hello world handles line feed, carriage return, backspace, and scrolling up.