Newsgroups: comp.os.msdos.djgpp Date: Fri, 14 Feb 1997 12:45:25 -0700 (MST) From: Matthew Mastracci To: Nikita Proskourine Cc: djgpp AT delorie DOT com Subject: Re: data segment in NASM (repost) In-Reply-To: Message-Id: References: Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Thu, 13 Feb 1997, Nikita Proskourine wrote: > > What's the proper way of loading DS with the value of my data segment in > NASM? The docs don't say anything about this (or maybe I am just using an > old version or didn't read the docs carefully). NASM gives me an error > when I try to compile the program: something like "Undefined symbol > '.data'" But it's the name of my data segment! Why can't I use a MOV < >, > SEG .data instruction? I wouldn't worry about explicitly loading DS. DS is always (unless you mess with it) loaded with the selector referencing your data. This includes: all your C variables, your ASM variables and all the malloc()ed memory you've taken. If you're talking about modifying DS and then recovering it: don't forget that NASM doesn't know what the selector of your data segment will be (it isn't known until runtime)! If you want to load/unload it, try: Just use: [bits 32] [section .text] mov [_SaveDS], ds mov ds, [_NewDS] ; code mov ds, [_SaveDS] [section .data] dw _SaveDS 0000h dw _NewDS 0000h ; Fill with your favorite selector somewhere if you want to access the data segment. This *should* work, but I'm just running it off the top of my head. If you post a small code snippet, we may be able to help a little more. /\/\att /\/\astracci mmastrac AT acs DOT ucalgary DOT ca GCS/GE d- s+:+ a--- C++++ UA P+ L E-- W+ N++ o K+ w+ O M- V PS++ PE++ Y+ PGP t+++ 5+++ X++ R++ tv+ b+++ DI++++ I G++ e h r* z?