Instead of hardcoding the stack position (which could cause other problems)
Why don't you make sure that you unpop what you have pushed onto the stack?
By the way, if you are certain that the call to the interpreter will never exit, use a JMP and not a JSR, it will not add things to the stack
Equivalent of the NEW basic command ?
Re: Equivalent of the NEW basic command ?
Your idea is not bad
and I think in common your code is OK.
It can be made nicer and bit optimized in the part where you transfer command string
to $35, but this is another story. If you need to return to this assembler routine you can
intercept the 'Ready' vector at $1A, but if this is not needed your code will work.
![Smile :)](./images/smilies/icon_smile.gif)
It can be made nicer and bit optimized in the part where you transfer command string
to $35, but this is another story. If you need to return to this assembler routine you can
intercept the 'Ready' vector at $1A, but if this is not needed your code will work.
- Hialmar
- Flight Lieutenant
- Posts: 349
- Joined: Tue Mar 04, 2014 11:25 am
- Location: Toulouse, France
- Contact:
Re: Equivalent of the NEW basic command ?
Thanks to both of you.
I will replace the jsr with a jmp and see if it still works.
As for hard coding the stack pointer it's just that I don't know exactly what my C program put on the stack before this code. So well it's easier to hard code it. I have made sure the first value on the stack is still 0 as the Basic apparently needs this (at least that's what I understood from "l'Oric à Nu").
Anyway Dbug's solution would be more correct but it's also way more complex so...
I will replace the jsr with a jmp and see if it still works.
As for hard coding the stack pointer it's just that I don't know exactly what my C program put on the stack before this code. So well it's easier to hard code it. I have made sure the first value on the stack is still 0 as the Basic apparently needs this (at least that's what I understood from "l'Oric à Nu").
Anyway Dbug's solution would be more correct but it's also way more complex so...
-
- Squad Leader
- Posts: 774
- Joined: Sat May 21, 2011 7:21 pm
- Location: Between UK and France
- Contact:
Re: Equivalent of the NEW basic command ?
Hialmar wrote:Thanks to both of you.
I will replace the jsr with a jmp and see if it still works.
As for hard coding the stack pointer it's just that I don't know exactly what my C program put on the stack before this code. So well it's easier to hard code it. I have made sure the first value on the stack is still 0 as the Basic apparently needs this (at least that's what I understood from "l'Oric à Nu").
Anyway Dbug's solution would be more correct but it's also way more complex so...
Normally what your C code put on the stack should be predictable, and no function should left anything on the stack apart from, depending on the ABI (I need to check how the C compiler provide the return value of a function) possibly the return value of a C function.
My Projects: Replic'Oric Project - StratoCumulus Project
- Hialmar
- Flight Lieutenant
- Posts: 349
- Joined: Tue Mar 04, 2014 11:25 am
- Location: Toulouse, France
- Contact:
Re: Equivalent of the NEW basic command ?
Indeed as I said it's more a laziness problem ![Wink ;)](./images/smilies/icon_wink.gif)
I think I read on the OSDK pages that the C code uses another stack but I do use some ROM routines which may put things on the stack.
I could store the value of the SP at the beginning of my C program and restore it just before jumping to the Sedoric.
![Wink ;)](./images/smilies/icon_wink.gif)
I think I read on the OSDK pages that the C code uses another stack but I do use some ROM routines which may put things on the stack.
I could store the value of the SP at the beginning of my C program and restore it just before jumping to the Sedoric.
Re: Equivalent of the NEW basic command ?
The C compiler uses its own stack, pointed by the sp zero page variable and with a size of 256 bytes at the end of the generated code (I think it is on the tail.s file).
For returning values it uses registers X and A, not the 6502 stack.
AFAIK it should not upset the 6502 stack data.
For returning values it uses registers X and A, not the 6502 stack.
AFAIK it should not upset the 6502 stack data.