Add partial support for 8-bit loads

We're big-endian.
when we have this in memory:

00 01 02 03

And we need the first byte, we load the first 16-bit word:

0x0001

The first byte is then in the upper part of the word, and requires
a right shift by 8.
So any load into an 8-bit typed container needs to shift stuff.

So far, stores from/to the stack are exempted, they always load/store
full 16-bit words.

And a few othe rminor things. Like string null terminators.
And escaped characters in character literals.

Can you believe it's spelled 'literal', with a single t?
Me neither.
This commit is contained in:
Paul Mathieu
2021-03-18 08:35:23 -07:00
parent 5612f23181
commit b70cdd13c4
4 changed files with 29 additions and 8 deletions

View File

@@ -9,11 +9,11 @@ void init() {
}
int main() {
led0->output = 37;
init();
led0->output = 42;
while(1) {
led0->output = 42;
uint8_t c = uart_read(uart0);
uint16_t period;
if (c == 'c') {
@@ -44,6 +44,8 @@ int main() {
period = 791; // B4, 493.88 Hz, maybe
uart_writen(uart0, "B4\r\n", 4);
led0->output = 64;
} else {
led0->output = 37;
}
square0->period = period;