News:

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

Difference between 80x86 and IA-32

Started by Vahagn, August 23, 2005, 10:28:46 AM

Previous topic - Next topic

Vahagn

Hello,-
I am starting to learn assemby and hope someone can answer the following question:

I have purchased the following book By Richard Detmer about 80x86 programming:
http://www.amazon.com/exec/obidos/tg/detail/-/0763717738/qid=1124792784/sr=8-1/ref=pd_bbs_1/002-2532172-2704029?v=glance&s=books&n=507846

Now, however, I also am keen on learning the IA-32 version. Can I use the same tools as I use for the 80x86 (there is a CD included with the book, with a debugger etc) as for IA-32? If not, what is the best way / environment / tools to learn IA-32 ?  :eek

Thanks beforhand,
Vahagn

hutch--

Vahagn,

Welcome on board. I hate to be a killjoy but if the book and the associated CD are about 16 bit DOS assembler, it is useless to you in 32 bit Windows or LINUX code. If its Windows in 32 bit you are interested in, there are a number of directions you can go in, you can start with Randy Hyde's HLA which is geared for assembler beginners, if you have enough mileage in Windows, MASM is very powerful and has the biggest support and code base but it is not for the faint of heart.

Let us know wha you have experience with and we may be able to help you some more.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

MichaelW

As far as I know the book covers mostly 32-bit Windows programming with only a relatively small amount of 16-bit DOS. What I believe to be the contents of the CD that accompanies the book are available here (legally, I assume):

http://www.cs.nmt.edu/~cs221/jbpub/Detmer/
eschew obfuscation

PBrennick

I think I would be VERY careful here.  I suspect it is posted only for the use of students at New Mexico Tech.

Paul
The GeneSys Project is available from:
The Repository or My crappy website

Vahagn

Hutch,-
thank you, I will try to explain what I go after:

Essentially, I want to master assembly language using state-of-the-art assembly. I guess that implies I have to use 32-bit Windows and Linux. At the school where I study they take an approach of having a simple source code in C, then they either disassemble it using the "gcc -S my_c_file.c" command, or build their own assembly code with the C code as reference and then assemble, link and execute it. I am doing that as well when I practice. The book by Detmer I purchased because I wanted to have some fundamental reference book on assembly. As it is about 80x86 assembly, I thought it fitted the purpose (was generic or fundamental enough). However, as I want to learn assembly using the state-of-the-art as opposed to just learning assembly, I posted this question. The abovementioned book states that one can enter the .386 directive followed by the directive: .MODEL FLAT, which will allow for an extended instruction set and generating 32-bit code using a flat memoru model. But is this the same as programming in IA-32? Here the first example from the book (as someone who has paid it, I judge it is OK to bring a sample here):

##################################################################

; Example assembly language program -- adds two numbers
; Author:  R. Detmer
; Date:    revised 7/97

.386
.MODEL FLAT

ExitProcess PROTO NEAR32 stdcall, dwExitCode:DWORD

INCLUDE io.h            ; header file for input/output

cr      EQU     0dh     ; carriage return character
Lf      EQU     0ah     ; line feed

.STACK  4096            ; reserve 4096-byte stack

.DATA                   ; reserve storage for data   
number1 DWORD   ?
number2 DWORD   ?
prompt1 BYTE    "Enter first number:  ", 0
prompt2 BYTE    "Enter second number:  ", 0
string  BYTE    40 DUP (?)
label1  BYTE    cr, Lf, "The sum is "
sum     BYTE    11 DUP (?)
        BYTE    cr, Lf, 0

.CODE                           ; start of main program code
_start:
        output  prompt1         ; prompt for first number
        input   string, 40      ; read ASCII characters
        atod    string          ; convert to integer
        mov     number1, eax    ; store in memory

        output  prompt2         ; repeat for second number
        input   string, 40
        atod    string
        mov     number2, eax
       
        mov     eax, number1    ; first number to EAX
        add     eax, number2    ; add second number
        dtoa    sum, eax        ; convert to ASCII characters
        output  label1          ; output label and sum

        INVOKE  ExitProcess, 0  ; exit with return code 0

PUBLIC _start                   ; make entry point public

END                             ; end of source code

#################################################################


Thanks,
Vahagn

hutch--

Vahagn ,

The code looks pretty close to current 32 bit code. Remove the stack directive as the stack is set in 32 bit PE files as a pair of  linker options. I would be interested in which version of MLEXE you are using as some of the earliest ones that supported 32 bit code differ from current versions.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

zooba

I was under the impression that IA-32 is Intels name for their 32-bit architecture. x86 is just the first (most popular?) implementation.

Certainly all (that I've read) of their references refer to IA-32 when talking about the assembly language

Vahagn

Hutch,-

when I go into the properties for the ML.EXE that resides in the folder with the examples etc from the book, I don't find much information except that it is
379 KB (388.608 bytes). Exactly what information are you interested in with respect to the ML.EXE? Can I fetch a new version of ML.EXE somewhere?

Hutch, zooba: Looks like the book wasn't a waste of money anyway! I am looking forward to trying your MASM32 tools, Hutch, which I already have downloaded.

Regards,
Vahagn


hutch--

Vahagn,

To test te version, just run ML /? and it will tell you which version it is. The current version in the MASM32 project is 6.14 which has been super reliable over some years and about the only problem is that it does not support the later SSE2 opcodes. If you upgrade your version of VC6 you can get ML 6.15 in the processor pack, 7.00 is a late DDK or 7.10 from the more current VC versions.

Just be careful which linker you use with MASM modules. The one in MASM32 had the correct default alignment of 512 byte sections where if you use a later one without setting the alignment you default to 16k alignment which blows you cde size out for no purpose.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Mark Jones

Hutch, for 7.00.92 would that be?


link.exe /align:512


Because it complains with "LINK : warning LNK4108: /ALIGN specified without /DRIVER or /VXD; image may not run." It seems to work ok anyways. Only shaved off 1k from a 1MB executable though.

EDIT: using /align:16 shaved off another 2k. :U But what kind of compatibility issues might this incur?
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

hutch--

Mark,

You will get into trouble if you use smaler than 512 bytes on some Windows versions. The main trick is to not default to 16k as it makes a mess of your small stuff.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Vahagn

Hello Hutch,-

here is the (partial) output of ML /?:

Microsoft (R) Macro Assembler Version 6.11
Copyright (C) Microsoft Corp 1981-1993.  All rights reserved.


QuoteIf you upgrade your version of VC6 you can get ML 6.15 in the processor pack, 7.00 is a late DDK or 7.10 from the more current VC versions.

Just be careful which linker you use with MASM modules. The one in MASM32 had the correct default alignment of 512 byte sections where if you use a later one without setting the alignment you default to 16k alignment which blows you cde size out for no purpose.

Thanks for the tips; I'll get back after I've experimented with it a little.