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

Reusing a static FCB for several file operations #109

Closed
venomix666 opened this issue Jan 6, 2024 · 3 comments
Closed

Reusing a static FCB for several file operations #109

venomix666 opened this issue Jan 6, 2024 · 3 comments

Comments

@venomix666
Copy link
Contributor

I have an issue in vt52term, where I reuse a global static FCB struct for opening files for both sending and receiving with Xmodem. If I only open/close the files, I get strange behavior such as the file position from the previous file being remembered when opening a new file.

I currently have a working fix where I use memset to zero the entire FCB before starting a new file operation. This works fine, but is this the way it is intended to be done? I tried just setting ex to zero, but this did not solve the problem.

I guess this boils down to two questions:

  1. Is it expected that the FCB must be cleared between a close and open operation, or is this a bug in the BDOS?
  2. If it needs to be cleared, it a complete zeroing with memset needed or is there a smarter way to do this?
@davidgiven
Copy link
Owner

You do need to clear some. I don't know why they're not cleared for you. See F_OPEN here: https://www.seasip.info/Cpm/bdos.html EX, S1, S2, RC and CR are the ones specified in the documentation. S2 is cleared for you in the code but I forget why.

For clearing the whole structure... memset and fcb = {} should be equivalent in C. Really they should both produce a tiny embedded loop as that'd be more efficient than calling out to a function but I don't know whether llvm-mos does that or not.

@venomix666
Copy link
Contributor Author

Thanks for the clarification, then it is just my poor knowledge of CP/M which is the issue. I assumed that cpm_file_close would set up the FCB used by fcb_file_open or fcb_file_create for a new file.

The fcb = {} syntax is more elegant for sure. I am still getting used to these 'modern' (i.e. anything not supported by Watcom ;) ) additions to C.

@venomix666
Copy link
Contributor Author

Closed by #115

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants