Skip to content

Store16 #1

@arcanis

Description

@arcanis

Hi,

First of all, great work! Your guide is very well written, kudos. I really hope you'll be able to finish it, good emulation guides are quite hard to find, and even more rare are those as clean as yours.

I have a small question about the store32/16/8 instructions:

I start with an empty function instead of copying the store32 code because different devices react differently when we change the transaction width. Some will pad the value to 32bits with zeroes, others may just set 16bits in the register and leave the others untouched. For this reason I’ll be conservative and add them only when needed.

Do you have more informations on this, maybe references? For example, can't we just do something like this (assuming a C code, which doesn't have generics)? Why?

void write_uint16(uint32_t addr, uint16_t value)
{
    uint32_t w_addr = addr & ~0b1;

    if (w_addr == addr) {
        write_uint32(w_addr, (read_uint32(w_addr) & 0xFFFF0000) | (value << 0));
    } else {
        write_uint32(w_addr, (read_uint32(w_addr) & 0x0000FFFF) | (value << 16));
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions