Board index » delphi » Assigning ES:EP a string

Assigning ES:EP a string

Hi!
  How do I assign ES:EP (I think) in Assembler?  Also, Can anyone help me
clear the screen in graphics mode? (Not BGI)

Thank You,
Jon Troyer
j...@alpha.psd.k12.co.us

PS Can anyone point to any good assembler resources on the Internet? and
please E-mail me also.

 

Re:Assigning ES:EP a string


Quote
Jonathan P. Troyer wrote:

> Hi!
>   How do I assign ES:EP (I think) in Assembler?  Also, Can anyone help me
> clear the screen in graphics mode? (Not BGI)

Hmm... Never seen that register before (EP). But you have BP and SP. Which do
you mean? Anyway, if you'd like to make ES:DI point to a array, you could do a

les di, TheArray[0]

or somthing. The TheArray[0] is the part I'm not 100% sure about.

Next, clearing the screen. Ok, a fast way:

mov ax, $a000
mov es, ax
xor di, di
mov cx, 64000 {if in 320x200x256}
db $66; xor ax, ax
db $66; rep stosw

- Asbj?rn

Re:Assigning ES:EP a string


Quote
> Next, clearing the screen. Ok, a fast way:

> mov ax, $a000
> mov es, ax
> xor di, di
> mov cx, 64000 {if in 320x200x256}
> db $66; xor ax, ax
> db $66; rep stosw

Ok, this might be just me, but if you are using a rep stosd shouldn't
cx be only 16000, or did I miss something?

Also, exactly what does les do?  

Ben Stephenson
aa...@info.london.on.ca

Re:Assigning ES:EP a string


Asbjorn allegedly said:

A> Jonathan P. Troyer wrote:
A> >
A> > Hi!
A> >   How do I assign ES:EP (I think) in Assembler?  Also, Can anyone help me
A> > clear the screen in graphics mode? (Not BGI)
A>
A> Hmm... Never seen that register before (EP). But you have BP and SP. Which d
A> you mean? Anyway, if you'd like to make ES:DI point to a array, you could do
A>
A> les di, TheArray[0]
A>
A> or somthing. The TheArray[0] is the part I'm not 100% sure about.

I don't think this would work, unless maybe TheArray is an ARRAY[0..1] of
Word/Integer. I believe to make ES:DI (or DS:SI, for that matter) point to
TheArray, you'd use:

    les di, @TheArray
or
    les di, @TheArray[0]

