Quiz2_sample2 - BILKENT UNIVERSITY Department of Electrical...

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

View Full Document Right Arrow Icon
BILKENT UNIVERSITY Department of Electrical and Electronics Engineering EEE212 Microprocessors QUIZ 2 19-03-2010 Sections 2 and 5 Open book, closed notes, no calculators. Duration: 45 minutes Surname : Name : ID Number : Section : Signature : Question 1 (45 pts) : Question 2 (55 pts) : TOTAL :
Background image of page 1

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

View Full DocumentRight Arrow Icon
1) Assume that four 8 bit numbers (x values) are stored at memory locations 20H to 23H and four other 8 bit numbers (y values) are stored at memory locations 30H to 33H. a) ( 10 pts) Write a code which makes the calculation z = x+y and stores the result (z) starting from memory location 30H. Assume that the result of each of the additions will be smaller than 256 (x+y<256), so you can just ignore the carry. Use a loop, otherwise no credit will be granted . ORG 000H MOV R0, #20H MOV R1, #30H MOV R2, #4 CLR A LOOP: MOV A, @R0 ADD A, @R1 MOV @R1, A INC R0 INC R1 DJNZ R2, LOOP EXIT: SJMP EXIT
Background image of page 2
b) (20 pts) Rewrite your code so that the sum of z's are also calculated while z's are stored in 30H to 33H, and the overall sum (sum of z's ) is stored in memory locations 34H and 35H, where 34H holds the higher byte. Like in part ( a ), assume that x+y<256 for each (x,y) pair, but you need to consider the carry coming from the addition of z’s. ORG 000H
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 / 5

Quiz2_sample2 - BILKENT UNIVERSITY Department of Electrical...

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