flat assembler
Message board for the users of flat assembler.

Index > Main > [beginner] Very basic questions about assembly!

Author
Thread Post new topic Reply to topic
arao6



Joined: 10 Jan 2013
Posts: 4
arao6
.

Hello!

You have no idea how long it took me to sign up. First I thought it was a captcha, then I realized it was a conversion, but I had H and G in my captcha...

Anyway, I just started learning asm and hex numbering. I can add hex and stuff using a calculator lol... I'm having trouble understanding the last sentence in this paragraph:

Quote:
Some x86 instructions require more than one byte. For example, the instruction mov ax, [1000] loads the ax register from memory location 1000. The encoding for the opcode is 11000110 or 0C6h. However, the encoding for mov ax,[2000]’s opcode is also 0C6h. Clearly these two instructions do different things, one loads the ax register from memory location 1000h while the other loads the ax register from memory location 2000. To encode an address for the [xxxx] or [xxxx+bx] addressing modes, or to encode the constant for the immediate addressing mode, you must follow the opcode with the 16-bit address or constant, with the L.O. byte immediately following the opcode in memory and the H.O. byte after that. So the three byte encoding for mov ax, [1000] would be 0C6h, 00h, 10h and the three byte encoding for mov ax, [2000] would be 0C6h, 00h, 20h


I understood everything except the last sentence. Since when is 10h equal to 1000h and 20h equal to 2000h?

Edit: it was 12 AM when I read that. I completely misread the part about the low order byte coming first.
Post 10 Jan 2013, 06:05
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Take a look at this. x86 is little-endian.
Post 10 Jan 2013, 06:16
View user's profile Send private message Reply with quote
arao6



Joined: 10 Jan 2013
Posts: 4
arao6
LocoDelAssembly wrote:
Take a look at this. x86 is little-endian.


Sweet, that's a very helpful link. Thank you! Now it makes complete sense and I can continue my study Smile
Post 10 Jan 2013, 06:29
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1419
Location: Toronto, Canada
AsmGuru62
The phrase "Some x86 instructions require more than one byte" is not very well to use in this context.
It suggests, that opcode is always 1 byte and whatever comes next is an address or some other info.
However, full x86 instruction is much more than that:

1. Prefix(-es) may come BEFORE the instruction opcode
2. Opcode may be 1-3 bytes
3. MOD/R/M information
4. Offsets (like 1000h or 2000h) and immediate values
Post 10 Jan 2013, 16:01
View user's profile Send private message Send e-mail Reply with quote
arao6



Joined: 10 Jan 2013
Posts: 4
arao6
Ah I see. That explains some irregularities that I noticed in IDA.

Question: what is movss? I have not been able to find much information about that instruction.
Post 13 Jan 2013, 00:46
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1419
Location: Toronto, Canada
AsmGuru62
According to this:
http://www.intel.com/content/www/us/en/processors/architectures-software-developer-manuals.html

The link you need on that page is called:

"... Volume 2B - Instruction Set Reference M-Z"

MOVSS moves floating point values between XMM registers and memory.
Post 13 Jan 2013, 01:32
View user's profile Send private message Send e-mail Reply with quote
arao6



Joined: 10 Jan 2013
Posts: 4
arao6
AsmGuru62 wrote:
According to this:
http://www.intel.com/content/www/us/en/processors/architectures-software-developer-manuals.html

The link you need on that page is called:

"... Volume 2B - Instruction Set Reference M-Z"

MOVSS moves floating point values between XMM registers and memory.


Awesome, thanks. Smile
Post 16 Jan 2013, 05:24
View user's profile Send private message Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1901
DOS386
arao6 wrote:
Question: what is movss? I have not been able to find much information about that instruction.


I'd suggest to begin with 8086 or 80386 assembly, and avoiding obscure (AAA, ABC, DAS, LES, BOUNCE, ...), system (ARPL, IRET, LIDCT, ...), and FPU (FILD, FIST, FLDCW, ...) instructions for now.

> [beginner] Very basic questions about assembly!

Understanding all instructions is not a good goal for now Smile

http://home.myfairpoint.net/fbkotler/nasmdocc.html

Quote:
A.4.180 MOVSS: Move Scalar Single-Precision FP Value

MOVSS xmm1,xmm2/m32 ; F3 0F 10 /r [KATMAI,SSE]
MOVSS xmm1/m32,xmm2 ; F3 0F 11 /r [KATMAI,SSE]

MOVSS moves a single-precision FP value from the source operand to the destination operand. When the source or destination is a register, the low-order FP value is read or written.

_________________
Bug Nr.: 12345

Title: Hello World program compiles to 100 KB !!!

Status: Closed: NOT a Bug
Post 03 Feb 2013, 17:58
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.