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

Info iconThis 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
Background image of page 1

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

View Full DocumentRight 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
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/23/2011 for the course ENGINEERIN 102 taught by Professor Pablo during the Spring '11 term at Bilkent University.

Page1 / 4

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

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

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