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

Could use more dword-addressable memory. #155

Open
basvs opened this issue Jul 28, 2017 · 0 comments
Open

Could use more dword-addressable memory. #155

basvs opened this issue Jul 28, 2017 · 0 comments

Comments

@basvs
Copy link
Contributor

basvs commented Jul 28, 2017

Free up more 8-bit addressable memory.

Experimental, untested byte getter and setter methods:

uint8_t
u32_get_byte(uint8_t *ptr)
{
    intptr_t _ptr = (intptr_t) ptr;
    uint32_t *ptr_u32 = (uint32_t *) (_ptr & ~3);
    return (*ptr_u32 >> ((_ptr & 3) << 3)) & 0xff
}

void
u32_set_byte(uint8_t *ptr, uint8_t value)
{
    intptr_t _ptr = (intptr_t) ptr;
    uint32_t *ptr_u32 = (uint32_t *) (_ptr & ~3);
    uint32_t u32 = *ptr_u32;
    u32 &= ~( 0xff << ((_ptr & 3) << 3) );
    u32 |= value << ((_ptr & 3) << 3);
    *ptr_u32 = u32;
}   
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

1 participant