flat assembler
Message board for the users of flat assembler.

Index > Main > Question on Segments and Offsets

Author
Thread Post new topic Reply to topic
Alboin



Joined: 31 Jan 2007
Posts: 2
Alboin
Hello,

When I call
Code:
LDS ax, [some-16bit-address]
    

LDS moves the segment of the address into DS and the offset into AX.

How does it find the offset and segment? I think I 'm a little confused about something here......

Thanks!

_________________
Anyone for tennis, wouldn't that be nice?
Post 17 Mar 2007, 18:30
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7721
Location: Kraków, Poland
Tomasz Grysztar
No, it doesn't load the address, it loads the contents of the memory.
That is, you provide as a source the 32-bit memory operand, which contains the complete segment:offset address. An example data definition
Code:
x DD 12h:34h ; same as "x dd 00340012h"    

and the instruction:
Code:
LDS AX,[x] ; loads 0012h into DS and 0034h into AX    
Post 17 Mar 2007, 19:13
View user's profile Send private message Visit poster's website Reply with quote
asmfan



Joined: 11 Aug 2006
Posts: 392
Location: Russian
asmfan
Is it right Tomasz?
AFAIK for getting address segment component left shifted by 4 only, say
0F000h:0FFF5h will be <(0F000h << 4) + 0FFF5h> = 0FFFF5h

_________________
Any offers?
Post 17 Mar 2007, 19:44
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7721
Location: Kraków, Poland
Tomasz Grysztar
Such computation is needed to convert between the linear/physical address and the segmented one. However the LDS instruction loads the segmented address, not the linear one (just like the far call, too).
Post 17 Mar 2007, 20:14
View user's profile Send private message Visit poster's website Reply with quote
Alboin



Joined: 31 Jan 2007
Posts: 2
Alboin
Thanks for the help!

_________________
Anyone for tennis, wouldn't that be nice?
Post 17 Mar 2007, 23:17
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-2020, Tomasz Grysztar.

Powered by rwasa.