moving data into DS 
Author Message
 moving data into DS

I am not quite sure on something... :)  (yes.. .I am a newbie lol)

.model small
.stack 100h
.data
message db "Hello, world!", odh,0ah,'$'

.code
main proc

    mov ds, ax

Why is it necessary, when loading the data segment, to load it into the

register?

Million thank you's in advance :)

-Bill



Sun, 18 Aug 2002 03:00:00 GMT  
 moving data into DS

Quote:

> I am not quite sure on something... :)  (yes.. .I am a newbie lol)

> .model small
> .stack 100h
> .data
> message db "Hello, world!", odh,0ah,'$'

> .code
> main proc

>     mov ds, ax

> Why is it necessary, when loading the data segment, to load it into the

> register?




Mon, 19 Aug 2002 03:00:00 GMT  
 moving data into DS
Quote:

> ...
> Why is it necessary, when loading the data segment, to load it into the

> register?

...

That's intentional. Loading a bogus value into a segment address
register could cause you no end of suffering. So Intel decided to
prevent anyone from loading DS, ES, and some other registers with
anything but the contents of another register. That way you can't
accidentally send your PC into eternal darkness through a typo. Now, if
you're determined enough to put an ooky value into AX, then MOV DS,AX ,
well, I guess there's nothing to prevent that. But at least you can't
mess up DS by "accident".

======================================================




Mon, 19 Aug 2002 03:00:00 GMT  
 moving data into DS
Neither 8086 nor Pentium have instruction that puts particular number to
a segment register. :)

Alexei A. Frounze

Quote:

> I am not quite sure on something... :)  (yes.. .I am a newbie lol)

> .model small
> .stack 100h
> .data
> message db "Hello, world!", odh,0ah,'$'

> .code
> main proc

>     mov ds, ax

> Why is it necessary, when loading the data segment, to load it into the

> register?

> Million thank you's in advance :)

> -Bill



Mon, 19 Aug 2002 03:00:00 GMT  
 moving data into DS


Hello Bill

[Snip]

Quote:

>     mov ds, ax

> Why is it necessary, when loading the data segment, to load it into the

> register?

That's because there is no command that will let you do something with a
"direct value" and a Segment-register.  Sort of the same as "why do loops
only use the CX-register ?" or "why can't I do Bit-functions (bit set, bit
clear, bit test-and-set, etc) on a 80x86".  The creators of the processor
saw no need for it ....

Regards,
  Rudy Wieser



Mon, 19 Aug 2002 03:00:00 GMT  
 moving data into DS

Quote:
>Hello Bill

>[Snip]


>>     mov ds, ax

>> Why is it necessary, when loading the data segment, to load it into the

>> register?

>That's because there is no command that will let you do something with a
>"direct value" and a Segment-register.  Sort of the same as "why do loops
>only use the CX-register ?" or "why can't I do Bit-functions (bit set, bit
>clear, bit test-and-set, etc) on a 80x86".  The creators of the processor
>saw no need for it ....

I just heared of that the non-CMOS versions of 8086 executed something like
a MOV CS,xxxxh opcode. However, I didn't find any compiler which supports
this command.


Wed, 21 Aug 2002 03:00:00 GMT  
 moving data into DS
AHHH!  Gotcha!  :) Many thanks.
Quote:


> > ...
> > Why is it necessary, when loading the data segment, to load it into the

> > register?

> ...

> That's intentional. Loading a bogus value into a segment address
> register could cause you no end of suffering. So Intel decided to
> prevent anyone from loading DS, ES, and some other registers with
> anything but the contents of another register. That way you can't
> accidentally send your PC into eternal darkness through a typo. Now, if
> you're determined enough to put an ooky value into AX, then MOV DS,AX ,
> well, I guess there's nothing to prevent that. But at least you can't
> mess up DS by "accident".

> ======================================================





Wed, 21 Aug 2002 03:00:00 GMT  
 moving data into DS

Refering to NASM nsamdoc.txt manual, I can say there is an undocumented
"pop cs" instruction.

Good Luck
Alexei A. Frounze

Quote:

> >Hello Bill

> >[Snip]


> >>     mov ds, ax

> >> Why is it necessary, when loading the data segment, to load it into the

> >> register?

> >That's because there is no command that will let you do something with a
> >"direct value" and a Segment-register.  Sort of the same as "why do loops
> >only use the CX-register ?" or "why can't I do Bit-functions (bit set, bit
> >clear, bit test-and-set, etc) on a 80x86".  The creators of the processor
> >saw no need for it ....

> I just heared of that the non-CMOS versions of 8086 executed something like
> a MOV CS,xxxxh opcode. However, I didn't find any compiler which supports
> this command.



Wed, 21 Aug 2002 03:00:00 GMT  
 moving data into DS



Quote:

>Refering to NASM nsamdoc.txt manual, I can say there is an undocumented
>"pop cs" instruction.

POP CS would be 0Fh. That is used for SHLD/SHRD on 386+

Osmo



Wed, 21 Aug 2002 03:00:00 GMT  
 moving data into DS


:>
:>Refering to NASM nsamdoc.txt manual, I can say there is an undocumented
:>"pop cs" instruction.

: POP CS would be 0Fh. That is used for SHLD/SHRD on 386+

On the 8088, 0Fh was indeed POP CS.  Apparently that was a consequence of
the general design, and since it wasn't terribly useful, Intel evidently
felt comfortable in redefining it to do something more practical.  I once
wrote a small program which used POP CS to loop forever (or rather, for a
relatively long time -- it would have trapped eventually) without using
any variety of jump.

--

Columbus, Ohio



Sat, 24 Aug 2002 03:00:00 GMT  
 moving data into DS


In newsgroup: comp.lang.asm.x86

Quote:

> That's intentional. Loading a bogus value into a segment address
> register could cause you no end of suffering. So Intel decided to
> prevent anyone from loading DS, ES, and some other registers with
> anything but the contents of another register. That way you can't
> accidentally send your PC into eternal darkness through a typo. Now, if
> you're determined enough to put an ooky value into AX, then MOV DS,AX ,
> well, I guess there's nothing to prevent that. But at least you can't
> mess up DS by "accident".

Actually, almost certainly it was just decided that data path wasn't
needed.

        -hpa
--

"Unix gives you enough rope to shoot yourself in the foot."



Sat, 24 Aug 2002 03:00:00 GMT  
 
 [ 11 post ] 

 Relevant Pages 

1. moving data into DS

2. ds ds

3. DS and data segment question.

4. Problem to defines DS (data segment)

5. initialize DS to data segment

6. Need help moving string field using data variable at runtime

7. moving data from Clipper to SQLServer v7

8. Moving data between registers

9. moving data.......

10. Moving data from 16bit seg to 32bit seg

11. moving data between registers

12. Moving data from registers to variables...

 

 
Powered by phpBB® Forum Software