

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Three problems from an embedded systems exam held in spring 2008. The problems involve writing assembly code, converting assembly code to c code, and analyzing the behavior of an unconventional subroutine. No registers are altered by the provided code in problem 1, and no registers or memory locations are given initial values in problem 3.
Typology: Exams
1 / 3
This page cannot be seen from the preview
Don't miss anything!


Student Name:______________________________ Student ID: _______________
Problem 1 Provide the assembly code that can perform the following code.
Full credit for 5 instructions or less and 10 points off for every additional instruction. Assume that do_something – a function in C – is a subroutine in assembly.
Make sure no registers are altered by this code after completion.
Student Name:______________________________ Student ID: _______________
Problem 2
Write the equivalent C code for the assembly below. Assume J and K are global variables declared with ds.b directive that are signed integers in C.
J ds.b 1 K ds.b 1 …
ldaa J cmpa #$F bne done cmpa #$ bne done movb #$00, K done: movb #$FF, K