4.47
A.
Change into pointer version
!INCLUDE './code/bubble-sort/bubble-sort-pointer.c'
B.
Compile bubble-sort-pointer.c
gcc -S -Og bubble-sort-pointer.c
get gas file
!INCLUDE './code/bubble-sort/bubble-sort-pointer.s'
Change it into ys version
!INCLUDE './code/bubble-sort/bubble-sort-pointer.ys'
main difference is second param of function is long* end
instead oflong count
for convinient, long* end
marks the position of last element.
using yas
assemble it and yis
run it, see output
../sim/misc/yas bubble-sort-pointer.ys
../sim/misc/yis bubble-sort-pointer.yo
Stopped in 117 steps at PC = 0x13. Status 'HLT', CC Z=1 S=0 O=0
Changes to registers:
%rax: 0x0000000000000000 0x0000000000000020
%rsp: 0x0000000000000000 0x0000000000000200
%rsi: 0x0000000000000000 0x0000000000000018
%rdi: 0x0000000000000000 0x0000000000000018
%r9: 0x0000000000000000 0x0000000000000001
%r10: 0x0000000000000000 0x0000000000000002
Changes to memory:
0x0018: 0x0000000000000004 0x0000000000000001
0x0020: 0x0000000000000003 0x0000000000000002
0x0028: 0x0000000000000002 0x0000000000000003
0x0030: 0x0000000000000001 0x0000000000000004
0x01f0: 0x0000000000000000 0x0000000000000055
0x01f8: 0x0000000000000000 0x0000000000000013
initial array order is 4,3,2,1, now 1,2,3,4
当前内容版权归 DreamAndDead 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 DreamAndDead .