segment after segment 
Author Message
 segment after segment

Hi , would you like to tell me how can i creat two segment that one is
follow to the one?I want the code32 segment follow code16 segment
And please tell me how to put a jump instruction into code16 that jump to
code32 segment ,thanks?

.model    tiny
.8086
code16    segment    use16
code16    ends
.386
code32    segment    use32
code32    ends



Wed, 31 Jul 2002 03:00:00 GMT  
 segment after segment


May be you are a bit unsure about what .8086/.386 and use16/use32
entail.

A 8086 can only execute 16-bits code. A 80386 can execute both 16-bit
and 32-bit code. By 32-bit code I mean the possibility of using the 32
bit registers, and 32-bit offsets.

You may mix both 16-bit code and 32-bit code in your program, but
obviously, if there's 32-bit code, a 8086 shall never be able to run
it fully. So don't put

.8086

and later on

.386

just put .386 from the very beginning, because this program is
intended to be run in a 386+ CPU.

Now, a 80386 can be in 16-bit mode, or in 32-bit mode. Use16/use32
just tell the compiler: assume the CPU is now in 16-bit/32-bit mode,
respectively.

If you have a segment with use16, it is meant to be run while the CPU
is in 16-bit mode. If you have a segment with use32, it is meant to be
run while the CPU is in 32-bit mode. If you have 2 segments in your
program, one with use16, another with use32, something must come in
between which changes the CPU mode from 16-bits to 32-bits.

Now, let's see what happens with the following code:

code16 segment para 'code' use16
        mov ax, 12
        mov eax, 12
code16 ENDS

Use16 tells the assembler to assume the CPU is in 16-bits mode, so mov
ax,12 is translated into machine code without a prefix, but mov eax,
12 is translated into machine code with a prefix. Yes, you can write
32-bit code for a CPU in 16-bits mode, but all that 32-bit code needs
the use of a prefix.

And now,  let's see what happens with the following code:

code32 segment para 'code' use32
        mov ax, 12
        mov eax, 12
code16 ENDS

Use32 tells the assembler to assume the CPU is in 32-bits mode, so mov
ax,12 is translated into machine code _with_ a prefix, but mov eax, 12
is translated into machine code _without_ a prefix. Yes, you can write
16-bit code for a CPU in 32-bits mode, but all that 16-bit code needs
the use of a prefix.

Well, I'm afraid this doesn't answer all your questions, but may be a
good starting point...

Manuel Algora



Wed, 31 Jul 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. segment follow segment

2. PUSH Segment, POP Segments

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

4. data segment vs code segment

5. PROGRAM SEGMENT PREFIX ?

6. GemStone segment names

7. Old Space segments and the OE.

8. Multi-segment key lookup with PowerBrowse in CW2.003

9. segmented key locator question

10. 128 segments

11. Too many segments

12. Group or Segment Class Exceeds 64k

 

 
Powered by phpBB® Forum Software