Am I on the right track? 
Author Message
 Am I on the right track?

Quote:

>    out      dx,0

Should be

    mov al, 0
    out dx, al

Quote:
> :WaitNotRetrace
>    in       al,0x3da       //check VR status

Should be

    mov dx, 03dah
WaitNotRetrace:
    in al, dx

Quote:
> :WaitRetrace
>    in       al,0x3da

Should be

WaitRetrace:
    in al, dx

Quote:
>    rep outs dx, WORD PRT si

Should be

    rep outs dx, word ptr es:[si]

Quote:
>    xor      ax,ax          //return 0
>    xor      dx,dx

Since it can't go wrong, why return an error code?

Quote:
>    out      dx,0

Should be

    mov al, 0
    out dx, al

Quote:
>    rep ins  WORD PRT di,dx

Should be

    rep ins word ptr es:[di], dx

or

    rep insw

Quote:
>    xor      AX,AX          //return 0
>    xor      DX,DX

Again, why bother?

Also, the fact that you disable interrupts while waiting for vertical
retrace is a very {*filter*} thing to do in a multi-tasking environment. It
can cause lost data if, for instance, another program is receiving from
a serial port. My advice is just to loop until you're in a retrace, then
disable interrupts while you output the palette. Once in a great while,
you'll fall off the end of the retrace, and a little artifact may appear
at the top of the screen, but only very rarely.

By the way, there are BIOS functions that do these things.

--

Ciao,
Paul


return address, which has been altered to foil junk mail senders.)



Fri, 22 Oct 1999 03:00:00 GMT  
 Am I on the right track?

Hi,

        I've never programmed in assembler before (allthought I've
read all sorts of intersting and useful docs) . . and I just
discovered I need it for this program I'm working on.  Can someone
please take a minute and tell me if I'm on the right track?  Thanks.

        here's the code.. most of it is self-explanitory. They are
routines that read/write palettes to/from the VGA graphics card.  It's
in a .cpp file, and is ment to compile under Turbo C++ 3.0 by Borland.

-GLog_Error is a typedef for unsigned int.
-PPalette_aucActualPalette is a global array of unsigned characters
which contains the active palette

---------------------------------------------------------------------------------------------------------
GLog_Error PPalette_UpdatePalette (
   void
   ) asm
{
   push     si

   mov      dx,0x3c8       //setup palette register to receive palette
   out      dx,0
   inc      dx

   mov      ax,SEG PPalette_aucActualPalette //load palette
   mov      es,ax
   mov      si,OFFSET PPalette_aucActualPalette //load palette

   mov      cx,64          //do only 64words at a time
   mov      bh,2           //do 2 loops

   cli                     //disable interupts

:WaitNotRetrace
   in       al,0x3da       //check VR status
   test     al,0x008
   jnz      WaitNotRetrace

:WaitRetrace
   in       al,0x3da
   test     al,0x008
   jz       WaitRetrace

   rep outs dx, WORD PRT si

   mov      cx,64
   dec      bh
   jnz      WaitNotRetrace

   sti

   pop      si
   xor      ax,ax          //return 0
   xor      dx,dx

Quote:
}

GLog_Error PPalette_GetPalette (
   unsigned char *      io_aucPalette
   ) asm
{
   push     di

   mov      dx,0x3c7       //setup palette register to receive palette
   out      dx,0
   inc      dx
   inc      dx

   mov      ax,SEG io_aucPalette //load palette
   mov      es,ax
   mov      di,OFFSET io_aucPalette //load palette

   rep ins  WORD PRT di,dx

   pop      di
   xor      AX,AX          //return 0
   xor      DX,DX

Quote:
}

---------------------------------------------------------------------------------------------------------

Thanks in advance!

        Geoff



Sat, 23 Oct 1999 03:00:00 GMT  
 Am I on the right track?

Quote:

> Hi,

>         I've never programmed in assembler before (allthought I've
> read all sorts of intersting and useful docs) . . and I just
> discovered I need it for this program I'm working on.  Can someone
> please take a minute and tell me if I'm on the right track?  Thanks.

Yes, you are.

--
               *** When you build it, they will come ***



http://www.ptf.hro.nl/~walter/



Sat, 23 Oct 1999 03:00:00 GMT  
 Am I on the right track?

On Mon, 05 May 1997 23:26:05 -0700, "Paul D. DeRocco"
Wow, thanks for all these useful comments!  Can I ask a few questions
about them?

Quote:
>>    out      dx,0
>Should be
>    mov al, 0
>    out dx, al

Is it better to do it that way?  I read that there is an intruction to
output and input imediate ports and values to ports.  Is it just
better, or did read it wrong?

Quote:
>>    xor      ax,ax          //return 0
>>    xor      dx,dx
>Since it can't go wrong, why return an error code?

I can answer that:  it's part of an overall coding standard.  The
exceptions routines can return are define in the package's (or
modules, if you prefer) header file, and *all* functions return an
error code.  This way, even if a function doesn't orgianly return an
error, if at some future date it needs does the error will always be
picked up by the next level, because it always checks for errors.
        This may seem pointless, but the errors it catches and the
stability it offers far outweigh the time it occationally wastes.

Quote:
>Also, the fact that you disable interrupts while waiting for vertical
>retrace is a very {*filter*} thing to do in a multi-tasking environment. It
>can cause lost data if, for instance, another program is receiving from
>a serial port. My advice is just to loop until you're in a retrace, then
>disable interrupts while you output the palette. Once in a great while,
>you'll fall off the end of the retrace, and a little artifact may appear
>at the top of the screen, but only very rarely.

considering how long those loops have to weight for the next retrace,
can it still cause data loss?

Quote:
>By the way, there are BIOS functions that do these things.

umm.. good point.  It's good practice, though :)


Sun, 24 Oct 1999 03:00:00 GMT  
 Am I on the right track?

Quote:
> >>    out      dx,0
> >Should be
> >    mov al, 0
> >    out dx, al

> Is it better to do it that way?  I read that there is an intruction to
> output and input imediate ports and values to ports.  Is it just
> better, or did read it wrong?

Aren't immediate ins and outs restricted to port values of 0 to 255?

Regards, Rob.



Sun, 24 Oct 1999 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Am I on the right track?

2. Reverse Engineering Continued (Am I on the right track)

3. Am I on the right track?

4. Adding compressed Palm pixmap format to PIL; am I on the right track?

5. could someone get me on the right track??

6. could someone get me on the right track??

7. Am I on the correct track?

8. VO my understanding,am I right?

9. Am I Right?

10. Am I right?

11. Canvas: Am I headed in the right direction?

12. SC-Track Roundup 0.5.8 - an issue tracking system

 

 
Powered by phpBB® Forum Software