diff options
| author | Mike Vink <ivi@vinkies.net> | 2025-02-16 18:21:50 +0100 |
|---|---|---|
| committer | Mike Vink <ivi@vinkies.net> | 2025-02-16 18:21:50 +0100 |
| commit | b9bf3afbb52aebcc0f93df55b55ec0f0f521b1ab (patch) | |
| tree | 76899e2e38c2a9ca7e40db160a9c86ee0ad4e0dc /4/practice_problem_4_7_and_8_ambiguities.c | |
| parent | 7ae6aa6a64f3f697edb90bb573862bf31dd14e69 (diff) | |
Diffstat (limited to '4/practice_problem_4_7_and_8_ambiguities.c')
| -rw-r--r-- | 4/practice_problem_4_7_and_8_ambiguities.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/4/practice_problem_4_7_and_8_ambiguities.c b/4/practice_problem_4_7_and_8_ambiguities.c new file mode 100644 index 0000000..043a692 --- /dev/null +++ b/4/practice_problem_4_7_and_8_ambiguities.c @@ -0,0 +1,26 @@ +/* +pushtest: + movq %rsp, %rax Copy stack pointer + pushq %rsp Push stack pointer, original or after incrementing + popq %rdx Pop the value back + subq %rdx, %rax Always 0 on this machine + +It must first push the original rsp decremented address and then decrement rsp itself, otherwise a difference is expected after pushing and popping. +*/ + +/* +poptest: + movq %rsp, %rdi Save the original sp + pushq $0xabcd Push test value + popq %rsp Pop test value to rsp + movq %rsp, %rax Set popped value as return value + movq %rdi, %rsp + ret + +Rsp gets set the value in memory at rsp. + +From solutions: +mrmovq (%rsp), %rsp + +I guess it just reads the stack value and overwrites it into rsp +*/ |
