Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Whats the opcode for MOV EAX,0?

678 views
Skip to first unread message

Todd RUDICK

unread,
Apr 3, 1994, 1:29:07 PM4/3/94
to
Please!! I'm writing a game in Turbo Pascal and need the binary form of
"mov eax,0" to use inline. Does anybody know how to find this out? Th
Difference in speed for my game is tremendous, as I'm using REP STOSD to clear
video memory (I finally figured out how to code that one). I would prefer
not having to have ten million asm routines linked into my program. Anybody
know why borland never bothered to include 386 instructions in its BASM?
Thanks in advance,
Todd Rudick

Isaac Foraker

unread,
Apr 5, 1994, 11:48:28 PM4/5/94
to
Todd RUDICK (rud...@binkley.cs.mcgill.ca) wrote:
: Please!! I'm writing a game in Turbo Pascal and need the binary form of

I usually use xor to clear eax like this:
db 0x66
xor eax, eax
That's the easiest way to clear eax in a high level language.
--

==== zar...@cegt201.bradley.edu ====
Tact is rubbing out another's mistake instead of rubbing it in.

Ivan Pulleyn

unread,
Apr 6, 1994, 12:24:50 AM4/6/94
to


I would suggest using xor eax, eax or sub eax, eax to make it faster and
involve smaller code. You can easily find out the opcodes by assembling
something small and then disassembling it. As far as the Borland inline
asm, I used to do this:

void Cheat(void) {
asm {
.386
xor eax, eax
}
}

You can also use the string commands like rep movsd by just putting the .386
statement in.


Ivan...

--

for pgp public key: finger ip0...@uhura.cc.rochester.edu
ivan pulleyn 268 susquehanna rd. rochester, ny 14618 (716) 442-3735
hypereal group po box 18572 rochester, ny 14618 (716) 442-6231

Duncan Murdoch

unread,
Apr 6, 1994, 10:34:54 AM4/6/94
to
In article <2nmud3$m...@homer.cs.mcgill.ca> rud...@binkley.cs.mcgill.ca (Todd RUDICK) writes:

> Please!! I'm writing a game in Turbo Pascal and need the binary form of
>"mov eax,0" to use inline. Does anybody know how to find this out?

You can convert lots of 16 bit instructions to 32 bit equivalents by putting
on a prefix of $66. So in BASM, you'd code this as

db $66
mov ax,0
dw 0 { Since mov eax,0 needs a 32 bit 0 }

As someone else mentioned, it's simpler to use xor eax,eax:

db $66
xor ax,ax

You can put either of these through David Baldwin's INLINE program (garbo.
uwasa.fi:/pc/turbopas/inlin219.zip) to get the hex codes, or just type them
in to TD for a quick assembly (if you've got it), or type them in to BASM
and run DUMPPROG to disassemble a line or two of your program (dmpprg20.zip,
same directory on garbo).

>Difference in speed for my game is tremendous, as I'm using REP STOSD to clear
>video memory (I finally figured out how to code that one). I would prefer
>not having to have ten million asm routines linked into my program. Anybody
>know why borland never bothered to include 386 instructions in its BASM?

There aren't any 386 instructions allowed because the linker wouldn't know
what to do with some of them. It only knows about 16 bit fixups. Why not
fix the linker? Good question.


Duncan Murdoch
dmur...@mast.queensu.ca

DWAYNE RICHARD NEED

unread,
Apr 6, 1994, 11:58:01 AM4/6/94
to

I believe to simply precede the operation in question with a

66h for 32 bit operand
67h for 32 bit operator

(Note: These are close, though they may not be exact.)

example: to write mov eax,0

DB 67h
MOV AX,0


I hope this helps.

Dwayne
--

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

Dwayne Need Dwayne Need
System Programmer 6210 Dogwood Lane
North Carolina State University Waxhaw, NC 28173
drn...@eos.ncsu.edu

___ _
Dwayne Need / _ \ _ __ ___ (_) __ _ __ _
MicroVision Software | |_| || '_ ` _ \ | | / _` | / _` | AAA - Welcome
General Organizer | _ || | | | | || || (_| || (_| | to the future!
Developer - IBM Division |_| |_||_| |_| |_||_| \__, | \__,_|
drn...@eos.ncsu.edu |___/

Isaac Foraker

unread,
Apr 6, 1994, 12:51:46 PM4/6/94
to
DWAYNE RICHARD NEED (drn...@eos.ncsu.edu) wrote:
: I believe to simply precede the operation in question with a
: 66h for 32 bit operand
: 67h for 32 bit operator
: (Note: These are close, though they may not be exact.)
: example: to write mov eax,0
: DB 67h
: MOV AX,0

The problem here is that eax is 32 bits and "mov ax,0" will only load ax
with 0000h (16 bits).

It might work like this (I've never tried this before):

DB 66h
MOV ax, 0
DW 0000h

Also, as far as I know, 66h is 386 opcode and 67h is 486 opcode.
--

==== zar...@cegt201.bradley.edu ====
Me transmite sursum, Caledoni!

0 new messages