flat assembler
Message board for the users of flat assembler.

Index > DOS > Loading seg register (MZ files)

Author
Thread Post new topic Reply to topic
Oddity



Joined: 09 Nov 2009
Posts: 2
Oddity 09 Nov 2009, 08:06
Hi. I am trying to create a dos executable where DS will contain the information I define in the .data segment, but I can't figure out how to do this.

Code:
use16
format MZ

segment .data

  mychar:
    db 0x41


segment .code
entry .code:0000

  start:
    mov ax, .data 
    mov ds, ax 

    mov ax, 0x4C00
    int 0x21    


This of course gives me "undefined symbol 'start.data'". I've tried other things like

Code:
mov ax, segment .data    

Code:
mov ax, seg .data    


but of course they give me errors as well. Can anyone help me?
Post 09 Nov 2009, 08:06
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20299
Location: In your JS exploiting you and your system
revolution 09 Nov 2009, 08:17
try with a double dot for the label name
Code:
segment ..data 
...
mov ax,..data    
or even just without a dot
Code:
segment my_data 
...
mov ax,my_data    
Post 09 Nov 2009, 08:17
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 09 Nov 2009, 08:18
Labels preprended with dot are a local labels, so when you write ".data" after the "start:" label, it looks for the "start.data" label actually.
You can either make all labels here local (change "start" to ".start"), or use some non-local names for segments (recommended), like "_data" and "_code".

EDIT: yes, revolution's advice is a good one, too. Smile
Post 09 Nov 2009, 08:18
View user's profile Send private message Visit poster's website Reply with quote
Oddity



Joined: 09 Nov 2009
Posts: 2
Oddity 09 Nov 2009, 08:25
Thanks =)
Post 09 Nov 2009, 08:25
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.