2. Before starting this part of the lab, please do all calculations below manually.

Create a new project: Lab5b. Copy the appropriate files over from the provided

zip file. Starting with provided calculate.s, modify it to add or subtract the

numbers that are stored in the memory and store the sum in memory (i.e. your

program should read numbers from the memory, apply mathematical operation to

the numbers accordingly and save the result in the memory). Put the operand

values given into the .rodata section of your program. Execute the programs and

record the sum or subtraction and the 'C' (carry) and 'Z' (zero) bits of the

condition code register. Use the following data:

a. Addition of two single-byte numbers:

0xC3 + 0x8D

Helpful steps:

1) Use LDRB to read a byte of data from memory into a register.

How does an instruction refer to memory location? How do you

initialize memory? Hint: Look at Lab5a, above.

2) Use ADD to add numbers in registers.

ab 5 Rev. 3


Advanced Assembly, Branching, and Monitor Utilities

3) Use STRH or STR in order to save the result from a register to

memory-why shouldn't you use STRB in this case?



0x2E68B3F4 +0x5C2A

b. Subtraction of two single-byte numbers:

c. Three-byte subtraction:

d. Multi-byte addition:

Fig: 1