hw15SLN - ECE 212 HW Set 15 SOLUTIONS p 1 of 12

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

View Full Document Right Arrow Icon
ECE 212 HW Set 15 SOLUTIONS p 1 of 12 //home/vdimitrov/6678/b17507542489153a36e0891527bfe53d605466bd.doc ECE 212 Homework Set 15 – SOLUTIONS 1. Write a program to: Read three Bytes from Port A, store them in memory; if ( first value == 0x30 ) AND ( second value == 0x40 ) AND (third value == 0x50) send 0xFF to Port B ; else send 00 to Port B ; Return to DBug12; Your program must include the memory allocation for storing the data from Port A. Use a three-Byte array. Neatly organize the branching in your program. A Solution: Program organization: Read, store the three values; B = 0; if (first value != 30h) ; else if (second value != 40h) ; else if (third value != 50h) ; else B = 0xFF; PortB = B; Return to DBug12;
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 15 SOLUTIONS p 2 of 12 (1. Solution) The program: .data V: .space 3 ;A three-Byte array. .text main: ldx #V ;Collect the movb PortA 0,X ; three Bytes, movb PortA 1,X ; putting them movb PortA 2,X ; into the array. clrb ;Anticipate a False result. ldaa 0,X ;If the first Byte cmpa #0x30 ; is NOT 30, bne send ; then no more testing. ldaa 1,X ;If the second Byte cmpa #0x40 ; is NOT 40, bne send ; then no more testing. ldaa 2,X ;If the third Byte cmpa #0x50 ; is NOT 50, bne send ; then no more testing. ldab #0xFF ;All conditions are true: send FF. send: stab PortB jmp DBug12
Background image of page 2
ECE 212 HW Set 15 SOLUTIONS p 3 of 12 2. Write a program to: Read three Bytes from Port A, store them in memory; if ( first value == 0x30 ) OR ( second value == 0x40 ) OR (third value == 0x50) send 0xFF to Port B ; else send 00 to Port B ; Return to DBug12; Your program must include the memory allocation for storing the data from Port A. Use a three-Byte array. Neatly organize the branching in your program. (When is it unnecessary to check the second and third values?) A Solution: As soon as you find a True condition, you're done. Program organization:
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.

This homework help was uploaded on 04/17/2008 for the course ECE 212 taught by Professor Greco during the Spring '08 term at Lafayette.

Page1 / 12

hw15SLN - ECE 212 HW Set 15 SOLUTIONS p 1 of 12

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