0% found this document useful (0 votes)
5 views

Lecture 26

The document outlines the pin assignments and functions for a Centronics parallel printer interface with a FALCON-A processor, detailing input/output signals and their statuses. It includes an assembly language program example to send an 80-character line to the printer, discussing polling efficiency and the use of a buffer to optimize performance. Additionally, it covers instruction counts and execution times for various operations related to printing characters.

Uploaded by

imaan maqsood
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Lecture 26

The document outlines the pin assignments and functions for a Centronics parallel printer interface with a FALCON-A processor, detailing input/output signals and their statuses. It includes an assembly language program example to send an 80-character line to the printer, discussing polling efficiency and the use of a buffer to optimize performance. Additionally, it covers instruction counts and execution times for various operations related to printing characters.

Uploaded by

imaan maqsood
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 36

Signal Directio Function Pin# Pin#

Name n Summary (25-DB) (36-DB)


w.r.t. CPU Printer
Printer side side
D<7..0> Input 8-bit data bus 9,8,…,2 9,8,…,2
1-bit control signal
STROBE# Input High: default value. 1 1
Low: read-in of data is performed.
1-bit status signal
ACKNLG# Output Low: data has been received and the printer is ready to accept new 10 10
data.
High: default value.
1-bit status signal
BUSY Output Low: default value 11 11
High: see note#1
1-bit status signal
PE# Output High: the printer is out of paper. 12 12
Low: default value.
1-bit control signal
INIT# Input Low: the printer controller is reset to its initial state and the print 16 31
buffer is cleared.
High: default value.

SLCT Output 1-bit status signal 13 13


High: the printer is in selected state.

AUTO Input 1-bit control signal


FEED XT# Low: paper is automatically fed after one line. 14 14
1-bit control signal
Low: data entry to the printer
is possible.
SLCT IN# Input High: data entry to printer is not
17 36
possible.

1-bit status signal 15 32


ERROR# Output Low: see note#2.
High: default value.
CS501
Advanced Computer
Architecture

Lecture26

Dr.Noor Muhammad Sheikh


Centronics Bit Assignment
for the I/O Ports

Logical Description 7 6 5 4 3 2 1 0
Address

0 8-bit output port for D<7> D<6> D<5> D<4> D<3> D<2> D<1> D<0>
DATA

1 8-bit input port for BUSY ACKNLG# PE# SLCT ERROR# Unused Unused Unused
STATUS

2 8-bit output port for Unused Unused DIR IRQEN SLCT IN# INIT# Auto Feed STROBE#
CONTROL XT#
Problem Statement

Assuming that a Centronics parallel


printer is interfaced to the FALCON-A
processor, as shown in example 9-4,
write an assembly language program
to send an 80 character line to the
printer. Assume that the line of
characters is stored in the memory
starting at address 1024.
movi r1, reset ;use r1 for
;data transfer
out r1, controlp
Polling loop
again: in r1, statusp
;
and r1,r1,r3 ; test if BUSY = 1
jnz r1, [again] ; wait if BUSY = 1
;
; filename: Example_11-8.asmfa
;
;This program sends an 80 character line
;to a FALCON-A parallel printer
;
; Notes:
; 1. 8-bit printer data bus connected to
; D<7..0> of the FALCON-A (remember big-endian)
; Thus, the printer actually uses addresses 57, 59 & 61
;
; 2. one character per 16-bits of data xfered
;
;
.org 400
;
NOB: .equ 80
;
movi r5, 32
mul r5, r5, r5 ; r5 holds 1024 temporarily
;
movi r3, 1
shiftl r3,r3,7 ; to set mask to 0080h
datap: .equ 56
statusp: .equ 58
controlp: .equ 60
;
reset: .equ 1
; used to set unidirectional, no interrupts,
; auto line feed, and strobe high
;
strb_H: .equ 5
strb_L: .equ 4
;
movi r1, reset ; use r1 for data xfer
out r1, controlp
;
movi r7, NOB ; use r7 as character counter
;
again: in r1, statusp
;
and r1,r1,r3 ; test if BUSY = 1 ?
jnz r1, [again] ; wait if BUSY = 1
;
load r1, [r5]
out r1, datap
movi r1, strb_L
out r1, controlp
movi r1, strb_H
out r1, controlp
addi r5, r5, 2
subi r7, r7, 1
jnz r7, [again]
halt
movi r7, NOB [2]
;
again: in r1, statusp [3]
and r1 , r1, r3 [3]
jnz r1, [again] [4]
;
load r1, [r5] [5]
out r1, datap [3]
movi r1, strob_L [2]
out r1, controlp [3]
movi r1, s trob_H [2]
out r1, controlp [3]
addi r5, r5, 2 [3]
subi r7, r7, 1 [3]
jnz r7, [again] [4]
halt
Consider the following
instructions:
movi r1, strb_L [2]
out r1, controlp [3]

• The execution time for these two


