hw16SLN - ECE 212 HW Set 16 SOLUTIONS p 1 of 9

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
ECE 212 HW Set 16 SOLUTIONS p 1 of 9 //home/vdimitrov/6673/ef6a606a2db130bc514bb342b937512689654d5f.doc ECE 212 Homework Set 16 – SOLUTIONS 1. An input device has an InDR signal to indicate that data is ready. This device is interfaced to the 6812 as shown, with InDR connected to bit 0 of Port B. The 8-bit data from the device is connected to Port A. (a) Write the subroutine Get1Byte specified below. Assume that the labels 'PortA' and 'PortE' have been defined elsewhere. (b) Complete the 'Destroys' line of the subroutine header. A Solution: (a) (b) ;Name: Get1Byte [Byte Get1Byte(void)] ;Preconditions: None. ;Postconditions: A = One Byte from Port A. ;Destroys: No registers. ;Description: Wait until InDR = 1. ; [InDR is connected to bit 0 of Port B.] ; Then read the Byte at Port A and return with ; the Byte in A. Get1Byte: ldaa PortB ;Is data anda #1 ; available? beq Get1Byte ; NO -- try again. ldaa PortA ; YES -- read it. rts Input Device Data InDR 68HC12 Port A Port B, Bit 0
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
ECE 212 HW Set 16 SOLUTIONS p 2 of 9 2. (a) Write the subroutine Get1ByteA specified below. (This routine is similar to that in Problem 1, except that this routine waits for a complete pulse on the InDR signal.) (b) Complete the 'Destroys' line of the subroutine header. A Solution: (a) (b) ;Name: Get1ByteA [Byte Get1ByteA(void)] ;Preconditions: None. ;Postconditions: A = One Byte from Port E. ;Destroys: Flags. ;Description: Wait until InDR = 1, then wait until InDR = 0. ; [InDR is connected to bit 0 of Port B.] ; Then read the Byte at PortA and return with the ; Byte in A. Get1ByteA: Wait4One: ldaa PortB ;Wait for anda #1 ; InDR = 1. beq Wait4One ; Wait4Zero: ldaa PortB ;Now wait anda #1 ; until bne Wait4Zero ; InDR = 0. ldaa PortA ;We found a complete pulse on InDR; rts ; get the data and return.
Background image of page 2
ECE 212 HW Set 16 SOLUTIONS p 3 of 9 3. (a) Write the subroutine Replace specified below. You subroutine must work properly when it is called with the value 0 in Y. (b) Complete the 'Destroys' line of the subroutine header.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 9

hw16SLN - ECE 212 HW Set 16 SOLUTIONS p 1 of 9

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online