OK, smart people... why do I get an error compiling the following. The 3 instructions in particular.



.386
.model flat,stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib

.data
msg1 db "message1",0

.code
start:

mov dx, msg1
mov ah, 09h
int 21h

call ExitProcess
end start


And I also want to know about the nature of declaring msg1, All I know is that that's how you declare a string, I have no idea what that 0 is at the end, sometimes it can be a '$' though?

More.. what does stdcall mean in .model flat,stdcall, and what option casemap:none is for?

By the way I'm trying to display a string inside the console window.
Posted on 2002-01-20 11:56:06 by gregd
I hope I'm not off topic!!!

Ok here goes...

1. You can't use the flat memory model on a win32 program
2. You can't use interrupts either. You have to write vxd's
3. If you want to use 32 bit registers on a DOS program, you have to code in DPMI or use a dos extender.

From my experience, win32 doesn't like the $ as a character string terminator, use 0(NULL), stdcall, for more better explanation check out iczelions tuts(tutorial #1), stdcall is a hybrid of c and pascal calling convention. Option casemap is case sensitivity(in C: string != String || string !=strinG...)

that should be invoke ExitProcess, 0
in DOS(Console), you should make that
mov ah, 04Ch
mov al, 0
int 21h

Hope that helps :)
Posted on 2002-01-20 12:09:20 by stryker
Yep, it is the int21 that is bugging you. Also, you didn't specify which compiler and linker you were using. You will need to use an old version of MS's linker if you want to compile&link the above program as a DOS based one (after you remove the includes for the 32 bit version of windows).
Posted on 2002-01-20 14:48:55 by sluggy
gregd,

A number of things, DOS interrupts will not work in 32 bit windows, the memory addressing mode is different and you do not have access to the DOS interrupts.

32 bit PE files are entirely different to DOS COM or EXE files and they run in their own address space.


.386
.model flat,stdcall
option casemap:none


These three lines are necessary for win 32 assembler coding, the .386 or higher processor forces 32 bit code, FLAT memory model is necessary for 32 bit windows, STDCALL is the normal calling convention for almost all API calls and the OPTION CASEMAP:NONE is necessary because API calls are case sensitive.

Console output is done in 32 bit windows by the use of API functions, the MASM32 library has a number of console functions that you can use as reference, either to use or to write your own.

Regards,

hutch@movsd.com
Posted on 2002-01-20 16:49:05 by hutch--
Umberg, you are very very very wrong :).


1. You can't use the flat memory model on a win32 program

You *have* to us eflat memory model on a win32 program.


2. You can't use interrupts either. You have to write vxd's

Well, theoretically you could call interrupts, but the win32
api is not done that way... don't confuse the guy talking about
VxD's.


3. If you want to use 32 bit registers on a DOS program, you have to code in DPMI or use a dos extender.

Again, wrong. You can easily use 32bit registers even from 16bit
realmode... it just generates some pesky prefixes, and of course
you don't have a flat memory model - but there's no problems at all
using 32bit registers from 16bit dos. It's true that you'd have to
use a dos extender (preferably one using DPMI) to get 32bit pmode
code to run under DOS though.


that should be invoke ExitProcess, 0
in DOS(Console), you should make that

Don't confuse DOS and console. While it's true that DOS programs are
"console-mode", a console-mode win32 app is definitely not a dos app ;).
Posted on 2002-01-20 17:12:06 by f0dder
1. Ok I goofed up, Maybe I was thinking of something. Umm eflat? :)

2. What I meant is if you really want to SUCCESSFULLY use interrupts under a win32 program use a vxd.

3. Again, if you want to SUCCESSFULLY use 32bit registers without screwing your program under a console, you have to use a dos extender

4. im assuming he's using dos which is also a console. It'll furthermore confuse the person if I had differentiated DOS console mode and win32 app console mode. So it might be better to let him find out the difference later.

So in essence, I'm just saying those words of my previous post in lay mans term. I don't want to get into technical terms as much as possible. :)
Posted on 2002-01-20 18:05:34 by stryker
Umberg, it's okay not always being right. And it's okay to make guesses,
as long as they have some substantial background. Hey, I'm certainly
not infallible (sp?) either.

But if you have *no clue* what you are talking about... sometimes
it's better to keep silent :). For example, there is *no problem*
using 32bit registers from a 16bit app (well, you're obviously still
limited by the 16bit addressing modes and such).

Please don't take this post too hard, it's not meant as harsh as it
might sound.
Posted on 2002-01-20 18:38:15 by f0dder
gregd,

As your program looks, i think you are trying to show a message, don't you? In that case, do not use interrupts, use MessageBox instead.

This does works for your purpose, that is, shows a message:




.386
.model flat,stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib

.data
msg1 db "message1",0

.code

start:

invoke MessageBox, hInstance, addr msg1, addr msg1, MB_OK
invoke ExitProcess, NULL
end start



Do not hesitate asking more and further questions :)
Posted on 2002-01-21 18:37:31 by CodeLover
The only reason I see why you're getting an error when you assemble it is that your trying to store the hole string into DX. You need to store the address. (ie mov dx, addr msg1).

But your program most likely won't run under win32 (maybe MS-DOS mode).

BTW:
Your program was meant for the 16bit DOS envrionment -- You would need to create a MZ executable or a com (binary image) that will run in v86 mode.

To use the Win32 API you'll need to PE format
and a) Create a GUI app
or b) Create a Console app.

Check out Iczelion's Tutorial
Posted on 2002-01-21 20:34:53 by eet_1024
I've never heard of PE before. What *is* PE?
Posted on 2002-01-22 00:07:12 by gregd
PE is the Win32 equivilent of MZ (MZ being a 16 reallocatable executable).

This is from http://www.wotsit.org/:
Posted on 2002-01-22 00:45:15 by eet_1024
So, Greg, what do you want? 16bit DOS code or 32bit windows code?
I think we need to know that before we can help you further :).
Posted on 2002-01-22 01:58:45 by f0dder