50 lines
733 B
C
50 lines
733 B
C
|
|
/*
|
||
|
|
* 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
|
||
|
|
}
|