Can you help me by explaining restrictions of xlat instruction...

First, xlat give us the position of a byte in an array of bytes...

Is the array restricted to 256 elements ?? or now, with modern CPU, there is no restrictions ???

What is the number of cycles for this instruction ?

Thanks for your help
Posted on 2002-03-15 06:25:42 by DarkEmpire
Xlat is slow. I don't have my instruction reference here but I seem to remember it is 5 cycles on the 486...

I recommend you to use something like...

mov al, byte ptr [esi+ecx]


Where al is your destination byte, esi is the offset of the first byte of your byte array and ecx is the position of the byte you want to retrieve...

It should be way faster and by using this method, you can address an array of 4294967295 bytes while xlat only allows you to address 256 of them ! :eek:

Hope this helps.
Posted on 2002-03-15 06:48:51 by JCP
xlat shouldn't be too bad on modern CPUs - 2 uops for p2/p3.
The instruction basically does "al = ". Since it's a BYTE
lookup, the table is obviously limited to 256 bytes :).

If you don't care about the rest of EAX, xlat can be changed to

movzx eax, al
movxz eax, byte ptr [ebx+eax]

(or of course any other base register if you want). This is also 2 uops,
but you can put other instructions inbetween if you feel that is helpful =).
Posted on 2002-03-15 07:53:38 by f0dder
Depends what you want to do, XLATB is designed for doing character table conversions, EBCDIC to ASCII type stuff.

Indexed pointers are a lot more flexible in both table and data size but they are just slightly harder to write.


Posted on 2002-03-15 08:02:23 by hutch--
If your coding for size, then it's a great little instruction. :)
Posted on 2002-03-15 10:36:40 by bitRAKE