qdosmsq:vectors:gtint

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
qdosmsq:vectors:gtint [2009/02/10 11:41]
george.gwilt
qdosmsq:vectors:gtint [2009/02/11 10:33] (current)
george.gwilt An additional note on tidying the maths stack
Line 1: Line 1:
 +====== CA_ or SB_ GTINT/GTFP/GTSTR/GTLIN - Vectors $112/$114/$116/$118 ======
 +
 +These vectors evaluate parameters to SuperBASIC procedures and functions and put them on the maths stack.
 +
 +^Call Parameters^^Return Parameters^^
 +|D0.L|Unused|D0.L|Error code.|
 +|D1.L|Unused |D1.L|Corrupted.|
 +|D2.L|Unused |D2.L|Corrupted.|
 +|D3.L|Unused |D3.W|Number of parameters fetched.|
 +|D4.L|Unused |D4.L|Corrupted.|
 +|D6.L|Unused |D6.L|Corrupted.|
 +|A0.L|Unused |A0.L|Corrupted.|
 +|A1.L|Unused |A1.L|Updated pointer to maths stack|
 +|A2.L|Unused |A2.L|Corrupted.|
 +|A3.L|Pointer to first parameter|A3.L|Preserved.|
 +|A5.L|Pointer to last parameter|A5.L|Preserved.|
 +|A6.L|SuperBASIC pointer |A6.L|Could be changed.|
 +
 +===== Errors =====
 +|ERR_BP|Bad parameter.|
 +|ERR_XP|Error in expression.|
 +
 +===== Notes =====
 +  * All registers not shown above are not used on entry and are preserved on exit.
 +  * The parameters are stored in the name table between (A3,A6.L) and (A5,A6.L). Thus A5.L points to the //end// of the last parameter.
 +  * The final value of the maths stack is at (A1,A6.L). The value in A1 is also set in BV_RIP(A6).
 +  * The four routines process the following four types of parameter:
 +    * GTINT - integer.
 +    * GTFP  - floating point.
 +    * GTSTR - string.
 +    * GTLIN - long integer.
 +  * The maths stack is set to its initial position after procedures and after errors in functions. It is up to the programmer to tidy the maths stack after a function.
 +  
 +
 +===== Example =====
 +In this example we need three integer parameters followed by two long integers.
 +
 +
 +<code>
 +       lea       5*8(a3),a0      ; To check for 5 parameters
 +       cmpa.l    a0,a5
 +       bne       bad_parm ---->  ; There were not 5 parameters
 +       movea.l   a5,a4           ; Keep the pointer to the end of parameters
 +       lea       3*8(a3),a5      ; Arrange to input 3 parameters
 +       movea.w   CA_GTINT,a2
 +       jsr       (a2)            ; Process the parameters
 +       bne       bad_parm ---->  ; (No need to test D0.L)
 +       subq.w    #3,d3           ; Three parameters? . .
 +       bne       bad_parm ---->  ; . . no!
 +       movem.l   (a1,a6.l),d5-7  ; Extract parameters to D5 to D7
 +       addq.l    #6,bv_rip(a6)   ; Tidy the maths stack
 +       movea.l   a5,a3           ; Point to the last two parameters
 +       movea.l   a4,a5           ; Restore A5
 +       movea.w   CA_GTLIN,a2
 +       jsr       (a2)            ; Process the remaining 2 parameters
 +       bne       bad_parm ---->
 +       subq.w    #2,d3           ; Two parameters? . .
 +       bne       bad_parm ---->  ; . . no 
 +       addq.l    #8,bv_rip(a6)   ; Tidy the maths stack
 +</code>
 +
  
  • qdosmsq/vectors/gtint.txt
  • Last modified: 2009/02/11 10:33
  • by george.gwilt