Afternoon all.

I'm puzzled again. I'm writing an article on the use of the maths packags in 
QDOSMSQ for our esteemed QL Toady magazine and I've hit a small problem that, 
for the life of me, I can't figure out.

I was explaining the SAVE and LOAD op codes for RI_EXEC and RI_EXECB where the 
top of stack floating point value is saved to a variables area at (A6,A1.L) or 
a new TOS is created by loading back from said area. The op codes for save are 
even in the range $32 to $FF and the load op codes are odd in the same range. 
Save with $32 and load the same value back with $33, save with $34 and load 
with $35 and so on.

I was trying to explain where exactly the 6 bytes of the FP number are loaded 
from and saved to, so I decided to have a look at the code in the SMSQE 3.1.2 
source, and I found the qa_op and qa_mop routines, tracing through these I 
basically found the following (in file smsq\qa\op.asm) :

6 bytes are saved and loaded to and from the address given by (A6.L + A4.L + 
D0.W) where D0.W is simply the op code in the range £32 to $FF with bit zero 
cleared (ie even).

Now I had assumed that I could save one FP using code $32 and another using op 
code $34 and so on, but the source appears to indicate that I will overwrite 
part of my $32 saved FP with part of my $34 saved FP.

Not only this, but I'm effectively wasting the $32 bytes at the start of my 
buffer at (A6,A4.L) because the lowest op code I can use is $32 and that writes 
to my (buffer address + $32) to (buffer address + $37).

My next save would be to (buffer address + $34) to (buffer address + $39) - and 
so on.

Is this a bug in SMSQE or am I missing something serios here.

What I was expecting is the load and saves to occur from (D0.W - $32) *6 bytes 
on from the start of my buffer - this would allow me to save consecutive FP 
values without corruption.

Anyone got any ideas ?

Here's the code :

;+++
; QL Arithmetic: do operation
;
;       d0 cr   operation code error return
;       a1 c  u pointer to arithmetic stack
;       a4 c  p pointer to (top of) variables area
;       a6      base address
;       status return standard
;---
qr_op
        add.l   a6,a1
        add.l   a6,a4
        bsr.s   qa_op

        sub.l   a6,a4
        sub.l   a6,a1
        rts

;+++
; QL Arithmetic: do operation
;
;       d0 cr   operation code error return
;       a1 c  u pointer to arithmetic stack
;       a4 c  p pointer to (top of) variables area
;       a6      base address
;       status return standard
;---
qa_op
        ext.w   d0
        cmp.w   #qa.maxop,d0             ; operation?
        bhi.s   qao_ldst                 ; ... no
        add.w   d0,d0
        add.w   qao_tab(pc,d0.w),d0
        jmp     qao_tab(pc,d0.w)         ; ... do it

qao_ldst
        bclr    #0,d0                    ; load or store
        beq.s   qao_load
        move.w  (a1)+,(a4,d0.w)
        move.l  (a1)+,2(a4,d0.w)         ; store
        bra.s   qao_ok
qao_load
        move.l  2(a4,d0.w),-(a1)          ; load
        move.w  (a4,d0.w),-(a1)
qao_ok
        moveq   #0,d0
        rts

Cheers,
Norman.

_______________________________________________
QL-Users Mailing List
http://www.q-v-d.demon.co.uk/smsqe.htm

Reply via email to