----- Original Message -----
From: "Thierry Godefroy" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, August 11, 2003 12:33 AM
Subject: Re: [ql-users] Machine Code Extension
>
> On Sat, 9 Aug 2003 06:20:20 EDT, [EMAIL PROTECTED] wrote:
>
> > Hmm - one of my old machine code extensions reports an error on QL2K
(oddly
> > enough, it reports Channel Not Open when I use d$=SAV_DEV$).
Possibly an RI stack problem in another (nearby) keyword is causing this.
<>
> > * Def SB extensions
> > Lab1000A dc.w 0
> > dc.w 0
> > dc.w 2
> > dc.w lab1001e-*
> > dc.b 8
> > dc.b 'SAV_DEV$'
> > dc.b 0
> > dc.w 0
> > * End SB ext
>
> That last 'dc.b 0' should be removed, although it will not make a
> difference here given their is no more function name after that one
> and that the following bytes are 0 as well...
> The number of bytes in the name table must be kept even: as
> SAV_DEV$ counts 8 bytes, you don't need for a padding null byte.
The padding byte needs to be there: Nametable name strings all have byte
sized length counters.
<>
> The code seems correct although far than optimized. I'd propose:
>
> Lab1001E moveq #0,d5 Clear MS word.
> lea Lab10076,a4 Name string address
> move.w (a2)+,d5 Name length
> addq.l #3,d5 | Take length word into account
> bclr #0,d5 | and round up to word boundary
or
moveq #3,d5
lea.l Lab10076,a4
add.w (a4),d5 wont overflow in this context
bclr #0,d5
> move.l d5,d1 Number of bytes to reserve
> movea.l $58(a6),a1 Arithmetic stack address.
> movea.w $011a,a0 QA.RESRI
> jsr (a0) Reserve the space on the stack
> movea.l $58(a6),a1 New stack address
> suba.l d5,a1 Make space for the string
> move.l a1,$58(a6) Store the new top of stack
or
jsr (a0)
sub.l d5,$58(a6)
move.l $58(a6),a1
> movea.l a1,a2 Copy of stack pointer
> lsr.l #1,d5 | Number of words to transfer
or
lsr.l #1,d5
loop
move.w (a4)+,0(a6,a2.l) first move is length word
addq.l #2,a2
dbra d5,loop min once through loop
> subq.l #1,d5 |
> Lab1005A move.w (a4)+,0(a6,a2.l) Transfer a word.
> addq.l #2,a2 Increment stack pointer
> dbf d5,Lab1005A Continue until end of name.
> moveq #1,d4 Parameter on stack = string
> moveq #0,d0 No error
> rts retuns...
>
> Lab1006E dc.b '<<QDRV>>'
>
> Lab10076 dc.w 13
> dc.b 'win2_NEMESIS_'
> Lab10086 ds.b 35
>
> The above is tested and working.
Per