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

fread and fwrite works only with ADL pointers #66

Closed
nihirash opened this issue Apr 17, 2024 · 3 comments
Closed

fread and fwrite works only with ADL pointers #66

nihirash opened this issue Apr 17, 2024 · 3 comments

Comments

@nihirash
Copy link
Contributor

I can open file by 16 bit pointer in legacy cpu mode but when I'll try read or write to buffer from non-ADL mode I'm getting failure - cause API works only with full ADL pointers.

As current workaround I'm using prefixed LD command(LD.LIL) but best solution will be making API consistent and allow use fread and fwrite with non-ADL pointers(when MB isn't equal zero).

@calc84maniac
Copy link

I'd also like to add to this that ffs_api_fread and ffs_api_fwrite unnecessarily destroy a shadow register which isn't really noted in the API (and no other APIs, or anything in MOS in general, seem to do this).

This code sequence:

			EXX		
			LD	HL, _scratchpad
			PUSH	HL
			EXX

Could be replaced with this sequence, which is also smaller:

			PUSH	HL
			LD	HL, _scratchpad
			EX	(SP), HL

stevesims added a commit that referenced this issue Nov 24, 2024
@stevesims
Copy link
Contributor

as I'm currently digging around in the MOS API implementation code I've taken a look at this. I can confirm that it looks like mos_fread and mos_fwrite both weren't adjusting the pointer argument in HL to be 24-bit compatible. I've looked around a bit further than I think they may be the only APIs that had that oversight - everywhere else I've looked so far is ensuring that registers with pointers are made 24-bit compatible. doh!

also the fatfs versions of fread and write were also both the only places in the code that were using EXX

I just added a commit to #91 that addresses these issues

I might end up back-porting these to 2.3, as MOS 3 is probably still quite a while away from release

stevesims added a commit that referenced this issue Nov 29, 2024
stevesims added a commit that referenced this issue Nov 29, 2024
@stevesims
Copy link
Contributor

These fixes got back-ported, and released as part of MOS 2.3.2

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

3 participants