{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

Info icon This 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;
Image of page 1

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

View Full Document Right 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
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.
Image of page 3

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

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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern