CAR: added stack operations, call, ret, jmp and some other random stuff

This commit is contained in:
2026-07-18 19:28:11 -05:00
parent 5902eae153
commit 1f11242762
10 changed files with 294 additions and 20 deletions

View File

@ -4,10 +4,23 @@
* CAR (Cool ARM Ripoff) copyright (c) 2026 David J Goeke. All rights reserved.
* Unauthorized (re)distribution is prohibited.
*/
#include <string.h>
#include <stdio.h>
#include "include/defs.h"
void _push(uint32_t v, pstate_t* state)
{
state->sp--;
memcpy(state->memory + state->sp, &v, sizeof(v));
}
void _pop(uint32_t* a, pstate_t* state)
{
memcpy(a, state->memory + state->sp, sizeof(*a));
state->sp++;
}
void dump_regs(pstate_t* s)
{
printf("r0: 0x%08x r1: 0x%08x r2: 0x%08x, r3: 0x%08x\n", s->gprs[0], s->gprs[1], s->gprs[2], s->gprs[3]);