If I may comment....
1. In QDOS/SMSQ, strings are defined this way, with a leading word determining the length, followed by the characters of the string.
Code: Select all
runcmd dc.w cmdEND-runcmd-2
dc.b 'lrun win1_menu',$0A
cmdEND equ *
Doing it this way means never having to count characters when you change the string contents. I think QMAC requires the "equ *" on the same line as the label.
2. In your loop, you then pick up the word before entering the loop, then send a single character, then decrement the counter and if not -1, yes that's minus one, not zero, skip back to the start. Something like the following untested code:
Code: Select all
MENU lea runcmd,a5
move.w (a5)+,D2 ; Counter of bytes in command.
bra.s endLoop ; Skip loop.
nextchar move.b (a5)+,d1 ; get character
move.l a5,-(sp)
bsr.s doqin ; send to buffer
move.l (sp)+,a5
endLoop dbra d2,nextchar ; Loop until done.
sent rts
So why skip the loop after getting the word count? Two reasons, the first is that we need to stop the loop at D2 = -1 and not at D2 = 0, so reducing the counter without copying a byte does this automagically. The second reason is, if the string just happened to be zero bytes long, improbably I know, but still possible, then the loop will end immediately without copying anything. I'm indebted to the late George Gwilt for this snippet, as I always did something like:
Code: Select all
pick up the word count.
Decrement it.
Enter the loop
do stuff
dbra ...
Which meant that if the word I picked up was zero, my decrement made it -1,. then I would erroneously perform the task within the loop once, then decrement the counter to -2, which is not -1, so the loop would actually execute 65,536 times before reaching -1 again! Not good.
3. Instead of stacking A5 each time, if you have a spare unused address register, why not EXG A5,An before and after the call to doqin? It's quicker than using the stack. I'm indebted to Per Witte for that snippet. If you have spare registers, use them instead of the stack.
Anyway, I'm glad you kept at it and found a way to do it. Nicely done.
Cheers,
Norm.