Board index » delphi » Assembler - accessing FS / GS registers?

Assembler - accessing FS / GS registers?

Hi, sorry for the assembler but I would really appreciate it if someone has
the opcodes (or a lovely example) for using the FS / GS registers in Borland
Pascal assembler.

The high-colour mode of my graphics unit allows 256 colour virtual palettes.
For speed, the actual high-colour (normally 5bit, 6bit, 5bit) values are
precalculated when the colour is set. The problem comes when implementing a
+ACI-putimage+ACI- command, because I need to use three selectors. ES holds the
screen memory, DS holds the +ACI-image+ACI- information (corresponding to the
virtual palette index), but I also need to hold the selector of the virtual
palette lookup table. So at the moment, by core loop for each pixel consists
of:

(+ACo-Get the index value in bx+ACo-)
push  ds                            +AHs-Preserve the image selector+AH0-
mov   ds,DataSeg                    +AHs-Get the VPal selector+AH0-
mov   ax,WORD PTR VirtualTrue+AFs-bx+AF0-   +AHs-copy the highcolour into ax+AH0-
mov   es:+AFs-di+AF0-,ax                    +AHs-move it to the screen+AH0-
pop   ds                            +AHs-reload the image selector+AH0-

This works okay, but the problem is loading ds all the time is very slow. As
you may be able to visualise, utilising fs or gs to store the virtual
palette selector in would speed things up incredibly. But BP's assembler
won't let me use them. If someone could give me the opcodes or an example it
would be much appreciated.

(I have thought of using an external +ACo-.OBJ file, but I can't get procedures
with parameters working correctly. If anyone could give me an example that
works with NASM I would also be very happy)

--
Lors, Paradice Software
Christchurch, New Zealand
paradice+AEA-thevortex.com
http://surf.to/paradice
--

 

Re:Assembler - accessing FS / GS registers?


Hi,

IMHO, it's better to compile the assembly parts with TASM and link into your
program. The built-in assembler recognizes only 286 instructions.
You can insert 386 instructions with 'DB', but it's just a pain.

Andras

Re:Assembler - accessing FS / GS registers?


In article <901515781.563...@newsch.es.co.nz>,
  "Lors" <parad...@thevortex.com> wrote:

Quote
> Hi, sorry for the assembler but I would really appreciate it if someone has
> the opcodes (or a lovely example) for using the FS / GS registers in Borland
> Pascal assembler.

> The high-colour mode of my graphics unit allows 256 colour virtual palettes.
> For speed, the actual high-colour (normally 5bit, 6bit, 5bit) values are
> precalculated when the colour is set. The problem comes when implementing a
> +ACI-putimage+ACI- command, because I need to use three selectors. ES holds
> the
> screen memory, DS holds the +ACI-image+ACI- information (corresponding to the
> virtual palette index), but I also need to hold the selector of the virtual
> palette lookup table. So at the moment, by core loop for each pixel consists
> of:

> (+ACo-Get the index value in bx+ACo-)
> push  ds                            +AHs-Preserve the image selector+AH0-
> mov   ds,DataSeg                    +AHs-Get the VPal selector+AH0-
> mov   ax,WORD PTR VirtualTrue+AFs-bx+AF0-   +AHs-copy the highcolour into
ax+AH0-
> mov   es:+AFs-di+AF0-,ax                    +AHs-move it to the screen+AH0-
> pop   ds                            +AHs-reload the image selector+AH0-

> This works okay, but the problem is loading ds all the time is very slow. As
> you may be able to visualise, utilising fs or gs to store the virtual
> palette selector in would speed things up incredibly. But BP's assembler
> won't let me use them. If someone could give me the opcodes or an example it
> would be much appreciated.

How about:

getmem(ll_tab, _ride * sizeof(lift_ptr));

asm
  db    $0f,$b4,$3e; dw    offset ll_tab {lfs di, ll_tab}
  db    r386; mov   ax, word ptr lift_top
@s:
  db    r386; mov   word ptr lift_ptr, ax
  db    r386; or    ax, ax
  jz    @z
  dw    fs386; mov [di], ax
  add   di, 4
  push  di
  les   di, lift_ptr
  db    r386;  mov   ax, es:[di + offset lift_list.ll_nxt]
  pop   di
  jmp   @s
@z:
end;

This following is my "386+" include file, with constants that are more
meaningful than seriues of DB's.

const
  pushad       = $6066;
  popad        = $6166;
  segfs        = $64;
  seggs        = $65;
  fs386        = $6664;
  gs386        = $6665;
  r386         = $66;
  a386         = $67;
  cwde         = $9866;
  cdq          = $9966;
  movsd        = $a566;
  cmpsd        = $a766;
  stosd        = $ab66;
  lodsd        = $ad66;
  scasd        = $af66;
  ax_2_fs      = $e08e;
  ax_2_gs      = $e88e;
  imul_eax_ebx = $c3af0f66;

Note that you can get the opcodes by assembling code in TD's CPU window!

HTH,

Robert
--
Robert AH Prins
prin...@wcg.co.uk

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum

Other Threads