radare2/libr/vm/stack.c
pancake c5e588e6e5 * Initial import of libr
- Previous commits has been reported in the ChangeLog file
  - hg log has been lost (moved inside ChangeLog)
  - Old radare1 repository has removed all the libr
2009-02-05 22:08:46 +01:00

25 lines
669 B
C

/* radare - LGPL - Copyright 2008-2009 pancake<nopcode.org> */
#include "r_vm.h"
#include "list.h"
void r_vm_stack_push(struct r_vm_t *vm, u64 _val)
{
// XXX determine size of stack here
// XXX do not write while emulating zomfg
u32 val = _val;
vm_reg_set(vm, vm_cpu.sp, vm_reg_get(vm, vm_cpu.sp)+4);
vm_mmu_write(vm, vm_reg_get(vm, vm_cpu.sp), &val, 4);
}
void r_vm_stack_pop(struct r_vm_t *vm, const char *reg)
{
u32 val = 0;
if (vm_mmu_read(vm_reg_get(vm, vm->cpu.sp), &val, 4))
return;
//printf("POP (%s)\n", reg);
vm_mmu_read(vm, vm_reg_get(vm, vm->cpu.sp), &val, 4);
vm_reg_set(vm, reg, val);
vm_reg_set(vm_cpu.sp, vm_reg_get(vm, vm->cpu.sp)-4);
}