From: Reinier Zwitserloot
Subject: Re: 3D game engine for PB?
Take an assembler that doesn't require the hassle of linking just to
produce straight binary output (stuff that'll directly run) and compile
this:
CLC ;Use NASM, -fbin, easiest.
and inspect the file. CLC (Clear Carry flag) translates directly to:
CHR$(0F8h). In other words, the file will be 1 byte long, containing the
byte 0F8h, which is what CLC really is. Every single opcode can be
translated like this, though some are a bit longer, up to a max of 7
bytes (that's only for some newer MMX or pentium instructions, 80486 and
lower is up to 5, max.)
dB is not a real opcode but causes the assembler to insert a byte value
straight in.
so,
1. CLC
2. dB 0F8h (in PB: !dB &hF8)
statements 1 and 2 are *exactly* the same. However, looking up all those
codes gets rather annoying. So, what you could do, is write a program
that takes the assembly statements, saves them to a temporary file, gets
an assembler to compile the code straight binary, read the generated
binary file, and insert all that back into the PB program as !db
statements, and send THAT on to PBC which will compile it just fine.
That's just what PBPLUS does.
so, while you can't actually use !LEAVE (a 286 opcode) in the PB/inline
system, you CAN do !db &hC9 which is the same thing as the LEAVE opcode.
PBPLUS takes care of the translating LEAVE to !db &hC9, and uses NASM to
accomplish this.
Brianster wrote:
>
> Ok, now I'm pretty confused here. I'm not a professioanl programmer on the
> level you guys are and no very little about assembler. (I usually learn
> something about it only when I see some code and I want to know how it
works.)
> But I'm really confused about what instruction PB's inline can handle. On
one
> had, if you're doing stright inline assembly programming, you have to
conform
> to the 8086 instruction set, right? If you want to use 32-bit
nstructions,
> you need to link .obj files compiled in a seperate assembler compiler
Masm,
> Tasm, Nasm...the debate rages on :)...) But, if I'm following this
correctly,
> everyone is saying that I can write 386 assembly code, put it in PB but
ust
> put a !db in front of it and it will work? Somehow this seems a little to
easy
> to me and I think I'm missing something here...
> Brian
--
- Ray Zwitserloot.
R.Zwitserloot@antispam.BTInternet.com
Change the E-mail address to reply!
----------------------------------------------------
*** QwkNews (tm) v2.1
* [TN71] alt.lang.powerbasic POWER_BAS Gateway
--- GEcho 1.20/Pro
---------------
* Origin: Toast House Remote (1:100/560.2)
|