{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

samples - Q1(b Assume that there is an unsigned number...

Info icon This preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Q1. (b) Assume that there is an unsigned number stored in register A. Write an assembly language subroutine to test if the number in A is divisible by 4 without using the DIV AB instruction . If it is divisible, set R1 to 1, otherwise set R1 to 0. DIVFOUR: MOV R1, #0 ; not divisible JB ACC.0, EXIT JB ACC.1, EXIT MOV R1, #1 ; divisible EXIT : RET
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
Q2. Assume that P2.0 through P2.4 of a 8051 are connected to three switches and two leds as displayed in the figure. (a) For the following code, fill in the missing parts of the code so that the code will execute in accordance with the comment lines. Assume that DELAY subroutine already exists, so you are not supposed to write the DELAY subroutine. Hint: The instruction “MOVX destination,@Rx” can be used to access the external memory. ORG 0 MOV R1, #08H START: MOV P2, #07H HERE: JNB P2.2, HERE .................................... ; monitor P2.2, go to the next line if high, ;stay here otherwise MOV A, P2 ANL A, #3 ................................... ; read P2.0-P2.1 to A ................................... MOV DPTR, #PLIST MOVC A, @A+DPTR .................................... ; read to A from ROM, starting from the memory location ;#PLIST + A MOV R0, A
Image of page 2
Image of page 3
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