Any type of file IO causes errors with submit.com

Post Reply
sgjava
Member
Posts: 25
Joined: Thu Feb 22, 2024 9:25 pm

Any type of file IO causes errors with submit.com

Post by sgjava »

I've been playing with submit.com and noticed stat, fopen, etc. causes the next line of submit to fail. In this case it's just calling the same com file over and over. Without submit it works fine, so it's something in how the program is exiting when run from submit?

I'm running this on a C128. but I'll try MyZ80 next. I built z88dk from source a couple weeks ago.

Simple test case: https://github.com/sgjava/c3lz/blob/mai ... baseline.c
Submit file: https://github.com/sgjava/c3lz/blob/mai ... s/test.sub
Built with https://github.com/sgjava/c3lz/blob/a88 ... ild.sh#L30

Error on screen:

B>TEST

B>BASELINE
1024 BYTED READ

B>BASELINE

CP/M ERROR ON .: INVALID DRIVE
B>BASELINE

CP/M ERROR ON .: INVALID DRIVE
B>
User avatar
dom
Well known member
Posts: 2304
Joined: Sun Jul 15, 2007 10:01 pm

Re: Any type of file IO causes errors with submit.com

Post by dom »

For archive purposes this one is now fixed.

The issue was that we didn't bother to set sp on entry to the program. On CP/M 2.2 this is okay, since sp floats somewhere below the bdos address.

However on CP/M 3, sp on entry is some temporary workspace in high memory, so we end up overwriting bits of CP/M with the result that no future command actually works.

The fix is to do ld sp,(6) so do set sp to the address of bdos initially. This is now performed by the crt, but if you're not tracking nightly, this can be achieved with -pragma-define:REGISTER_SP=-6 as a link time option.
stefano
Well known member
Posts: 2328
Joined: Mon Jul 16, 2007 7:39 pm

Re: Any type of file IO causes errors with submit.com

Post by stefano »

"..it is always the stack". 😅
Post Reply