My problem is: MASM does not work correctly:

Dos command: ml /Zi shell.asm
Contents of "Shell.asm" :

.xlist
include stdlib.a
includelib stdlib.lib
.list
.386
option segment:use16
dseg segment para public 'data'
dseg ends
cseg segment para public 'code'
assume cs:cseg, ds:dseg
Main proc
mov ax, dseg
mov ds, ax
mov es, ax
meminit
Quit: ExitPgm
Main endp
cseg ends
sseg segment para stack 'stack'
stk byte 1024 dup
sseg ends
zzzzzzseg segment para public 'zzzzzz'
LastBytes byte 16 dup (?)
zzzzzzseg ends
end Main

I assure that this code works, bacause I have all .lib and .inc files associeted.
Eventually I get this in DOS window:

/z2
"x86.obj" /CO:nopack
"x86.exe"
NUL
LINK : warning LNK4044: unrecognized option "z2": ignored
LINK : warning LNK4044: unrecognized option "CO:nopack": ignored
LINK : error : Segment reference in fixup record
x86.obj : fatal error LNK1123: failure during convertion to COFF: file invalid or corrupt

After this .obj file is produced, but not .exe.

What should I do in order not to get those messages again, and to produce the .exe file?

( some time passed )
I already tried to use MASM versions 6.xx, 7.0, 8.0, but I receive the same message all the time.
Eventually I managed to create .obj files, using "ml /subsystem:windows /c *.asm". But when I try to use "link ..." there is some problems, like in "shell.asm" function "meminit" is not recognized, and so on...

Summary: I am reading the book: Art of Assemly. Three or four moths ago I stopped, because MASM wouldn't work with examples, thst were included in software for AoA.

Thank you. ( for any info, because I am loosing my patience in learning assembly for such nonsence like MASM incompatability or something...)

StillUnAware
Posted on 2003-03-28 06:24:23 by StillUnAware
Still,

The problems you are from trying to mix a number of technologies. AOA is Randy Hyde's work and he has a forum here to ask about it. MASM32 is for 32 bit Windows assembler but the code you posted is 16 bit DOS code. They do not mix and are different systems.

Use MASM32 for building 32 bit Windows programs as it is an extensive system based on the modern stuff. DOS code is becoming a bit hard to find now, my own view is that you will probably get the best result building DOS code with a Microsoft MASM version like 6.11d if you have the package.

For a different approach, you can try Randy Hyde's new High Level Assembler which is also a diffeent concept. Ask a question in the HLA forum for info on how to use it.

Regards & good luck learning.

hutch@movsd.com
Posted on 2003-03-28 06:51:41 by hutch--
Thank you for your answer, at last I know why...
One more tiny question : how do you know it's a 16 bit assembly code ( I'm plain newby, for now...)?
Posted on 2003-03-28 09:17:46 by StillUnAware
AoA for normal masm was only for 16 bits assembler (non-windows)

AoA 32 bits (+ windows) was not written for masm (much to our chagrin :tongue: ) but for HLA which is a totally different thing :)

