You are on page 1of 7

Lab #5 Pointers, Subroutines

Jamari Johnson (jrj309@msstate.edu) ECE 3724, Section 01


TA: Jeff Hsu

Abstract
Pointers are variables that point to a specific address that contains
data. Subroutines (or functions in C) are used to call and return different
processes that are executed outside of the main() function. C code was
given which was to then be translated into Assembly code that uses
pointers and subroutines.

Theory

A pointer is an addition to a variable (p[variable_name] or de-referenced


with *p[variable_name]) that creates an additional address to another
address which basically points to that initial address and its respective
data contents. In Assembly language, indirect addressing is used to
handle the use of pointers. Subroutines are basically functions in
Assembly language that are especially useful due to the fact that a
subroutines parameters can be passed as pointers for arrays.

An example is shown here of how addresses are given to pointers


and how they are used in assembly language.

Procedures and Experimental Data:


Task 1:

C Program was successfully converted to Assembly and gave the results


below:

Task 2:
In C program upcase_cversion.c, the initial areas for sz_1 and sz_2 were
in the 1000 to 1010 block of memory.

Conclusions:
Task 1 and 2 were completed. In Task 1 one finds that the final output
is not in the variable itself, but in the program memory. In Task 2 one
also finds that the initial locations for sz_1 and sz_2 were in the 10001010 block, and also used by register W14 and W15.
Reference:
1. Reese, Bruce, Bryan Jones, Microcontrollers: From Assembly to C
with the PIC24 Family, 2008

Appendix A: Post-Lab Answers


1. Based on your student ID, what microcontroller did
you examine? (This enables the TAs, who dont know
your student ID, to grade your report.)
A: I used the Atmel AT89C5115
2. What is the width of the instruction word?
A: 16 or 32 bits
3. What is the width of the internal data registers?
A: 8-bits
4. What is the width of the program counter or instruction pointer?
A: 16-bits

5. How much on-chip RAM does the processor have? (RAM =


Random Access Memory, memory that the processor can modify,
equivalent to the register file on the PIC24).
A: The processor has 256 Bytes
6. Can the uC access external memory (memory that does not reside
on the same chip)? If yes, what is the maximum amount?
A: No
7. Does the uC have special instructions for signed comparisons? If
yes, give an example.
A: No
8. Does the uC have any special instructions for multiply/divide? If
yes, give an example.
A: No
9. Does the uC have a fixed sized stack? If yes, what is the size?
A: No
10.
Can the uC write to the stack under program control? If
yes, give an example on an instruction that does this.
A: Yes, you can use push or pop to control the stack
PUSH/POP DPL
PUSH/POP DPH
11.
How many clock cycles does it take for an add operation to
execute?
A: 2 clock cycles
12.
How does the uC accomplish indirect addressing? Give an
example.

A: The uC uses a @ symbol to use indirect addressing. Example:


A, @R1
13.
Give the machine code format for an add of two register
values (you pick the registers).

(as shown by the data sheet)


14.
What flags are affected in the status register of the uC by the
add instruction? Give the definition of each flag.
A: C(carry), OV(signed overflow), and AC(add carry)
15.
For the shift/rotate instructions, can multiple positions be
shifted via one instruction? If yes, how many clocks does it take
for a multiple position shift?
A: No

You might also like