The first method points to the beginning of the array, while the second points
to element 0 of the array (not good if the array starts at a negative number,
although that's rare).

Of course, I've been programming in OS/2 for a while, so I may be wrong. :)

--
| Jeff Teunissen -=- President, Dusk To Dawn Computing      Team OS/2
| Disclaimer: I am my employer, so anything I say goes double for me.
| Email: d...@grfn.org          URL: http://www2.dhinternet.com/~deek

Re:Assigning ES:EP a string


Quote
Ben Stephenson wrote:

> > Next, clearing the screen. Ok, a fast way:

> > mov ax, $a000
> > mov es, ax
> > xor di, di
> > mov cx, 64000 {if in 320x200x256}
> > db $66; xor ax, ax
> > db $66; rep stosw

> Ok, this might be just me, but if you are using a rep stosd shouldn't
> cx be only 16000, or did I miss something?

Oh, sorry, it was late, and of cource you're right. 64000 is the number
of bytes total, and 64000 / 4 = 16000. What was I thinking? (probaly nothing :)

Quote
> Also, exactly what does les do?

les works a like lea (load effective address), it takes a pointer and load the
registers with the address that the pointer points to. The diffrence is that lea is
just 16 bit (within a segment) and les load it into es:register. So it's like pointer^

You can use any of the segment reg's, like lds, lss and so on.

So, an example:

begin
        pointer:= @record;

        asm
           les di, dword ptr [pointer]
{       es:di should now point to record }
        end;
end.

- Asbj?rn

Re:Assigning ES:EP a string


Quote
Ben Stephenson wrote:
> > Next, clearing the screen. Ok, a fast way:

> > mov ax, $a000
> > mov es, ax
> > xor di, di
> > mov cx, 64000 {if in 320x200x256}
> > db $66; xor ax, ax
> > db $66; rep stosw

> Ok, this might be just me, but if you are using a rep stosd shouldn't
> cx be only 16000, or did I miss something?

You didn't miss anything; it *should* be 16000.  It might not do any
harm, since it should remain within the same segment and just wrap
around a few times.  Nevertheless, it's still safer to use 16000 there.

Quote
> Also, exactly what does les do?

"LES" and "LDS" are used to load segment/offset pairs from memory.  For
example, "les di,[mypointer]" loads ES with the segment portion of the
pointer at memory location DS:[mypointer] (if a global, or
SS:[mypointer] if a local or a parameter), and loads DI with the offset
portion of the pointer at memory location DS:[mypointer] (or
SS:[mypointer]).

Generally, for assembly pointer operations, DS:SI are paired as a source
pointer, and ES:DI are paired as a destination pointer (for operations
like STOS, LODS, and MOVS).

For other questions like these and for more information, you might want
to get an opcode reference.  I know there's one floating around with the
name INTEL.DOC.

Quote
> Ben Stephenson
> aa...@info.london.on.ca

--
Scott Earnest        | We now return you to our regularly |
set...@ix.netcom.com | scheduled chaos and mayhem. . . .  |

Re:Assigning ES:EP a string


On 7 Feb 1997, Jonathan P. Troyer wrote:

Quote
> Hi!
>   How do I assign ES:EP (I think) in Assembler?  Also, Can anyone help me
> clear the screen in graphics mode? (Not BGI)

Ummm... if you want to use ES:DI for MOVS instructions, there are two ways
to do it...

PUSH ES
PUSH DI
MOV AX,SEG xxxx
MOV ES,AX
MOV DI,OFFSET xxxx
.
.
.
POP DI
POP ES

Where xxxx is the name of the data item you want to use.  (A pointer).
There is a single instruction for this, which replaces the three MOV
instructions:

LES ES,DI xxxx

which does the same thing.

To clear the screen depends on which video mode you are using, and on your
video card.  In general, the screen is accessed using a 64K memory block
at segment $A000 (on the VGA/SVGA).  Sometimes this is 128K.  You can
clear the memory block like this:

PUSH ES
PUSH DI
MOV AX,0A000h
MOV ES,AX
XOR DI,DI
CLD
MOV CX,32768
XOR AX,AX
REP STOSW
POP DI
POP ES

There are probably faster ways (consider using wider elements for the
STOSx instruction, such as a DoubleWord or TenByte).  In higher resolution
modes which require more than 64K ram, this will only clear part of the
screen.  You need to select the bank number to work with.  Get a hold of
the SWAG archive, which has a much fuller explanation in it.

Quote

> Thank You,
> Jon Troyer
> j...@alpha.psd.k12.co.us

> PS Can anyone point to any good assembler resources on the Internet? and
> please E-mail me also.

Do a search using infoseek or lycos for 'assembler'. :)

Cheers,

JB

+----------------------------------------------------------------------------+
| John Breen                                        wom...@mad.scientist.com |
| External Student Representative                   +61-97-91-5646           |
| Edith Cowan University ISRC                       0411-378-443             |
|                                                                            |
|             http://www.geocities.com/SiliconValley/Heights/8192            |
+----------------------------------------------------------------------------+

Re:Assigning ES:EP a string


--
Vincent Negrier (negri...@epita.fr)
Sysop of Deadline BBS +331-46486763

Quote
>   How do I assign ES:EP (I think) in Assembler?  Also, Can anyone help me
> clear the screen in graphics mode? (Not BGI)

Well, EP does not exists :) The most used offset register with ES is DI
(16b) or EDI (32b). If you want ES:DI to point to a string, just do
something like that:

var s:^string;
begin
  {something here}
  s^:='test';
  asm
    les di,s
    {do something useful}
  end;
  {here could be your banner ad}
end.

LES DI,pointer sets ES:DI to the pointer ... You can use another
combination of course (LES SI,pointer for ES:SI ...).

To clear the screen, it depends which graphics mode you are in. For mode
13h (320x200 256col), do this:
asm
mov ax,0a000h
mov es,ax
xor di,di
mov cx,16000
db 66h
rep stosw
end;

for 3h mode (text 80x25), replace 0a000h with 0b800h and 16000 with 1000.
The word in AX is the segment of the video memory, and the one in CX is the
size of the video mem div 4 (must be linear).

Bye ...

Quote

> Thank You,
> Jon Troyer
> j...@alpha.psd.k12.co.us

> PS Can anyone point to any good assembler resources on the Internet? and
> please E-mail me also.

Other Threads