A Design Example A Programmable Calculator
Programmable Calculator Working in Exact Mode Receiving Program from RS232 Port Saving Programs using RS232 Port Memory Fill/View/Edit/Search Switch to floating point calculator Using DMA for Large Data Transfer
Hardware Specifications Keyboard with 64 (8x8) Keys 8 Seven-Segment Display Timer Options: hh – mm – ss 8087 Coprocessor Maximum Mode DMA 8237 for Fast Data Transfer UART 8250 for RS232 Port RAM ( FFFF) – EPROM (80000-FFFFF) Clock = *16*4= Hz =7.3728MHz
CPU Pins in Maximum Mode GND AD14 AD13 AD12 AD11 AD10 AD9 AD8 AD7 AD6 AD5 AD4 AD3 AD2 AD1 AD0 NMI INTR CLK GND VCC AD15 A16/S3 A17/S4 A18/S5 A19/S6 RQ/GT0 RQ/GT1 QS0 READY RESET BHE/S7 MN/MX RD LOCK S2 S1 S0 QS1 TEST Max Mode GND
S2S1S0 Characteristics 000 Interrupt acknowledge 001 Read I/O port 010 Write I/O port 011 Halt 100 Code access 101 Read memory 110 Write memory 111 Passive State S0, S1 and S2 Signals
8086 System Maximum Mode
8284 Clock Generator for 8086 an 18-pin chip specially designed to be used with 8088/86 microprocessors, It provides the clock and synchronization for the microprocessor, also provides the READY signal for the insertion of wait states into the CPU bus cycle.
7.3728MHz MHz
Bank Write and Bank Read Control Logic Bank Write Control Logic Bank Read Control Logic A0 2 EPROMs Each 256KB = 256Kx8 = Eight or SRAMs Each 256KB = 256Kx8 = Eight or Total 1M
A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 A12 A13 A14 A15 D0 D1 D2 D3 D4 D5 D6 D7 CS OE WE A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 A12 A13 A14 A15 D0 D1 D2 D3 D4 D5 D6 D7 CS OE WE A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 A12 A13 A14 A15 D0 D1 D2 D3 D4 D5 D6 D7 CS OE WE A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 A12 A13 A14 A15 D0 D1 D2 D3 D4 D5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D5 D6 D7 CS OE A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 A12 A13 A14 A15 D0 D1 D2 D3 D4 D5 D6 D7 CS OE D0 - D7 D8 - D15 A1-A16 Y0 Y1 Y2 Y3 Y4 Y5 Y6 Y7 A0 A1 A2 G1 G2 A17 A18 A19 A0 DEN Y0 Y1 Y2 Y3 Y4 Y5 Y6 Y7 A0 A1 A2 G1 G2 A17 A18 A19 BHE DEN RDL RDU RDL RDU RDL RDU EPROMs
Peripherals 8255 (Keyboard) 8255 (Display) Timer Interrupt Controller DMA 8237 Coprocessor 8087 UART 8250
Address Decoding for the Peripherals A PPI A0 A1 Latch (‘373) Display Y0 Y1 Y2 Y3 Y4 Y5 Y6 Y7 X0 X1 X2 A0 A1 A2 A3 A4 A5 A6 A7 CS 8259 A0 CS AD0-AD7 D0-D7 Buffer ALE Keyboard Address: 000XXPP0 Timer Address: 010XXPP0 Display Address: 011XXPP0 UART Address: 101XPPP Address: 110XXXP0 DMA Address: 111PPPP0 IR0 IR1 DMA Keyboard Timer UART 8259
Address Definition Keyboard_BASEEQU0 Display_BASEEQU60H Timer_BASEEQU40H UART_BASEEQU0A0H DMA_BASEEQU0E0H 8259_BASEEQU0C0H
Connecting 8087 to Processor
8250/16450/16550 UART Connection A3 A2 A1 (System) A2 A1 A0 (UART) Y5 (Decoder) CS 101XPPP0 Line Drivers RS232 io A0 A2 A4 A6 A8 AA AC AD A0 A2
Registers Transmitter holding register Receiver buffer register Interrupt enable register A2
Registers Interrupt identification register 00000PPP A4
Line Control A6 Even Parity, 2 Stop bits, 8 Data bits
Modem Registers Modem Control Register Modem Status Register A8 DTR Active status AD
Line Status Status AA
Divisor Register Input Clock : MHz Required Baud Rate: 9600 bps A6 DLAB Set A0 0 A2 Baud RateDivisor(Decimal)Divisor(hex) 460, , , , C
Intel Hex Data Format : No – Address – Data – Check Sum :0A F C F C = 375
Commands From RS232 Upload Data Download Data Dump Memory Fill Memory Go To Address Breakpoint Trace Register …
Definitions DISPLAY_SEGMENTS EQUDisplay_BASE DISPLAY_GND EQUDisplay_BASE +2 DISPLAY_CTRL EQUDisplay_BASE+ 6 KEYBOARD_ROW EQUKeyboard_BASE KEYBOARD_COL EQUKeyboard_BASE+2 KEYBOARD_CTRL EQUKeyboard_BASE+6 TIMER_CH0 EQU Timer_BASE TIMER_CH1 EQUTimer_BASE+2 TIMER_CH2 EQUTimer_BASE+4 TIMER_CTRL EQUTimer_BASE+6 IC8259_0 EQU8259_BASE IC8259_1 EQU8259_BASE+2
Main Program ORG 0FFF0H ;Address FFFF0 XOR AX,AX ;AX=0 MOV DS,AX ;DS=0 MOV AH,70H ;AX=7000H MOV SS,AX ;STACK From 7FFFFH MOV SP,0FFFFH; SS*10H+SP=7FFFFH JMP 0F000H:100
Initialize & Main LOOP ORG 100H ;Address F0100 CLI CALL INIT_KEYBOARDINIT_KEYBOARD CALL INIT_DISPLAYINIT_DISPLAY CALL INIT_TIMERINIT_TIMER CALL INIT_8259INIT_8259 CALLINIT_DMA CALLINIT_RS232 STI Main_LOOP: CALLKeyboard_hit JZRS232 CALLGETCH ;Scan Code Available in AL CALL Process_Key RS232: CALLRX_AVAILABLE JZMain_LOOP CALL Process_RX JMP Main_LOOP
INIT_KEYBOARD INIT_KEYBOARD: MOV AL, B ;Mode0 output for A & ;Mode 0 input for B input for C OUTKEYBOARD_CTRL,AL MOV AL,0FFH ;OFF All Rows OUT KEYBOARD_ROW,AL XOR AL,AL ;Reset FIFO MOV [Key_head],AL MOV [Key_tail],AL RET
INIT_DISPLAY INIT_DISPLAY: MOV AL, B ;Mode 0 and out for both A & B. C input OUT DISPLAY_CTRL,AL MOV AL,0FFH OUT DISPLAY_GND,AL ;All 7-Segments off XOR AX,AX ;Clear ALL Ms of Calc(X,Y,M0-M7) MOV ES,AX MOV DI,offset X_SIZE CLD MOV CX,10 REP:STOSW ;X_SIZE=Y_SIZE=M_SIZE0-7=0 CALL REFRESH_DISPLAYREFRESH_DISPLAY RET
REFRESH_DISPLAY REFRESH_DISPLAY: ; Shows the content of X register MOV DI,offset DISPLAY_DATA MOV AX,[X_SIZE] CMP AX,0 JNE X_NOT_ZERO XOR AX,AX MOV WORD PTR [DI],AX MOV WORD PTR [DI+2],AX MOV WORD PTR [DI+4],AX MOV BYTE PTR [DI+6],AL MOV BYTE PTR [DI+7], B RET
INIT_TIMER INIT_TIMER: MOV AL, B ;Counter 0, 2 Bytes, Mode 3, Binary OUT TIMER_CTRL,AL MOV AX,36864 ;7.3728M/36864=200Hz; Refreshing Rate OUT TIMER_CH0,AL MOV AL,AH OUT TIMER_CH0,AL MOV AL, B ;Counter 1, 2 Bytes, Mode 3, BCD OUT TIMER_CTRL,AL MOV AX,200H ;200Hz/200=1Hz; Time Refresh Rate OUT TIMER_CH1,AL MOV AL,AH OUT TIMER_CH1,AL RET
INIT_8259 INIT_8259: MOV AL, B ;ICW1: Edge - Single - ICW4 OUT IC8259_0,AL MOV AL,80H ; ICW2=Interupt Type OUT IC8259_1,AL MOV AL, B ;ICW4: 8086 Processor RET
INIT_RS232 INIT_RS232: