fix endianess
This commit is contained in:
parent
39b6a1f15f
commit
244baf55f1
14
src/vm.c
14
src/vm.c
|
@ -53,11 +53,11 @@ int core_dump() {
|
|||
}
|
||||
|
||||
uint8_t get_char(uint32_t word, int index) {
|
||||
return (word >> (8 * (3 - index))) & 0xFF;
|
||||
return (word >> (8 * index)) & 0xFF;
|
||||
}
|
||||
|
||||
uint32_t set_char(uint32_t word, int index, uint8_t ch) {
|
||||
return (word & ~(0xFF << (8 * (3 - index)))) | (ch << (8 * (3 - index)));
|
||||
return (word & ~(0xFF << (8 * index))) | (ch << (8 * index));
|
||||
}
|
||||
|
||||
/* Pack string into union-based memory */
|
||||
|
@ -148,7 +148,7 @@ void run_vm() {
|
|||
break;
|
||||
}
|
||||
case OP_INT_TO_F32: {
|
||||
int tmp = memory[src1_addr].u;
|
||||
uint32_t tmp = memory[src1_addr].u;
|
||||
memory[dest_addr].f = (float)tmp;
|
||||
break;
|
||||
}
|
||||
|
@ -262,6 +262,14 @@ int main() {
|
|||
memory[i++].u = 105;
|
||||
memory[i++].u = 0;
|
||||
memory[i++].u = 0;
|
||||
memory[i++].u = OP_READ_STRING;
|
||||
memory[i++].u = 0;
|
||||
memory[i++].u = 0;
|
||||
memory[i++].u = 109;
|
||||
memory[i++].u = OP_PRINT_STRING;
|
||||
memory[i++].u = 110;
|
||||
memory[i++].u = 0;
|
||||
memory[i++].u = 0;
|
||||
memory[i++].u = OP_HALT;
|
||||
memory[100].u = 5;
|
||||
memory[101].u = 1;
|
||||
|
|
Loading…
Reference in New Issue