Arch Lab
Arch Lab
Part A
Exp 1
When running rsum_list (rsum.ys), I accidentally set the pos of stack to 200 (normally 0x200). Then when pushing the callee-saved registers and the PCs to record call functions, the stack grows to 0x88, where is the code of addq %rbx, %rax. So it changes the code itself just like what we do in attack lab. However this change halt the program normally.
1 | Stopped in 29 steps at PC = 0x8c. Status 'HLT', CC Z=1 S=0 O=0 |
Exp 2
When last line is not newline, we get an error:
1 | Error on line 49: Missing end-of-line on final line |
Exp 3
When mistype ret in the beginning of execution:
1 | .pos 0x0 |
We will get:
1 | root@52f6d287284f:/work/_labs/04 arch lab/archlab-handout/sim/misc# ./yis copy.yo 44 |
Noticed that when returned from the first part, our program will restart.
Part B
Need to investigate the implementation of codes
Part C
Due to %rax was initialized to 0, and we can rearrange the instructions to avoid load/use hazard. And iaddq $-1, %rdx will set the CC automatically.
1 | # You can modify this portion |
We got:
1 | Average CPE 10.47 |
Then we tried to separate the loop into 8 branches:
1 | # You can modify this portion |
We got:
1 | Average CPE 7.79 |
Noticed that when we use same tags, the status of PC is unpredictable.
Then deal with bubbles:
1 | # You can modify this portion |
Then:
1 | ncopy |
We should decrease the program length. Noticed that there are multiple useless mrmovq #(%rdi), %r##. We change it to:
1 | # You can modify this portion |
We got:
1 | Average CPE 7.67 |
Change order:
1 | # You can modify this portion |
We got:
1 | Average CPE 7.60 |
Change order and Jump to halt directly.
1 | # You can modify this portion |
We got:
1 | Average CPE 7.36 |
If just changing order, we can got only:
1 | Average CPE 7.57 |
- Title: Arch Lab
- Author: Azusagawa Sakuta
- Created at : 2026-05-14 11:15:00
- Updated at : 2026-05-14 16:28:57
- Link: https://azusagawa-sakuta.github.io/project/codes/Courses/CSAPP/ArchLab/
- License: This work is licensed under CC BY-NC-SA 4.0.