Updated assembler, 32 new instructions...

This commit is contained in:
xolatile
2024-07-05 17:33:34 -04:00
parent 32393fa0f0
commit 0d660b1c45
3 changed files with 46 additions and 16 deletions

@ -4,19 +4,25 @@
#include "../source/assembler.h"
#include "../source/assembler.c"
static unsigned int array [29] = {
#define COUNT (29+24)
static unsigned int array [COUNT] = {
ADC, D64, REG, R1, REG, R2,
ADC, D32, REG, R1, MEM, 12,
ADC, D16, MEM, 12, REG, R10,
ADC, D8, REG, R3, IMM, 0X77,
INC, D16, REG, R0, LOCK
INC, D16, REG, R0, LOCK,
CMOVG, D64, REG, R1, REG, R1,
CMOVG, D64, REG, R1, REG, R9,
CMOVG, D64, REG, R9, REG, R1,
CMOVG, D64, REG, R9, REG, R9
};
int main (void) {
unsigned int index;
token_array = malloc (144UL * sizeof (* token_array));
assemble (29, array);
assemble (COUNT, array);
printf ("> %u\n", token_count);

@ -426,7 +426,28 @@ nnn: nop
nop
cmovo rcx, r9
nop
cmovg rcx, r9
cmovg rcx, r9 ; 49 0F 4F C9
nop
xor rcx, rcx
nop
xor r9, rcx;+1
nop
xor rcx, r9;+4
nop
xor r9, r9;+1+4
nop
nop
nop
nop
cmovg rcx, rcx; 48 0F 4F C9
nop
cmovg rcx, r9; 49 0F 4F C9
nop
cmovg r9, rcx; 4C 0F 4F C9
nop
cmovg r9, r9; 4D 0F 4F C9
nop

@ -97,8 +97,8 @@ static void build_long_prefix (form use_big_registers,
/* */
place (use_big_registers || use_new_destination || use_new_source,
(byte) (0X40
+ 0X01 * use_new_destination
+ 0X04 * use_new_source
+ 0X01 * use_new_source
+ 0X04 * use_new_destination
+ 0X08 * use_big_registers));
}
@ -139,8 +139,8 @@ static void build_regular (operation_index operation,
build_short_prefix (size == D16);
build_long_prefix (size == D64,
(to == REG) && (upper (destination)),
(from == REG) && (upper (source)));
(to == REG) && (upper ((form) destination)),
(from == REG) && (upper ((form) source)));
build_constant (from == IMM, size);
@ -167,7 +167,7 @@ static void build_irregular (operation_index operation,
build_short_prefix (size == D16);
build_long_prefix (size == D64,
(to == REG) && (upper (destination)), 0);
(to == REG) && (upper ((form) destination)), 0);
place (1, (byte) (0XF6
+ 0X08 * ((operation == INC) || (operation == DEC))
@ -219,12 +219,15 @@ static void build_jump_if (operation_index operation,
static void build_move_if (operation_index operation,
size_index size,
type_index to,
next destination) {
next destination,
type_index from,
next source) {
/* */
build_short_prefix (size == D16);
build_long_prefix (size == D64,
(to == REG) && (upper (destination)), 0);
(to == REG) && (upper ((form) destination)),
(from == REG) && (upper ((form) source)));
place (1, 0X0F);
place (1, (byte) (0X40 + operation - MOVE_IF_BEGIN));
@ -270,11 +273,11 @@ void assemble (next count,
build_jump_if (array [index + 0], array [index + 1],
array [index + 2]);
index += 2;
} else if ((array [index] >= SPECIAL_2_BEGIN)
&& (array [index] <= SPECIAL_2_END)) {
build_special_2 (array [index + 0], array [index + 1],
array [index + 2], array [index + 3],
array [index + 4], array [index + 5]);
} else if ((array [index] >= MOVE_IF_BEGIN)
&& (array [index] <= MOVE_IF_END)) {
build_move_if (array [index + 0], array [index + 1],
array [index + 2], array [index + 3],
array [index + 4], array [index + 5]);
index += 5;
}
}