News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

The x86 Instruction Set is Vast....

Started by Ned, December 13, 2008, 05:25:35 AM

Previous topic - Next topic

Ned

Hi. My background is C. I've always liked the brevity. But I feel I am limited in properly utilizing it without a more thorough grounding in the layer below it. I have circled assembly for a while but haven't taken the plunge until lately. I have a few very basic questions just for my own peace of mind that I can't seem to get answered via googling.

1. The total intel x86 instruction set is freakin' huge. I look at the A-M and N-Z listings ( http://www.intel.com/products/processor/manuals/index.htm ) and it's overwhelming. Is there a much reduced base that gets you 95% of what you need for typical stuff? If so, is there a resource that will lay it out somewhat in those terms? I understand the CISC approach and I know Intel supports all the legacy stuff and I know that the SSE commands, etc. aren't core to basic assembler, but if I can treat it like C with a focus on a few language structures with everything remaining being more akin to occasionally used library stuff maybe it won't seem so imposing.

2. Does MS MASM (9.0) or MASM32 support that full instruction set of commands (in the link above)? I assume not, but I want to ask anyway.

3. For the stuff that is implemented, to what extent do those Intel documents apply to MASM 9/MASM32 with respect to syntax? Any major departures or dead on?

I'm sure these questions show my lack of knowledge but sometimes I just want to wrap up certain questions before I take the plunge.

Thanks!

jdoe



1)  Interesting statistics:  http://smallcode.weblogs.us/2006/04/22/x86-machine-code-statistics/

2)  MASM 9.0 is the most up to date (MASM32 = MASM 6.14)



FORTRANS

QuoteInteresting statistics:

6% call and 1% ret?  Really?

Steve

Edit.

Not much code reuse  apparently.
SRN

Tedd

You're right, there are far more instructions than you'll need to use - most of them can be ignored (for now, at least.)
There's the core instructions that you can't live without, then a few extra ones that come in useful sometimes, and the 'extensions' such as fpu, mmx, sse, ..., and the rest you can largely forget.

So, the core instructions you should learn are (I'm sure others can argue):
MOV
INC, DEC
ADD, SUB
CMP, Jcc, JMP
PUSH, POP
CALL, RET
MUL, DIV
NOT, AND, OR, XOR


And any other instructions will become known to you as they become useful :wink


Yes, MASM supports the whole 32-bit instruction set (except newer SSE instructions.)
Syntax with respect to the instructions themselves is almost identical.
No snowflake in an avalanche feels responsible.

Tedd

Quote from: FORTRANS on December 13, 2008, 12:40:27 PM
6% call and 1% ret?  Really?

Not much code reuse  apparently.

Think about how those statistics were collected - it's entirely down to code-reuse.
One function (usually) only contains one RET, but the function itself can be CALLed many times from different places. So that's 6 calls per function, on average.
No snowflake in an avalanche feels responsible.

Ned

Quote from: Tedd on December 13, 2008, 01:16:18 PM
You're right, there are far more instructions than you'll need to use - most of them can be ignored (for now, at least.)
There's the core instructions that you can't live without, then a few extra ones that come in useful sometimes, and the 'extensions' such as fpu, mmx, sse, ..., and the rest you can largely forget.

So, the core instructions you should learn are (I'm sure others can argue):
MOV
INC, DEC
ADD, SUB
CMP, Jcc, JMP
PUSH, POP
CALL, RET
MUL, DIV
NOT, AND, OR, XOR


And any other instructions will become known to you as they become useful :wink


Yes, MASM supports the whole 32-bit instruction set (except newer SSE instructions.)
Syntax with respect to the instructions themselves is almost identical.


Thanks for responding, that's very helpful.

I would assume that the main difference with MASM 9 then is 64 bit support and all of the latest SSE and other instructions along with the newest processor family specific stuff?

Also, the intel documentation then is actually very useful, yes? To what extent do FASM and NASM stay up-to-date with the latest Intel additions? I figure MS has to for tthe most part.

BlackVortex

It's not too hard to implement new instruction sets to an assembler. I'm sure FASM and NASM are up-to-date with 64bit, at least SSE3 etc.