CAR: added stack operations, call, ret, jmp and some other random stuff
This commit is contained in:
49
misc.c
Normal file
49
misc.c
Normal file
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Source file for miscellaneous operations.
|
||||
*
|
||||
* CAR (Cool ARM Ripoff) copyright (c) 2026 David J Goeke. All rights reserved.
|
||||
* Unauthorized (re)distribution is prohibited.
|
||||
*/
|
||||
|
||||
#include "include/defs.h"
|
||||
|
||||
|
||||
DEFINE_OP(nop)
|
||||
{
|
||||
OP_RETURN_NORMAL
|
||||
}
|
||||
|
||||
DEFINE_OP(call)
|
||||
{
|
||||
misc_instruction_t i = convert_raw2misc(ri);
|
||||
|
||||
_push(state->pc + 1, state);
|
||||
|
||||
uint32_t addr = (uint32_t) (state->pc + (int32_t) i.imm);
|
||||
|
||||
state->pc = addr;
|
||||
|
||||
OP_RETURN_NO_INC_PC
|
||||
}
|
||||
|
||||
DEFINE_OP(ret)
|
||||
{
|
||||
uint32_t r_addr;
|
||||
|
||||
_pop(&r_addr, state);
|
||||
|
||||
state->pc = r_addr;
|
||||
|
||||
OP_RETURN_NO_INC_PC
|
||||
}
|
||||
|
||||
DEFINE_OP(jmp)
|
||||
{
|
||||
misc_instruction_t i = convert_raw2misc(ri);
|
||||
|
||||
uint32_t addr = (uint32_t) (state->pc + (int32_t) i.imm);
|
||||
|
||||
state->pc = addr;
|
||||
|
||||
OP_RETURN_NO_INC_PC
|
||||
}
|
||||
Reference in New Issue
Block a user