家庭作业
4.47
-
1
2
3
4
5
6
7
8
9
10
11
12/* Bubble sort: Pointer version */
void bubble_p(long *data, long count) {
long *ptr, i, last;
for (last = count - 1; last > 0; last--) {
for (ptr = data, i = 0; i < last; i++, ptr++)
if (*(ptr + 1) < *ptr) {
long t = *(ptr + 1);
*(ptr + 1) = *ptr;
*ptr = t;
}
}
} -
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32bubble_p:
rrmovq %rsi, %r8
irmovq $1, %r9
subq %r9, %r8
jmp test1
loop1:
rrmovq %rdi, %rax
irmovq $0, %rdx
jmp test2
loop2:
mrmovq 8(%rax), %rcx
mrmovq (%rax), %rsi
rrmovq %rcx, %r9
subq %rsi, %r9
jge false
rmmovq %rsi, 8(%rax)
rmmovq %rcx, (%rax)
false:
irmovq $1, %r9
addq %r9, %rdx
irmovq $8, %r9
addq %r9, %rax
test2:
rrmovq %rdx, %r9
subq %r8, %r9
jl loop2
irmovq $1, %r9
subq %r9, %r8
test1:
andq %r8, %r8
jg loop1
ret
4.49
1 | mrmovq 8(%rax), %rcx |
4.50
1 | switchv: |
4.53
https://git.gzezfisher.top/FISHER_/CSAPP-sol/src/branch/main/arch/sim/pipe/pipe-nobypass.hcl
4.55
https://git.gzezfisher.top/FISHER_/CSAPP-sol/src/branch/main/arch/sim/pipe/pipe-nt.hcl
4.56
https://git.gzezfisher.top/FISHER_/CSAPP-sol/src/branch/main/arch/sim/pipe/pipe-btfnt.hcl
4.57
-
1
2
3E_icode in { IMRMOVQ, IPOPQ } &&
E_dstM in { d_srcA, d_srcB } &&
!(D_icode in { IRMMOVQ, IPUSHQ } && E_dstM == d_srcA) - https://git.gzezfisher.top/FISHER_/CSAPP-sol/src/branch/main/arch/sim/pipe/pipe-lf.hcl
4.58
https://git.gzezfisher.top/FISHER_/CSAPP-sol/src/branch/main/arch/sim/pipe/pipe-1w.hcl
archlab
https://git.gzezfisher.top/FISHER_/CSAPP-sol/src/branch/main/arch