16-bit to 32-bit segments 
Author Message
 16-bit to 32-bit segments

I've written a program which writes out a small bitmap. Since I'd like
to write out a larger bitmap, I have to use 32-bit segments so as to fit
the data into the data segment.
As expected the program no longer works.

Could anyone give me some hints as regards going from 16 to 32 bit
segments and tell me why something like the following won't work:

;=====================================================================
.386
.model flat, stdcall

.data
Message1        db      "Hello, sailor!", 13, 10, 0

.code
DisplayMessage  proc    Message:ptr byte        
; print the message
                mov     ah, 02h         ;function 02h - display string
                mov     edi, Message
                .while  1
                mov     dl, [edi]
                .break  .if dl == 0
                int     21h
                inc     edi
                .endw          
; return to caller
                ret
DisplayMessage  endp    

Main            proc
invoke DisplayMessage, addr Message1
                mov     ax, 4C00h               ;return to DOS
                int     21h
                ret
Main            endp

.stack
stk             db      128 dup ("stack   ")

                end     Main
;=====================================================================

Thanks

Rik
--
The rumblynge of a fart, and every soun,
Nis but of eir reverberacioun[...]

                                   -- Geoffrey Chaucer



Sun, 15 Jul 2001 03:00:00 GMT  
 16-bit to 32-bit segments
The DOS loader doesn't understand 32 bit segments or how to load programs.
You're going to have to go to a DPMI/DOS extender type thing to get into
protected mode.  There's a sample of a bare bones "tiny model"  DPMI app (done
as a DOS .COM file) at my web site

http://www.geocities.com/pipeline/halfpipe/3660/index.htm

That'll get you into protected mode at least.  The DPMI app is an appendix in
the online book I've been working on.

 Tony



Sun, 15 Jul 2001 03:00:00 GMT  
 16-bit to 32-bit segments

Quote:
>I've written a program which writes out a small bitmap. Since I'd like
>to write out a larger bitmap, I have to use 32-bit segments so as to fit
>the data into the data segment.
>As expected the program no longer works.
>Could anyone give me some hints as regards going from 16 to 32 bit
>segments and tell me why something like the following won't work:
>;=====================================================================
>.386
>.model flat, stdcall

This model can't be used in plain DOS

Quote:
>.code
>DisplayMessage      proc    Message:ptr byte        
>; print the message
>            mov     ah, 02h         ;function 02h - display string
>            mov     edi, Message
>            .while  1
>            mov     dl, [edi]
>            .break  .if dl == 0
>            int     21h

INT 21h is a 16-bit DOS function, it can't handle 32-bit parameters.
Usually can't be invoked (directly) from a 32-bit program.

For DOS, your program still has to be 16-bit. Simply use 32-bit
instructions for (and ONLY for) the parts you need 32-bit instruction.
So you do NOT use 32-bit directives and/or memory models.

Because i386+ CPU's being compatible with the 80286, memory access
under plain DOS is limitted to 16-bit. If himem.sys is loaded, this
might have changed to 32-bit already, but don't rely on it.
If you want to use 32-bit structures under DOS, (and want it to work
as well :-), you have to use 'huge' pointers, a DOS extender or change
memory access to 32-bit (does not work in DOS emulations).

If you tell me (us) on what environment you program is supposed to
run, we can tell you some hints how to deal with 'larger' structures.

Herman



Sun, 15 Jul 2001 03:00:00 GMT  
 16-bit to 32-bit segments

Quote:
> If you tell me (us) on what environment you program is supposed to
> run, we can tell you some hints how to deal with 'larger' structures.

Thanks so far.

Target is Win 95/98. Using MASM 6.11.
Basically, what I'd like to know is how I can use 32-bit segments with
the least modification to my program (which uses DOS system calls).

R.
--
The rumblynge of a fart, and every soun,
Nis but of eir reverberacioun[...]

                                   -- Geoffrey Chaucer



Sun, 15 Jul 2001 03:00:00 GMT  
 16-bit to 32-bit segments
Quote:
>Thanks so far.
>Target is Win 95/98. Using MASM 6.11.
>Basically, what I'd like to know is how I can use 32-bit segments with
>the least modification to my program (which uses DOS system calls).

I'm afraid that to do this properly, you have to get rid of ALL the DOS
system calls and use Win32 calls instead...
This can be done from MASM, but is easier from C(++)...
I have a Win32 'Hello World!' example somewhere. It uses the console
calls. The .EXE file is 1.5KB...

Herman



Wed, 18 Jul 2001 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. TASM and far jumps from 16-bit segment to 32-bit segment

2. Division 32-Bit/32-Bit with 16-Bit Register

3. 32-bit addr in 16-bit segments - help!!!

4. 16, 16/32, 32 bit Forths: Pros/Cons?

5. Mixing 16-bit and 32-bit segments in one module?

6. 32 bit ST communicating with 16 bit VB

7. How to use SE at any color resolution (256, 16-bit, 32-bit)

8. Can I use 16 bit DLL and 32-bit exe together

9. Changing from 16-bit to 32-bit makes zillion duplicate symbols

10. 16-bit to 32-bit woes

11. Should I use 16 bit or 32 bit??

12. Graphics Error 16-bit vs 32-bit

 

 
Powered by phpBB® Forum Software