Simple Question seeks simple answer 
Author Message
 Simple Question seeks simple answer

Hello world(...)

I'm skipping from 16bit to 32bit, there are some minor problems which I
cannot solve nor does the 'whelp cguide'.

In 16 bits it was common practice to do the well known string copy
something like
        mov es,x
        mov di,y
        mov cx,z
        mov es:[di],x1
        rep movsd.

When I tried something similair in 32 bits my watcom compiler complained
that 'es' was an 'illegal register' (very strange since it is mentioned in
the cguide). 'Well' I thought 'Why use es at all we now have an 'EDI'.' But
this resulted in something not quite right.
the code was I think
        #pragma aux Fill_Screen_White = \
                "MOV EDI,0A0000H"       \
                "MOV CX,16000"          \
                "MOV [EDI],15"          \
                "REP MOVSD"             \
                modify [ EDI CX ];

Question [(1)] how to do a string copy 32 bits - wise ?

Something which looks the same.

To get the VESA info you've got to call int 10H with arguments AH  = 4fh
and AL = 00H and ES:DI being the pointer to put the junk. Once more
how's this done in 32 bit.

I've tried a non asm approach. The usual SREGS, REGS call.

16 bit version, tested and worked.

struct Vesa_info        
        {
                bla...bla...bla
        }

Vesa_info V;
union REGS Registers;
struct SREGS Segment_Registers;

Registers.w.ax = 4f00h;
Registers.w.di = FP_OFF(&V);
Segment_Registers.es = FP_SEG(&V);

int86x(10H, &Registers, &Registers, &Segment_Registers);

For the 32 bit version I invented the same code exept int86x = int386x.

This resulted in either the subtle crash of my p5 or a total empty Vesa_info
struct ( my video card supports Vesa - the 16 bit version proved that ).

Any bright ideas people ?

Finaly does anyone know a optimize-em-up site, that is some basic optimization
tricks for assembly code ?

Please reply to my email.

Regards,
        MArk




Fri, 02 Oct 1998 03:00:00 GMT  
 Simple Question seeks simple answer

Quote:

> In 16 bits it was common practice to do the well known string copy
> something like
>         mov es,x
>         mov di,y
>         mov cx,z
>         mov es:[di],x1
>         rep movsd.

Well this sure as heck aint going to work ...

Quote:
> When I tried something similair in 32 bits my watcom compiler complained
> that 'es' was an 'illegal register' (very strange since it is mentioned in
> the cguide). 'Well' I thought 'Why use es at all we now have an 'EDI'.' But
> this resulted in something not quite right.
> the code was I think
>         #pragma aux Fill_Screen_White = \
>                 "MOV EDI,0A0000H"       \
>                 "MOV CX,16000"          \
>                 "MOV [EDI],15"          \
>                 "REP MOVSD"             \
>                 modify [ EDI CX ];

... for the same reason that *this* doesn't work.  The algorithm it just out
lunch.  The rep MOVSD instruction requires that you prime ds:(e)si and es:{e}di
with the source and destination pointers (respectively) and prime (e)cx with
the number of DWORDs you are attempting to copy.

WATCOM C/C++ takes care of es and ds, by setting them to FLAT selectors (that
point to everything, so you can pretend they aren't there.)  From the looks
of it what you really want to do is a REP STOSD, in which case you prime up
EAX instead of ds:(e)si (and use ds:(e)di instead of es, but that doesn't
matter, of course.)

Try:
         #pragma aux Fill_Screen_White = \
                 "MOV EDI,0A0000H"       \
                 "MOV CX,16000"          \
                 "MOV EAX,15151515h"   \
                 "REP STOSD"             \
                 modify [ EDI CX ];

--
Paul Hsieh

Graphics Programmer
Chromatic Research

What I say and what my company says are not always the same thing



Fri, 02 Oct 1998 03:00:00 GMT  
 Simple Question seeks simple answer

Additions to my previous entry:

One should never, ever send news entries on assembler, while one is
programming....

Please replace all references to "std" by "cld" in my coding examples...

Best regard
Kurt Friis Hansen


Europe 1996: A bribe a day keeps the taxman away...



Wed, 07 Oct 1998 03:00:00 GMT  
 Simple Question seeks simple answer

| Hello world(...)

| I'm skipping from 16bit to 32bit, there are some minor problems which I
| cannot solve nor does the 'whelp cguide'.

| In 16 bits it was common practice to do the well known string copy
| something like
|       mov es,x
|       mov di,y
|       mov cx,z
|       mov es:[di],x1 (**)
|       rep movsd.

There's something missing here... you'd probably prefer to do this:

        les di,target
        lds si,source
        mov cx,count
        shr     cx,1
        std
        rep movsw
        rcl  cx,1
        rep movsb

The instruction I've marked (**) is not need at all (it will get
overwritten anyway).

