ECE383 Exam Questions: Assembly Language, Arithmetic Overflow, Stack Frames, and PIC24 I/O, Exams of Microcomputers

Sample questions for exam #2 in ece383, focusing on assembly language programming, arithmetic overflow, stack frames, and pic24 i/o. Topics include writing pic24 assembly language equivalents for c code fragments, detecting arithmetic overflow, implementing a branch instruction, and understanding the purpose of a stack frame. The document also covers the differences between latx and portx, weak internal pullup and open drain output capabilities, and configuring i/o pins using inline macros.

Typology: Exams

2011/2012

Uploaded on 03/02/2012

cristelle
cristelle 🇺🇸

4.5

(53)

374 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
ECE383 Sample questions for Exam #2 The exam will be open book/notes.
The exam will focus on material from lecture 5 through lecture 8, slide 25. Knowledge from earlier lectures (1-4) may be
required, but will not be the focus of the exam questions.
1. Write PIC24 assembly language equivalents for the following C code fragments.
uint32 i, j, k;
int32 x, y, z;
i=j+k;
x=y-z;
int32 r, s;
int16 t;
if(test<10) test++;
s=(int32) t;
2. Give an example of arithmetic overflow when adding two unsigned 8-bit numbers.
3. Give an example of arithmetic overflow when adding two signed 8-bit numbers.
4. How is overflow detected in hardware?
5. Given the following PIC24 assembly language code, give the machine code for the branch instruction.
Location Machine Code Label Instruction
0200
loop_top
<an instruction>
0202
<an instruction>
0204
<an instruction>
0206
bra geu,loop_top
6. Assume the following C code is executed.
int16 i, j, k;
int16* p_i,
i=0x4000;
j=0xFFFF;
p_i=&i;
k=*p_i;
Give the values of the following memory locations after all the instructions have executed. Complete all cells in the
table.
Location Variable Contents
0x800 i
j
k
p_i
Give the assembly language implementation of the above C code. You must use register indirect addressing to
implement *p_i.
7. What is the purpose of a stack frame?
pf3

Partial preview of the text

Download ECE383 Exam Questions: Assembly Language, Arithmetic Overflow, Stack Frames, and PIC24 I/O and more Exams Microcomputers in PDF only on Docsity!

ECE383 Sample questions for Exam #2 The exam will be open book/notes.

The exam will focus on material from lecture 5 through lecture 8, slide 25. Knowledge from earlier lectures (1-4) may be required, but will not be the focus of the exam questions.

  1. Write PIC24 assembly language equivalents for the following C code fragments.

uint32 i, j, k; int32 x, y, z;

i=j+k; x=y-z;

int32 r, s; int16 t;

if(test<10) test++; s=(int32) t;

  1. Give an example of arithmetic overflow when adding two unsigned 8-bit numbers.
  2. Give an example of arithmetic overflow when adding two signed 8-bit numbers.
  3. How is overflow detected in hardware?
  4. Given the following PIC24 assembly language code, give the machine code for the branch instruction.

Location Machine Code Label Instruction

0200 loop_top

0202

0204

0206 bra geu,loop_top

  1. Assume the following C code is executed.

int16 i, j, k; int16* p_i, i=0x4000; j=0xFFFF; p_i=&i; k=*p_i;

Give the values of the following memory locations after all the instructions have executed. Complete all cells in the table.

Location Variable Contents

0x800 i

j

k

p_i

Give the assembly language implementation of the above C code. You must use register indirect addressing to implement *p_i.

  1. What is the purpose of a stack frame?
  1. A C main() program calls the subroutine my_sub() as shown below. Implement the subroutine in PIC24 assembly language using the rules for subroutine parameter passing given in lecture slide 6-26. You must use a stack frame for the local variables in the subroutine.

main() { int8 i, j;

i=5; j=mysub(i);

}

int8 my_sub(int8 x) { int8 y; int8 z=0;

for(y=0;y<x;y++) z++;

return z; }

  1. What are the differences, and similarities, between LATx and PORTx?
  2. What is the purpose of weak internal pullup and open drain output capabilities on the PIC24 processor?
  3. What is the purpose of the MCLR# pin on the PIC24 processor?
  4. Assume the following circuit is used in a PIC24 system.

a) Write an inline macro named CONFIG_SW1() that, when used, would correctly configure RB12 as a digital input as shown. b) Write an inline macro named CONFIG_LED1() that, when used, would correctly configure RB13 as a digital output as shown.