-
-
Save gtkatakura/b6d8d13ee7f248e03a3124c340d2b106 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