Sistemata size in insCode,Stack,Data
This commit is contained in:
parent
fd45b5c54f
commit
f78fe540dd
@ -24,6 +24,7 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
bytecode = new uint8_t[bytecode_size];
|
||||
bytecode_if.read((char *)bytecode, bytecode_size);
|
||||
printf("SIZE READ: %d\n", bytecode_size);
|
||||
VM vm((uint8_t *)argv[1], bytecode, bytecode_size);
|
||||
vm.run();
|
||||
return 0;
|
||||
|
@ -175,6 +175,7 @@ bool VM::execMOVI(void) {
|
||||
uint16_t imm;
|
||||
dst = as.code[regs[IP] + 1];
|
||||
imm = *((uint16_t *)&as.code[regs[IP] + 2]);
|
||||
printf("IP: 0x%x | dst: 0x%x | imm: 0x%x\n", regs[IP], dst, imm);
|
||||
DBG_INFO(("MOVI %s, 0x%x\n", getRegName(dst), imm));
|
||||
if (dst == IP) {
|
||||
DBG_ERROR(("Can't MOVI to IP!\n"));
|
||||
|
@ -54,8 +54,9 @@ bool VMAddrSpace::allocate(void) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool VMAddrSpace::insCode(uint8_t *buf, uint8_t size) {
|
||||
bool VMAddrSpace::insCode(uint8_t *buf, uint32_t size) {
|
||||
if (code) {
|
||||
printf("SIZE IN insCode: %d\n", size);
|
||||
DBG_INFO(("Copying buffer into code section.\n"));
|
||||
memcpy(code, buf, size);
|
||||
} else {
|
||||
@ -65,7 +66,7 @@ bool VMAddrSpace::insCode(uint8_t *buf, uint8_t size) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool VMAddrSpace::insStack(uint8_t *buf, uint8_t size) {
|
||||
bool VMAddrSpace::insStack(uint8_t *buf, uint32_t size) {
|
||||
if (stack) {
|
||||
DBG_INFO(("Copying buffer into stack section.\n"));
|
||||
memcpy(stack, buf, size);
|
||||
@ -76,7 +77,7 @@ bool VMAddrSpace::insStack(uint8_t *buf, uint8_t size) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool VMAddrSpace::insData(uint8_t *buf, uint8_t size) {
|
||||
bool VMAddrSpace::insData(uint8_t *buf, uint32_t size) {
|
||||
if (this->code) {
|
||||
DBG_INFO(("Copying buffer into data section.\n"));
|
||||
memcpy(data, buf, size);
|
||||
|
@ -14,9 +14,9 @@ public:
|
||||
VMAddrSpace(uint32_t ss, uint32_t cs, uint32_t ds);
|
||||
uint8_t *stack, *code, *data;
|
||||
bool allocate(void);
|
||||
bool insStack(uint8_t *buf, uint8_t size);
|
||||
bool insCode(uint8_t *buf, uint8_t size);
|
||||
bool insData(uint8_t *buf, uint8_t size);
|
||||
bool insStack(uint8_t *buf, uint32_t size);
|
||||
bool insCode(uint8_t *buf, uint32_t size);
|
||||
bool insData(uint8_t *buf, uint32_t size);
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user