Embedded Systems Exam 3 - Problem 3: Analyzing Subroutine Behavior and RPN, Exams of Microprocessors

The third problem of the embedded systems exam held in fall 2006 by macdonald. Students are required to analyze the given subroutine code, fill in the memory and register table, and write an equivalent c code segment. Additionally, they need to answer short questions about reverse polish notation (rpn) and a freescale (motorola) for loop enhancement.

Typology: Exams

Pre 2010

Uploaded on 08/18/2009

koofers-user-aiu
koofers-user-aiu 🇺🇸

4

(1)

10 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
EE3376 – Embedded Systems - Fall 2006 - Exam 3 – MacDonald – Page 1
Student Name:______________________________ Student ID: _______________
Problem 3
Below is the code for a simple subroutine (do_it) that uses one local variable
implemented with a stack frame. Given the initialized values in the table, fill in the rest
of the table describing the registers and memory locations at different times during the
execution of the function.
TEMP set -1
do_it: pshb
pshx
tsx
leas TEMP,SP
movb #$20, TEMP, X
suba TEMP, X
txs
pulx
pulb
rts
Location Prior to JSR After LEAS After SUBA AFTER RTS
a10
b1
x 1000
y 3000
sp 2002
mem 1ff9 0
mem 1ffa 0
mem 1ffb 0
mem 1ffc 0
mem 1ffd 0
mem 1ffe 0
mem 1fff 0
mem 2000 0
mem 2001 0
pf3

Partial preview of the text

Download Embedded Systems Exam 3 - Problem 3: Analyzing Subroutine Behavior and RPN and more Exams Microprocessors in PDF only on Docsity!

Student Name:______________________________ Student ID: _______________

Problem 3

Below is the code for a simple subroutine (do_it) that uses one local variable

implemented with a stack frame. Given the initialized values in the table, fill in the rest

of the table describing the registers and memory locations at different times during the

execution of the function.

TEMP set -

do_it: pshb

pshx

tsx

leas TEMP,SP

movb #$20, TEMP, X

suba TEMP, X

txs

pulx

pulb

rts

Location Prior to JSR After LEAS After SUBA AFTER RTS a 10 b 1 x 1000 y 3000 sp 2002 mem 1ff9 0 mem 1ffa 0 mem 1ffb 0 mem 1ffc 0 mem 1ffd 0 mem 1ffe 0 mem 1fff 0 mem 2000 0 mem 2001 0

Student Name:______________________________ Student ID: _______________

Problem 3

GREEN EQU $

YELLOW EQU $

RED EQU $

ldab PORTB GREENS: cmpb #GREEN bne YELLOWS inc count asl PORTB bra FINISH YELLOWS: cmpb #YELLOW bne REDS inc count asl PORTB bra FINISH REDS: cmpb #RED bne default inc count asl PORTB bra FINISH ELSE: movb #GREEN, PORTB FINISH:

Write a segment of C code that is equivalent?

If this code was run and PORTB initially contained the value #$08, what

registers/memory locations would change and to what value(s)?