If you need help with HLA consuly the forum right below this one aptly named "HLA" ;) (or consult Randal Hyde's website for more links to resources and the manual)
Posted on 2003-03-28 09:47:45 by Hiroshimator
I don't know anything about HLA but your code says use16 and uses ax, es, etc. registers which are 16 bits. That's how we can tell.
Posted on 2003-03-28 09:48:18 by drhowarddrfine
Yes, I agree that "use16" migth be the answer, but the registers ax, bx and even al, ah, etc. might be used in 32bit code. But this question is not the main thing, why I'm here. The main reason, I want to learn assembly programming. For a start, that might be 16 bit assembly , because 32 bit assembly is very far away from hardware. I mean there are dll's, vxd's, and a great variaty of other drivers, subsystems, restrictions and so on.
So, as I understood, you offer me to write 16 bit programs not in MASM, but in HLA, if so, is there any great difference or not?
Posted on 2003-03-28 10:20:21 by StillUnAware
is there any great difference or not?
Uh, oh.:rolleyes:

Some say hla is good if you know nothing about the hardware or low level programming or have a background in HLL (high level language like C++) programming.

HLA is not MASM and I read there are limitations if/when you try to do some things. The beginning syntax is not masm at all and I personally think you would be learning one language (hla's) before you learn masm. I think it is better to just learn masm directly and save a lot of time.
Posted on 2003-03-28 10:34:42 by drhowarddrfine
32-bit programming is not far away from hardware now. Unless you are using older hardware, of course.
Posted on 2003-03-28 10:37:09 by drhowarddrfine
32bit assembly dosent HAVE TO be far away from hardware...

Check Menuet OS or my OS (SOL OS) and other 32bit ASM OS projects they are example of modern 32bit ASM "very close" to hardware, they are full of IN/OUTs, interupt tables, Interupt service routines (IDT, GDT) paging memory relocation, Linear frame buffers etc

However i do not understand why a beginner will want to deal with the problems of hardware acces at first steps... esp if you can not recognize 16 bit code from 32 bit code...

Doing "simple" win32asm applications will help you learn a lot ... and will also be rewarding for your brain. In time I have found that keeping brain happy is important for learning new things :). You will also find many examples and tutorials (for example the great ones from Iczelion)... also people on this board will help you faster on such matters.

You will also learn technology and stuff that might help you in other modern programming languages... (C/C++)or even other jobs... Unlikely to happen anymore with old DOS code...besides if it is for handhelp PC inside some barcode readers :P

Also IF you want to be close to hardware why not doing VxDs and KMDs :-?

It is harder indeed and i would not suggest it for the first thingy to learn unless you really want to learn and this is your passion for the rest of your life ...
Posted on 2003-03-28 10:39:14 by BogdanOntanu
Still,

Don't restrict yourself on assumptions that may not be correct, when you write 32 bit assembler, every instruction is a processor instruction and there is nothing inbetween what you write and the processor.

If you have a reason to specifically write 16 bit segmented code, then fine but don't assume its useful for current stuff as it has a different architecture.

Randy Hyde's earlier work in AOA was a milestone in its time and it was written around 16 bit DOS technology but his later work is 32 bit in HLA so he has left it behind as well. Depending on ho much programming you have done, your choices appear to be between a high level introduction to asembler like HLA or start with MASM as it is the best supported and documented assembler around at the moment.

Good luck.

hutch@movsd.com
Posted on 2003-03-28 19:55:12 by hutch--

HLA is not MASM and I read there are limitations if/when you try to do some things. The beginning syntax is not masm at all and I personally think you would be learning one language (hla's) before you learn masm. I think it is better to just learn masm directly and save a lot of time.



HLA cannot be used for 16 bit code. Besides that anything that can be done with masm can be done with HLA.



Depending on ho much programming you have done, your choices appear to be between a high level introduction to asembler like HLA or start with MASM as it is the best supported and documented assembler around at the moment.



And HLA is the second most documented.
Posted on 2003-03-29 09:01:48 by Odyssey
Thank you for all your suggestions, I made a conclusion : although I've read about 300 pages about HLA, now I'll start learning MASM from the beginning. So there is my question: where can I get a complete tutorial or a book (from net, free) about MASM32?
Posted on 2003-03-31 04:17:30 by StillUnAware
You can have a look at Thomas's basic win32asm tutorial at http://www.madwizard.org for an introduction to assembly and iczelions's win32 asm tutorial for programming with the windows api.
Thomas's tutorial is not as complete as AOA32 but it should give you an idea of what assembly language is all about.
Posted on 2003-03-31 05:44:37 by Odyssey
Thanks for suggestion, it's not bad.
But maybe there is some other and bigger publications on MASM?
Posted on 2003-03-31 06:13:56 by StillUnAware