Help an Assembler Noob, it's good karma

c0d1f1ed
Total Points:
860
Status Points:
360
Brown Belt
July 7, 2009 7:01 PM PDT
Rate
 
#1
Quoting - tyrch
1) MOV DEST,SOURCE .. got it. It's an intel syntax standard. However with the direction bit, this can change the position of source and dest thereby creating a whole new value for the same code. eg. 89C3h and 8BD8h produce the same instruction of MOV BX,AX. Is one more correct than the other, or is it like ansi C where there are a million ways to produce the same results?

2) (MOV) Immediate to Register/Memory vs. Immediate to Register. These to opcodes look like they do the same function in regards to move to register. Is one prefered to another? Are there advantages to using one vs. the other? The book is very vague and the teacher still has yet to answer me.


1) You probably meant 89h C3h and 8Bh D8h? Writing them as one value means the first byte ends up in the higher memory location, for a 'little endian' architecture like Intel: http://en.wikipedia.org/wiki/Endianness. Anyway, yes, there are sometimes multiple ways to create the same operation. One is not better than the other. But note that x86 can only have one memory operand, and whether it's the first or the second operand depends on the encoding. When both operands are registers, you can choose.

2) The encoding for moving an imm to a reg is shorter than imm to mem/reg. So in general you want to use that one to save on code size.

Intel Software Network Forums Statistics

8470 users have contributed to 31601 threads and 100646 posts to date.
In the past 24 hours, we have 30 new thread(s) 113 new posts(s), and 159 new user(s).

In the past 3 days, the most popular thread for everyone has been gemm(A,A,A) like possible? The most posts were made to gemm(A,A,A) like possible? The post with the most views is Dear Steve, excuse me for a d

Please welcome our newest member kopernikus