Last active
September 20, 2020 03:53
-
-
Save EduardoRFS/dfe620449a7e97dccacee20750163127 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
your obj pointer came in the first position of the stack | |
so you will load it on a register | |
*/ | |
movl (%esp), %eax ; | |
/* | |
then you want to do obj.a += 6, if we suppose | |
that we're talking about records not dictionaries | |
and we know that obj.a is on position 4 | |
on x86 you can do | |
*/ | |
addl $6, 4(%eax) ; | |
/* | |
internally this is what is happening, but atomically | |
so the cost of indirection is the same as if it was passed by value | |
because the only reference to the object is the first mov | |
*/ | |
movl 4(%eax), %ebx ; /* load */ | |
addl $6, %ebx ; /* op */ | |
movl %ebx, 4(%eax) /* store */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment