mov eax,ebx

change to

mov ax,bx

Why ?

Posted on 2004-08-09 00:20:49 by zada
If you're using MASM be sure you have specified at least a .386 processor. You probably used .286 and got the following error :

error A2085: instruction or register not accepted in current CPU mode
Posted on 2004-08-09 00:27:40 by donkey
Yes,I did it.

I have specified at least a .386 processor.

No error single.

Still useless.
Posted on 2004-08-09 00:33:38 by zada
First specify processor, then model flat:

.model flat,stdcall

"stdcall" is optional, but will set all your PROCs to stdcall, which is more optimal than the C calling convention, which iirc is the default. The order of processor and model selection is important, though...
Posted on 2004-08-09 02:19:24 by f0dder
I see !

Thank you !

But I have another problem.

.model small
num dd 12345678h
main proc near
mov ax,@data
mov ds,ax
mov eax,num <----------- When I disassembly , here is " DB 66. " Why ?
mov ah,4ch
int 21h
main endp
end main
Posted on 2004-08-09 09:47:35 by zada
As I remember, 66h was one of the 32-bits prefixes under real mode. So it's not a problem in your code (in fact it wouldn't work without it).
Posted on 2004-08-09 10:14:10 by QvasiModo
Ah, so you want a 16bit program but still be able to use 32bit registers - you should have specified this (as well as posted in The Heap, as main is mainly for win32 apps).

QvasiModo is right - and you ought to get yourself a better debugger. If all else fails, perhaps will do the trick... might be better free 16bit debuggers around, I dunno.
Posted on 2004-08-09 10:34:53 by f0dder
It has the exact same meaning in protected mode. The only differences between RM and PM are how segments work, how exceptions work, the checking of privilege levels and whether or not you can activate paging.

Anyway, the disassembly in DOS debug won't be of much help to you when dealing with programs written for the 286 and up. I think there are a few shareware disassemblers and debuggers you could use instead, as well as some that you have to buy (or "borrow" from a friend ;))
Posted on 2004-08-09 10:39:27 by Sephiroth3
QvasiModo is right. under realmode, 32bit operations are prefixed with 0x66, whereas 16bit operations are prefixed with 0x66 in pmode.
Posted on 2004-08-09 14:18:39 by Drocon
To be correct it's not about "real" and "protect" modes - 66h is about "default operand size". In real mode default operand size is always 16 bit. In protect mode however default operand size can be either 16 or 32 bits (depends on bit D in segment descriptor) . 66h is switch for the current comand only between default full size and alternative full size (16<->32)
16 and 32 bit GP registers are encoded in instruction the same way, the only thing that help processor to understand wich one shoul be used (ax or eax, di or edi for example) is to check what is "current default operand size" and if there is prefix 66h. So we shouldn't mixed up terms "real"\"protect" and "default operand size"\"default adress size". They are not complitelly the same things.
Posted on 2004-08-09 19:59:10 by The Svin
Oh, I see!

Thanks you!

I 'll get the GRDB instead of the free DOS debbuger.
Posted on 2004-08-09 20:39:44 by zada

The code you posted is DOS code and it cannot be run in 32 bit PE files under protected mode programming. Since OEM Win95 in 1995, dos interrupts cannot be used any longer and you use Windows APIs instead to gain the functionality.

If you have the MASM32 project, have a look at the 32 bit code design in it, its standard 32 bit Windows code that does build correctly.

You don't use segments either in 32 bit flat memory model code.
Posted on 2004-08-10 00:23:53 by hutch--
Why do the people use the protected mode ?

The protected mode is better than the real mode ?
Posted on 2004-08-12 22:31:45 by zada
Protected mode is, well, protected mode. This allows nifty things like running each program in a separate access space, ensuring that one crashing app can be terminated without bringing the whole system down. It also allows for easy virtual memory support, and easy use of 32bit address space (breaking free from the segment:offset addressing, without hacks like unreal/voodoo mode).
Posted on 2004-08-13 02:21:59 by f0dder
It seems difficult.
I am a beginner.
I am still learning the 16 bit .
Programming is a long road.
Posted on 2004-08-13 03:30:59 by zada
In my opinion, 32bit is easier to work with than 16bit... and you don't have to understand protected mode when you're just starting.

Have a look at
Posted on 2004-08-13 03:36:09 by f0dder
Did you write the demoscene with 32bit?
Posted on 2004-08-16 04:41:39 by zada
Got this years back
Posted on 2004-08-18 22:22:21 by mrgone
Posted on 2004-08-18 22:24:17 by mrgone