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

Refactoring of fileio.s #40

Open
mlund opened this issue Jul 26, 2023 · 2 comments
Open

Refactoring of fileio.s #40

mlund opened this issue Jul 26, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@mlund
Copy link
Collaborator

mlund commented Jul 26, 2023

Subroutines in fileio.s overlaps with C functions:

  1. mega65_io_enable()
  2. lcopy()
  3. Copying filename to 0x0100 could be done directly from C. Is it safe to override 0x0100 for temporary storage for setname?

Using C for the above, fileio.s becomes smaller; could be inline; and reduce compiler specific code.

Ping @ki-bo.

Notes

size_t read512(uint8_t* buffer)
{
    volatile size_t len;
    asm volatile("lda 0x1a\n"
                 "sta 0xd640\n"
                 "nop\n"
                 "stx %0\n"
                 "sty %1\n"
                 "lda 0x80\n"
                 "tsb 0xD689\n"
                 : "+r"(*(&len + 0)), "+r"(*(&len + 1))
                 :
                 : "a", "x", "y");
    lcopy(0xFFD6E00, (uint32_t)buffer, 512);
    return len;
}
@mlund mlund added the enhancement New feature or request label Jul 26, 2023
@ki-bo
Copy link
Member

ki-bo commented Jan 5, 2024

Copying the filename to 0x100 will often work, but be aware that this is by default the stack page, so you may overwrite the stack depending on where the stack pointer is and how long the filename will be.

@mlund
Copy link
Collaborator Author

mlund commented Jan 11, 2024

Thanks! Mega65libc has always been hardcoded to $0100 and I wonder if there are better alternatives, e.g. by dynamic allocation. If I recall correctly the hypervisor has restrictions as to where it can be placed(?).

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
None yet
Development

No branches or pull requests

2 participants