Equivalent of the NEW basic command ?

Since we do not have native C compilers on the Oric, this forum will be mostly be used by people using CC65 or the OSDK. But any general C related post will be welcome !
Godzil
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 ?

Post by Godzil »

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
User avatar
iss
Wing Commander
Posts: 1637
Joined: Sat Apr 03, 2010 5:43 pm
Location: Bulgaria
Contact:

Re: Equivalent of the NEW basic command ?

Post by iss »

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.
User avatar
Hialmar
Flight Lieutenant
Posts: 349
Joined: Tue Mar 04, 2014 11:25 am
Location: Toulouse, France
Contact:

Re: Equivalent of the NEW basic command ?

Post by Hialmar »

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...
Hialmar
CEO and Silicium member.
Godzil
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 ?

Post by Godzil »

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.
User avatar
Hialmar
Flight Lieutenant
Posts: 349
Joined: Tue Mar 04, 2014 11:25 am
Location: Toulouse, France
Contact:

Re: Equivalent of the NEW basic command ?

Post by Hialmar »

Indeed as I said it's more a laziness problem ;)

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.
Hialmar
CEO and Silicium member.
User avatar
Chema
Game master
Posts: 3013
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Re: Equivalent of the NEW basic command ?

Post by Chema »

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.
Post Reply