Talk:X86 Assembly/Data Transfer

First Example is Confusing Me
Can someone explain the first example in more detail. A few of the lines really confuse me:

1) following _start, in the second mov instruction... I understand that value == 6 because eax was set to 6 previously, but I don't see how in the fifth mov instruction that ebx can equal 2, since value was set to 6 in the second line. 2) And could someone explain what is going on here in the last instruction of _start: movw  value(, %ebx, 1), %bx Am I missing something from the previous sections in this book?


 * Regarding your first question, I'm guessing that the author forgot he'd reset **value** to 6, after initially setting it to 2 in the data section. That's my best guess, anyway.


 * For number 2, I haven't a bloody clue. 74.131.20.28 (talk) 02:48, 17 June 2008 (UTC)

Last example
In the last example, it says "due to endianess, the resulting mystr2 would be aAbBcC\0a". This seems wrong because the endianess should be the same during read AND write. Just to confirm, I tried to compile this with nasm : section .code global _start _start: ; copy mystr into mystr2 mov esi, mystr mov edi, mystr2 cld mov ecx, 4 rep movsw mov edx,8 mov ecx,mystr2 mov ebx,1 mov eax,4 int 0x80 mov ebx, 0 mov eax, 1 int 0x80 section .bss mystr2: resb 8 section .data mystr db "AaBbCca", 0x0 And in fact, it prints AaBbCca. Am I right or is it because of my architecture (amd64) or something like that ?

Description of movs/movsx
Is the description of instructions movs/movsx correct?

In any case the sentence should be fixed (but I don't know what it should be).

--Mortense (talk) 19:50, 26 May 2010 (UTC)

Can movz extend in-place?
Is it possible to zero extend, say, `AX` to `EAX` by doing `movz %ax, %eax` (in AT&T syntax)? Qwertyus (discuss • contribs) 15:12, 23 October 2013 (UTC)
 * Yes, but the  instruction is more appropriate. Kai Burghardt (discuss • contribs) 21:44, 30 January 2021 (UTC)

missing add esp,12/8
I believe the cmpxchg example is (technically speaking) missing add esp 12/8 after the call pthread_create/pthread_join calls, not that leaving crud on the stack would make it crash.