In a message dated 11/08/2003 00:30:49 GMT Standard Time, [EMAIL PROTECTED] writes:

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$).
>
>Can anyone spot anything wrong with the code - I wonder if I have cocked up
>the return stack...
>
>Sorry about the mess - I cannot find the original assembler, so had to use
>DEA to get the source back...
>
>*  Start of Deassembly Code - Dea v5.2 Plus 3
>*  Original file: WIN2_NEMESIS_HDEV_cde
>*  Code execution starts at $10000 with label Lab10000
>
>START_CODE
>Lab10000  lea     lab1000a,a1
>      movea.w   $0110,a0       ; SB.INIPR
>      jmp     (a0)
>
>*  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.



ho hum - never mind, we all make mistakes LOL
The name SAV_DEV$ may be 8 bytes, but it does not start on a word boundary because of the 'dc.b 8' which appears on the line before it !!

The last 'dc.b 0' should therefore stay according to my reckoning!!


>Lab1001E  moveq    #0,d1
>      moveq    #0,d0
>      move.w   lab10076,d1
>      beq     lab1006a
>      btst    #0,d1
>      beq.s    lab10032
>      addq.l   #1,d1
>Lab10032  addq.l   #2,d1
>      move.l   d1,d5
>      movea.l   $58(a6),a1
>      movea.w   $011a,a0       ; QA.RESRI
>      jsr     (a0)
>      movea.l   $58(a6),a1
>      suba.l   d5,a1
>      move.l   a1,$58(a6)
>      movea.l   a1,a2
>      lea     lab10076,a0
>      moveq    #0,d0
>      move.w   (a0)+,d0
>      move.w   d0,0(a6,a2.l)
>      subq.l   #1,d0
>Lab1005A  move.b   (a0)+,2(a6,a2.l)
>      addq.l   #1,a2
>      dbf     d0,lab1005a
>      moveq    #1,d4
>      moveq    #0,d0
>      rts
>
>Lab1006A  moveq    #-$0c,d0       ; ERR.INAM
>      rts
>
>Lab1006E  dc.l    '<<QDRV>>'
>
>Lab10076  dc.w    13
>      dc.b    'win2_NEMESIS_'
>
>Lab10085  dc.b    0
>Lab10086  ds.b    34
>END_CODE 
>      end
>*  End of Deasm


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
      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
      movea.l   a1,a2        Copy of stack pointer
      lsr.l    #1,d5        | Number of words to transfer
      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.

QDOS/SMS forever !

Thierry ([EMAIL PROTECTED]).


Well, thanks very much - I never felt the need to optimise, but I might as well now...

Still does not explain why the error on QL2K !!

d$=SAV_DEV$ returns "channel not open" LOL

--
Rich Mellor
RWAP Services
35 Chantry Croft, Kinsley, Pontefract, West Yorkshire, WF9 5JH
TEL: 01977 610509
http://hometown.aol.co.uk/rwapsoftware

Reply via email to