home *** CD-ROM | disk | FTP | other *** search
-
-
-
-
-
- FDStub
-
- The C to ASM interface generator
- Written by Bruce Mackey
- (c) 1991
- All rights reserved.
-
-
- Version 0.6a
-
-
- -=== CODE GENERATION DOCUMENTATION ===-
-
-
- Here are a few things to know about FDStub.
-
-
-
- 0. I am completly self taught in programming.
- So I am explaining things as I understand them,
- its possible that I am wrong about everything..
- but not probable. :)
-
- 1. D0 REGISTER. FDstub NEVER SAVES the D0 register. If D0
- is declared in the function definition the register
- WILL BE loaded from the stack BUT FDStub WILL NOT save
- D0 to the stack before loading.
-
- 2. MOVEM INSTUCTIONS. This is my understanding:
- MOVEM always saves DATA regs first followed by
- the ADDRESS regs EVEN if you specify the regs in
- a different order.
-
- SomeFunction(a1,d1) which has a stack like
-
- |------|
- | D1 |
- |------|
- | A1 | lowest
- |------|
-
- and issuing a MOVEM.L A1/D1,-(SP) will cause reg A1
- to be loaded with the value intended for D1 and
- visa versa.
-
- So the trick is to try to use the most efficient
- way of getting parameters off the stack while
- maitaining the LEFT to RIGHT order.
-
-
- here's an example:
- these are the registers for BltBitMap
-
- (A0,D0/D1,A1,D2/D3/D4/D5/D6/D7/A2)
-
- if you issued a command like this
-
- MOVEM.L 44(sp),A0/D0/D1/A1/D2/D3/D4/D5/D6/D7/A2
-
- DON'T expect the registers to be loaded correctly.
-
- registers D0-D7 will be loaded first followed by
- A0-A2 defeating the LEFT to RIGHT order of the regs,
-
-
- This is what FDStub does instead:
-
- _BltBitMap:
- MOVEM.L D1-D7/A0-A2,-(SP)
- MOVE.L 44(SP),A0
- MOVEM.L 52(SP),D0-D1
- MOVE.L 64(SP),A1
- MOVEM.L 72(SP),D2-D7
- MOVE.L 100(SP),A2
- MOVE.L _GfxBase,A6
- JSR _LVOBltBitMap(A6)
- MOVEM.L (SP)+,D1-D7/A0-A2
- RTS
-
- which is better than 11 MOVE.L instructions!
-
-
- 3. SAVING/RESTORING REGISTERS TO THE STACK.
- FDStub makes what I consider a logical assumtion:
- that all LIKE regs defined for a function will
- have a progression from lowest reg to highest
- WITHOUT SKIPPING a register.
-
- Now to expalin what I mean by that. Let's use AmigaDOS
- function Write(d1/d2/d3), when 'Write' was created the
- author started at D1 and progressed up to D3 and didn't
- skip any registers. If you were to redefine 'Write' to
- Write(d1/d2/d4), FDStub will pull registers D1-D4
- you'll get 4 registers instead of 3.
-
- you can see what will happen if this rule is not followed,
- when you use the stub in question your computer will do
- some stange things.
-
- (I thought about using a bad pun.. about stubbing... but...)
-
- My pain has a name... that name is "WRITING DOCUMENTATION".
-