Presentation is loading. Please wait.

Presentation is loading. Please wait.

Signal Name Direction w.r.t. Printer Function Summary Pin# (25-DB) CPU

Similar presentations


Presentation on theme: "Signal Name Direction w.r.t. Printer Function Summary Pin# (25-DB) CPU"— Presentation transcript:

1 Signal Name Direction w.r.t. Printer Function Summary Pin# (25-DB) CPU
side (36-DB) Printer D<7..0> Input 8-bit data bus 9,8,…,2 STROBE# 1-bit control signal High: default value. Low: read-in of data is performed. 1 ACKNLG# Output 1-bit status signal Low: data has been received and the printer is ready to accept new data. 10 BUSY Low: default value High: see note#1 11 PE# High: the printer is out of paper. Low: default value. 12 INIT# Low: the printer controller is reset to its initial state and the print buffer is cleared. 16 31 SLCT High: the printer is in selected state. 13 AUTO FEED XT# Low: paper is automatically fed after one line. 14 SLCT IN# Low: data entry to the printer is possible. High: data entry to printer is not possible. 17 36 ERROR# Low: see note#2. 15 32

2 CS501 Advanced Computer Architecture
Lecture26 Dr.Noor Muhammad Sheikh

3

4 Centronics Bit Assignment for the I/O Ports
Logical Address Description 7 6 5 4 3 2 1 8-bit output port for DATA D<7> D<6> D<5> D<4> D<3> D<2> D<1> D<0> 8-bit input port for STATUS BUSY ACKNLG# PE# SLCT ERROR# Unused 8-bit output port for CONTROL DIR IRQEN SLCT IN# INIT# Auto Feed XT# STROBE#

5

6 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.

7

8 movi r1, reset ;use r1 for ;data transfer out r1, controlp

9 Polling loop again: in r1, statusp ; and r1,r1,r3 ; test if BUSY = 1
jnz r1, [again] ; wait if BUSY = 1

10 ; 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

11 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

12 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 addi r5, r5, 2 subi r7, r7, 1 jnz r7, [again] halt

13 ; again: in r1, statusp [3] and r1 , r1, r3 [3] jnz r1, [again] [4]
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] addi r5, r5, 2 [3] subi r7, r7, 1 [3] jnz r7, [again] [4] halt

14 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.

15 load r1, [r5] [5] out r1, datap [3] The execution time for these two instructions is 5+3 = 8 clock periods.

16 movi strb_H [2] out r1, controlp [3] The execution time for these two instructions is 2+3 = 5 clock periods.

17 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 = 10 clock periods.

18 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 = =38 clock cycles Hence 38x100=3.8 s

19 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 996 s before sending the next character. Thus the poling loop will be executed about 996 times for every character which is very inefficient.

20 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

21 Example Assume a 64 byte FIFO buffer inside a 1000 cps printer
Time required to print a character is 1ms.

22 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]

23 Program execution time
Polling loop still takes 10 clock periods or 1 s. The main loop of the program is executed in =28 clock cycles. For a 10MHz FALCON-A CPU, 28x100=2.8 s

24 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.

25 Using a larger buffer Cost of printer will increase Same situation arises after the buffer is filled up

26 Output register COUT = FFFFF114H
Status register COSTAT = FFFFF110H

27 Wait: ld r1, COSTAT ;Read device status register,
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.

28 Output Register LOUT = FFFFF134H
Status Register LSTAT = FFFFF130H Unused Print Line Command Register LCMD = FFFFF138H

29 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.

30 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.

31 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.

32 Instruction count Total instruction count to print a line =3+(80x7)+2 =565 instructions

33 Figure 8.9 (jordan) Program fragment to print 80 line character

34 Figure 8.8 (jordan) Program fragment for character output

35 Review

36 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.


Download ppt "Signal Name Direction w.r.t. Printer Function Summary Pin# (25-DB) CPU"

Similar presentations


Ads by Google