NameID
Mo’men Ahmed2200768
John Sameh2200414

1. Compiling the code

2. Using simulation instead of physical board

3. Running the program till start of main using a breakpoint

RegisterValue
R13 (SP)0x20000660
R14 (LR)0x08000233
R15 (PC)0x08000314

4. Start of program in disassembly

Instruction: 0x08000314 B580 PUSH {r7,lr}. Interpretation: The same as the program counter (PC).

5. Instruction execution

center Registers changed: R13 (SP), R15 (PC). Relation with instruction:

  • SP was reduced by 2 to (from 0x20000660 to 0x20000658) because two register values were pushed to the stack.
  • The PC was increased by 2 because the difference between each two instructions is two.

6. Finding first 4-byte long instructions

center

7. Finding values of some registers before executing my_strcpy

RegisterValue
R13 (SP)0x20000628
R14 (LR)0x08000233
R15 (PC)0x08000344

8. Executing my_strcpy function

RegisterValue
R13 (SP)0x20000628
R14 (LR)0x08000349
R15 (PC)0x08000374
The LR was changed to point to the new location to be returned to. The PC was changed to the new instruction address matching the disassembly window.

9. Registers holding my_strcpy arguments

ArgumentRegisterValue
src_ptrR0 0x20000644”Hello, world!”
dst_ptrR1 0x08000630""

10. Viewing values of arguments in memory using Memory Windows

11 and 12. Content

ArgumentContent
src_ptrHello, world!
dst_ptr.

13.

RegisterFunction
R0Points to the character to be copied
R2Holds the character copied
R1Character is pasted here

14. Values before stepping out of the function

RegisterValue
R13 (SP)0x20000620
R14 (LR)0x08000349
R15 (PC)0x08000386

15. PC after stepping out of the function

R15 (PC): 0x08000348

16. Relationship between previous LR and PC

They are equal. The program returned to the point in main before entering the function.

center

17. Verifying my_capitalize