instructions is 2+3 = 5 clock periods.
load r1, [r5] [5]
out r1, datap [3]

• The execution time for these two


instructions is 5+3 = 8 clock periods.
movi strb_H [2]
out r1, controlp [3]

• The execution time for these two


instructions is 2+3 = 5 clock periods.
Polling Loop
again: in r1, statusp [3]
and r1, r1, r3 [3]
jnz r1, [again] [4]

• The execution time required by the


polling loop is 3+3+4 = 10 clock periods.
Time required by polling loop

The polling loop takes 10 clock cycles. For a


10MHz FALCON-A CPU, this is 10x100=1s
One pass of the main loop
=3+3+4+5+3+2+3+2+3+3+3+4
=38 clock cycles
Hence 38x100=3.8 s
Efficiency of polling

Assuming a 1000 character per second


printer connected to FALCON-A CPU,
1character is printed every 1000 s. Hence
the CPU will wait for 1000-3.8996 s
before sending the next character. Thus the
poling loop will be executed about 996 times
for every character which is very inefficient.
Buffer

• A small memory inside the printer


• CPU interacts with printer through
buffer
• Buffer relieves the CPU to
perform other tasks while the
printer is busy
Example

• Assume a 64 byte FIFO buffer


inside a 1000 cps printer
• Time required to print a character
is 1ms.
Modified program code

again: in r1, statusp [3]


and r1 , r1, r3 [3]
jnz r1, [again] [4]
;
load r1, [r5] [5]
out r1, datap [3]
addi r5, r5, 2 [3]
subi r7, r7, 1 [3]
jnz r7, [again] [4]
Program execution time

Polling loop still takes 10 clock periods


or 1 s.
The main loop of the program is executed in
3+3+4+5+3+3+3+4=28 clock cycles. For a
10MHz FALCON-A CPU, 28x100=2.8 s
Efficiency of polling

The outer loop will execute 64


times before the BUSY signal goes
to 1. After that the polling loop will
execute for about 996 times before
BUSY goes to 0.
Using a larger buffer

• Cost of printer will increase


• Same situation arises after the
buffer is filled up
Output register COUT = FFFFF114H

Status register COSTAT = FFFFF110H


lar r3, Wait ;Set branch target for wait.
ldr r2, Char ;Get character for output.
Wait: ld r1, COSTAT ;Read device status register,
brpl r3, r1 ;Branch to Wait if not ready.
st r2, COUT ;Output character and start device.
Output Register LOUT = FFFFF134H

Status Register LSTAT = FFFFF130H

Unused

Print Line
Command Register LCMD = FFFFF138H
lar r1, Buff ;Set pointer to character buffer.
la r2, 80 ;Initialize character counter and
lar r3, Wait ; branch target.
Wait: ld r0, LSTAT ;Read Ready bit,
brpl r3, r0 ; test, and repeat if not ready.
ld r0, 0(r1) ;Get next character from buffer,
st r0, LOUT ; and send to printer.
addi r1, r1, 4 ;Advance character pointer, and
addi r2, r2, -1 ; count character.
brnz r3, r2 ;If not last, go wait on ready.
la r0, 1 ;Get a print line command,
st r0, LCMD ; and send it to the printer.
• Buff = Pointer to character Buffer.

• Two nested loops starting at the label


Wait:

1). The two instruction inner loop,


which waits for Ready.
2). The outer seven-instruction loop.
The outer seven-instruction loop
perform following tasks:

• Outputs a character
• Advance the buffer pointer
• Decrement the register containing the
number of characters left to print
• Repeat if there are more characters left to
send.

The last two instructions issue the


command to print the line.
Instruction count

Total instruction count to print a line


=3+(80x7)+2
=565 instructions
Figure 8.9 (jordan)
Program fragment to print 80
line character
Figure 8.8 (jordan)
Program fragment for
character output
Review
Start: la r2, 0 ;Point to first device, and
la r3, 1 ; set all inactive flag.
Check: ld r0,Done(r2) ;See if device still active, and
brmi r4, r0 ; if not, go advance to next device.
ld r3, 0 ;Clear the all inactive flag.
ld r0,CICTL(r2) ;Get device ready flag, and
brpl r4, r0 ; go advance to next if not ready.
ld r0,CIN(r2) ;Get character and
ld r1,Bufp(r2) ; correct buffer pointer, and
st r0, 0(r1) ; store character in buffer.
addi r1,r1,4 ;Advance character pointer,
st r1,Bufp(r2) ; and return it to memory.
addi r0,r0,-CR ;Check for carriage return, and
brnz r4, r0 ; if not, go advance to next device.
la r0, -1 ;Set done flag to -1 on
st r0,Done(r2) ; detecting carriage return.
Next: addi r2,r2,8 ;Advance device pointer, and
addi r0,r2,-256 ; if not last device,
brnz r5, r0 ; go check next one.
brzr r6, r3 ;If a device is active, make a new pass.

You might also like