News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

DS=0000

Started by korte, April 22, 2007, 05:40:25 PM

Previous topic - Next topic

korte

How to define data segment pointing 0?

My program run DOS, compiling ML.


xdata segment 'DATA'
sampleoff db "HELLO"
xdata ends

code segment

mov esi,offset sampleoff
mov [sampleoff],'A'

Want DS=0 (flat memory and LFB)
now using fs to pointing LFB and XMS but uggly (and slow) segment prefix, want all offset 0 relativ (ds=0000)

but problem defining data segment

(sorry litle english)






korte

Not understod my question?
Sorry litle english

dsouza123

Your initial question seems OK,

Many people posting here only know about Windows 32 bit flat memory,
which doesn't involve changing or switching between the segment registers,
(or at least in the programming I've done), so they wont be able to answer.

You seem to be asking about DOS with XMS (maybe 32 bit esi shown in code snippet)
and switching from the FS to the DS segment.

MichaelW

korte,

Is your question about the VESA BIOS Extensions and using the Linear Frame Buffer?

eschew obfuscation

japheth


Or he might want to use UNREAL mode?

Because that's the fastest solution for VESA LFB access if the program runs in true real-mode.

If this is the case, I might suggest to post the question in the FASM forum which is ways better for DOS and/or low-level questions. There is also some example code for UNREAL mode.



korte

I would like the pointers of the Data Segment to point to physical
addresses when I compile with MASM in DOS enviroment.

For example:

xdata segment 'data'
sampledata label byte
xdata ends

  mov edi, offset sampledata


I would like the edi's value won't be ds:0 but the runtime physical
address according to 0 segment.

It's because the DS register's value is 0 in my program (because of
the XMS and VESA LFB) and I don't want to use another segment
register.

Or is it possible to set the datasegment's position at
compile time?

MichaelW

If I understand you correctly, you need to make MASM encode the data references in your code so they are relative to segment 0, instead of relative to the load address of your data. To do this I think you need to define an AT segment, define you data in that segment (only uninitialized data is allowed), and then use an ASSUME to tell MASM to associate that segment with segment register DS. MASM should then be able to encode all the data references in your code correctly. Sorry, I don't have time right now to code an example. For information see Using Full Segment Definitions and  Setting the ASSUME Directive for Segment Registers here.
eschew obfuscation

sinsi

Here's part of some code I have used in the dim dark past

biosdata segment at 40h
org 4ah
screen_columns word ?
biosdata ends
...
    mov ax,biosdata
    mov ds,ax            ;DS=0040
    assume ds:biosdata
    mov ax,screen_columns
...


So in your case you would do

xdata segment at 0
sampledata label byte
xdata ends
  mov ax,xdata ;sub ax,ax
  mov ds,ax
  ASSUME DS:xdata
  ...
  mov edi, offset sampledata


Of course you can override with DS:

xdata segment at 0
sampledata label byte
xdata ends

cseg segment
  mov ax,xdata ;sub ax,ax
  mov ds,ax
  ASSUME DS:xdata
cseg_label word 0
  ...
  mov ax,ds:cseg_label  ;this gets the offset right but used DS instead of CS
cseg ends
Light travels faster than sound, that's why some people seem bright until you hear them.