From 62e45181500d82556245c2e737ce996d0c420b19 Mon Sep 17 00:00:00 2001 From: xolatile Date: Thu, 25 Jul 2024 07:59:18 -0400 Subject: [PATCH] Synchronizing the changes... --- source/assembler.c | 18 ++++++++++-------- test/india.eax | 15 +++++++++++++++ 2 files changed, 25 insertions(+), 8 deletions(-) create mode 100644 test/india.eax diff --git a/source/assembler.c b/source/assembler.c index 6e35afa..d5f2b1c 100644 --- a/source/assembler.c +++ b/source/assembler.c @@ -118,6 +118,8 @@ static void build_regular (unsigned int operation, unsigned int size, unsigned i || ((to == REG) && (from == IMM) && front (destination))), 0x40); + input ((from == IMM) && (to == REG), 0x81 - 0x01 * (size == D8)); + input ((from == IMM) && (to == REG) && (destination == 0), 0x05 + 0x08 * (operation & 0x07) - 0x01 * (size == D8)); input (! ((from == IMM) && (to == REG) && (destination == 0)), @@ -135,12 +137,12 @@ static void build_regular (unsigned int operation, unsigned int size, unsigned i modify_memory (destination, to, from); modify_memory (source, to, from); - input_at ((to == REG) && (from == MEM), D32, source, 0x1000); + input_at ((to == REG) && (from == MEM), D32, source, 0x1000 - (text_sector_size + 4)); input_by ((to == REG) && (from == IMM), size, source); - input_at ((to == MEM) && (from == REG), D32, destination, 0x1000); - input_at ((to == MEM) && (from == IMM), D32, destination, 0x1000); + input_at ((to == MEM) && (from == REG), D32, destination, 0x1000 - (text_sector_size + 4)); + input_at ((to == MEM) && (from == IMM), D32, destination, 0x1000 - (text_sector_size + 4)); input_by ((to == MEM) && (from == IMM), size, source); - input_at ((to == REG) && (from == REL), D32, source, 0x4010b0); + input_at ((to == REG) && (from == REL), D32, source, 0x4010b0 - (text_sector_size + 4)); } static void build_irregular (unsigned int operation, unsigned int size, unsigned int to, unsigned int destination) { @@ -155,7 +157,7 @@ static void build_irregular (unsigned int operation, unsigned int size, unsigned input (to == REG, 0xc0 + 0x08 * (operation - IRREGULAR_BEGIN) + 0x01 * (destination & 0x07)); input (to == MEM, 0x05 + 0x08 * (operation - IRREGULAR_BEGIN)); - input_at (to == MEM, D32, destination, 0x1000); + input_at (to == MEM, D32, destination, 0x1000 - (text_sector_size + 4)); } static void build_special_1 (unsigned int operation) { @@ -232,10 +234,10 @@ static void build_move (unsigned int size, unsigned int to, unsigned int destina input ((to == MEM) && (from == IMM), 0xc6 + 0x01 * (size != D8)); input ((to == MEM) && (from == IMM), 0x05); - input_at ((to == REG) && (from == MEM), D32, source, 0x1000); + input_at ((to == REG) && (from == MEM), D32, source, 0x1000 - (text_sector_size + 4)); input_by ((to == REG) && (from == IMM), size, source); - input_at ((to == MEM) && (from == REG), D32, destination, 0x1000); - input_at ((to == MEM) && (from == IMM), D32, destination, 0x1000); + input_at ((to == MEM) && (from == REG), D32, destination, 0x1000 - (text_sector_size + 4)); + input_at ((to == MEM) && (from == IMM), D32, destination, 0x1000 - (text_sector_size + 4)); input_by ((to == MEM) && (from == IMM), size, source); input_at ((to == REG) && (from == REL), D32, source, 0x4010b0); diff --git a/test/india.eax b/test/india.eax new file mode 100644 index 0000000..3700d99 --- /dev/null +++ b/test/india.eax @@ -0,0 +1,15 @@ +unix program hello + s8 <> message = "Hello, world!" +begin + mov ebx 0 + mov edi 1 + mov esi message + mov edx 13 + india: + mov eax 1 + syscall + inc ebx + cmp ebx 1000000 + jne india + exit 0 +end program