RE: A83: Running asm Programs...
[Prev][Next][Index][Thread]
RE: A83: Running asm Programs...
>>
>>I think what you are doing, is copying the program over the 'shell'...
>
>yes and no, I overwrite the 'shell' at $9327 with the program I want to
run.
>By the way, does that area ($9327 )resize in function of a program's size?
>
>>what you should do is swap the shell with the program, and after that swap
it
>>back...
>
>How can I do this?
>What I do is copying a little code somewhere in memory (cmdshad) that will
then copy the >assembly program to run and jump at $9327.
>It works with every program, but crashes with a bigger program when it
quits.
The code you put in memory should do the folowing things:
[ -- start pseudocode -- ]
push registers
call swapbytes
call $9327
call swapbytes
pop registers
return [ return to shell ]
swapbytes:
temp = size
ptr1 = $9327
ptr2 = ptr_to_file
loop:
A = (ptr1)
(ptr1) = (ptr2)
(prt2) = A
temp = temp - 1
ptr1 = ptr1 + 1
ptr2 = ptr2 + 1
while temp<>0 goto loop
return
[ -- end of pseudocode -- ]
Notes:
- this way of loading asm-files screwes up the VAT (while running the
program not all pointers in the VAT are correct)
- to run SOS programs you should use the SOS load-routine (or a look-a-like:
SwapByte can be used from SOS programs, some programs pop some regs which
are pushed here, lib-pointers point to space directly after the loader, so
the loader can't be any larger)