CAR: added stack operations, call, ret, jmp and some other random stuff
This commit is contained in:
13
helpers.c
13
helpers.c
@ -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]);
|
||||
|
||||
Reference in New Issue
Block a user