Formatting of regular insstructions...

This commit is contained in:
xolatile 2024-07-01 22:54:37 -04:00
parent aec61241e7
commit eac867607d
2 changed files with 43 additions and 9 deletions

View File

@ -1,12 +1,43 @@
#include "assembler.h"
static void byte_push (byte data) {
byte_array [byte_count] = data;
byte_count += 1;
}
static void assemble_xor (size_index size,
type_index type,
size_t destination,
size_t source) {
// ERROR CHECKING
form destination,
form source) {
byte set = 0;
byte mod = 0;
// byte_array [byte_count] = ...;
if (size == size_256b) exit (EXIT_FAILURE);
if (size == size_128b) exit (EXIT_FAILURE);
// byte_count += ...;
if (size == size_64b) byte_push (0X48);
switch (type) {
case type_register_register: set += 0X30; break;
case type_register_variable: set += 0X32; break;
case type_register_constant: set += 0X80; break;
case type_variable_register: set += 0X30; break;
case type_variable_constant: set += 0X80; break;
default: exit (EXIT_FAILURE);
}
if (size != size_8b) set += 1;
if ((type == type_register_constant) && (destination == 0)) set += 4;
byte_push (set);
// FORMAT MOD/SIB BYTE IF NEEDED...
byte_push (mod);
// FORMAT MEMORY OR IMMEDIATE IF NEEDED...
// ...
}

View File

@ -66,15 +66,18 @@ typedef enum {
command_length
} command_index;
typedef unsigned int data;
typedef signed int form;
typedef unsigned int next;
typedef unsigned char byte;
static data byte_count = 0;
static next byte_count = 0;
static byte * byte_array = NULL;
static void byte_push (byte data);
static void assemble_xor (size_index size,
type_index type,
size_t destination,
size_t source);
form destination,
form source);
#endif