If you need a string fill (which I suspect from the following), you'd get
better results with:

        mov ax,wordvalue
        les di,target
        mov cx,wordcount
        std
        rep stosw

| When I tried something similair in 32 bits my watcom compiler complained
| that 'es' was an 'illegal register' (very strange since it is mentioned in
| the cguide). 'Well' I thought 'Why use es at all we now have an 'EDI'.' But
| this resulted in something not quite right.
| the code was I think
|       #pragma aux Fill_Screen_White = \
|               "MOV EDI,0A0000H"       \
|               "MOV CX,16000"          \
|               "MOV [EDI],15"          \
|               "REP MOVSD"             \
|               modify [ EDI CX ];
|

You still have severe errors in this routine (se above), and as far as I
can see you still need to set the ES segment. I do not know, why the Watcom
compiler objected, but I suggest you read the documentation. The Watcom
compilers I have used, have never complained about anything I did (whether
good or bad) in assembly code (unless I broke some basic ground rules ;-)

I'm not trying to offend you, but your code suggests, that a good basic
tutorial on assembly language programming could save you a lot of head
aches and grief in the long run. We've all had to start that way....

| [other things I haven't got the time to answer]
| Please reply to my email.

The purpose of news groups is, that answers are posted in them as well. If
news groups only consists of questions, they'll be so uniteresting to read,
that no one would benefit from asking questions....

So, no... I'm not going to answer you by E-mail. Either you're going to
read this news group, or you'll have to live happily without my answer...

best regards


Europe 1996: A bribe a day keeps the taxman away...



Wed, 07 Oct 1998 03:00:00 GMT  
 Simple Question seeks simple answer

Quote:
>| When I tried something similair in 32 bits my watcom compiler complained
>| that 'es' was an 'illegal register' (very strange since it is mentioned in
>| the cguide). 'Well' I thought 'Why use es at all we now have an 'EDI'.' But
>| this resulted in something not quite right.
>| the code was I think
>|   #pragma aux Fill_Screen_White = \
>|           "MOV EDI,0A0000H"       \
>|           "MOV CX,16000"          \
>|           "MOV [EDI],15"          \
>|           "REP MOVSD"             \
>|           modify [ EDI CX ];
>|
>You still have severe errors in this routine (se above), and as far as I
>can see you still need to set the ES segment. I do not know, why the Watcom
>compiler objected, but I suggest you read the documentation. The Watcom
>compilers I have used, have never complained about anything I did (whether
>good or bad) in assembly code (unless I broke some basic ground rules ;-)

Was the illegal register error due to trying to MOV an immediate value
into ES?  Note that if the address size is 32 bits, ECX will be used for
the countdown - if there are any set bits in its high half, things could
get a little out of hand.  If the address size is 16 bits, the writes
will start at 0000H.  There is generally no need to set ES in at least
some of Watcom's 32-bit environments where the default model is flat.

It's just impossible to learn assembler (and the original post can be
attributed to someone who is trying to do this) with only Watcom's docs.
You have to go with some good reference and use the Watcom docs for
explaining its various 32-bit environments, at which they do a good job.



Thu, 08 Oct 1998 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Question in french (a simple question, very simple)

2. simple question but hard to answer

3. Looking for a smalltalk Guru to answer some simple questions

4. Simple ODBC questions I need answered

5. I need two, hopefully simple, questions answered.

6. simple question, hard to answer?

7. Newbie simple question - can't find answer

8. Dumb question, hopefully simple answer

9. Simple forth question - maybe simple ?

10. Simple Answers are sometimes the best

11. Simple Q (prob. long answer)

12. Simple question! Simple answer?

 

 
Powered by phpBB® Forum Software