bad parameter when calling machine code from superbasic

Anything QL Software or Programming Related.
Post Reply
User avatar
nitrofurano
Chuggy Microdrive
Posts: 53
Joined: Sat Nov 16, 2013 10:48 am

bad parameter when calling machine code from superbasic

Post by nitrofurano »

i was trying this code:

Code: Select all

10 a$="227C0002081012BC005A4E75"
11 data 34,124,0,2,8,16,18,188,0,90,78,117
14 rem move.l #$00020810,a1
15 rem move.b #$5A,(a1)
16 rem rts
20 q=respr(704)
21 restore 11
22 for i=0 to 11
23 read j
24 poke q+i,j
25 next i
33 call q
and i got "At line 33 bad parameter"

what might caused that? the machine code simply does a poke on the display area (which indeed works as expected), and i thought that rts (0x4E75) would return to basic without any error message - or i should do something more/else instead?


User avatar
pjw
QL Wafer Drive
Posts: 1623
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

Re: bad parameter when calling machine code from superbasic

Post by pjw »

nitrofurano wrote:i was trying this code:
<>
I hate to be the one to say it, but you really need to research the basics
of a system you intend to target otherwise this could get excruciatingly
painful.

This once only, without looking at the ins and outs of your code: Most
system calls end in a

Code: Select all

        moveq #error,d0		; some negative error code
        rts

or

        moveq #0,d0			; all ok
        rts
to indicate an error or no error

Ditto calls to sub routines like that called from S*BASIC. CALL will always
return an error unless the condition flag Z is set. On Qdos, IIRC, BASIC
may simply STOP without an error if neither N nor Z is set.


Per
I love long walks, especially when they are taken by people who annoy me.
- Fred Allen
User avatar
nitrofurano
Chuggy Microdrive
Posts: 53
Joined: Sat Nov 16, 2013 10:48 am

Re: bad parameter when calling machine code from superbasic

Post by nitrofurano »

thanks, it works perfectly!
(it's indeed the very first time i see we need to clean registers and flags before returning to basic - i think i'd never find this out without making mistakes and fixing them from your help, even with good documentation available around, so, thanks again!)


Post Reply