Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mos_fopen returns 0 after bbcbasic exits #31

Closed
envenomator opened this issue Mar 20, 2023 · 3 comments
Closed

mos_fopen returns 0 after bbcbasic exits #31

envenomator opened this issue Mar 20, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@envenomator
Copy link
Contributor

Hi Dean,

An ADL=1 binary, written in C with the standard init.asm from the 'Hello World' example, that opens a file using the bare minimum assembly code for mos_fopen, mos_fopen only works when no bbcbasic.bin has been running previously.
After *bye from bbcbasic, mos_fopen just returns 0
Before running bbcbasic, manually, or from the autoexec.txt, mos_fopen returns a valid filehandle.

I'm attaching a minimalistic example that just fopens/fcloses 'autoexec.txt', and does it statically to avoid using the C arg parser. But opening other existing files behave similarly.
fopenbug.zip

I have reverted back to running MOS 1.02/VDP 1.02 and also tried bbcbasic 1.02/1.03/1.04.
Thnx!

@envenomator
Copy link
Contributor Author

envenomator commented Mar 20, 2023

I think I have found the culprit. I used the latest C init.asm, but that isn't saving the MBASE register to stack.
When I save it before main and clear it / recover it from stack after main, everything works as it should.

@breakintoprogram
Copy link
Owner

Issue: In misc.asm

_exec16 preserves MB as it changes it to run 16-bit applications
_exec24 doesn't bother as it does not change MB

Preserve the register in case 24-bit apps change MB

@breakintoprogram breakintoprogram added the enhancement New feature or request label Mar 20, 2023
@envenomator
Copy link
Contributor Author

Several MOS calls check the value in MBASE. For 24-bit apps calling to MOS API, it's more important that they set MBASE to 0, or get it set to 0 before starting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Released
Development

No branches or pull requests

2 participants