1-2: Accumulator and RM_TF_M MOD 00 R/M 110
This commit is contained in:
parent
1a7041ab9d
commit
15286389ad
2 changed files with 54 additions and 2 deletions
BIN
1-2/8086coded
BIN
1-2/8086coded
Binary file not shown.
|
|
@ -63,6 +63,48 @@ typedef struct
|
||||||
FILE *output;
|
FILE *output;
|
||||||
binary_data bin;
|
binary_data bin;
|
||||||
|
|
||||||
|
int MOV_MA_T_AM_parse(uint8_t byte1, uint8_t byte2, binary_data *binary, int bytes_read, bool is_M_T_A)
|
||||||
|
{
|
||||||
|
const uint8_t wide_mask = 0b0000'0001;
|
||||||
|
uint8_t extra_bytes_read;
|
||||||
|
unsigned char byte[1];
|
||||||
|
uint8_t acc_wide = 0;
|
||||||
|
uint8_t high_addr = 0;
|
||||||
|
uint16_t word_addr = byte2;
|
||||||
|
|
||||||
|
int disp_len = 0;
|
||||||
|
char ea_string[18] = {'\0'};
|
||||||
|
char *ea_string_write_ptr = ea_string;
|
||||||
|
|
||||||
|
//Immediate value retrieval
|
||||||
|
if (wide_mask & byte1)
|
||||||
|
{
|
||||||
|
fread(byte, sizeof(byte), 1, bin.binary);
|
||||||
|
extra_bytes_read++;
|
||||||
|
high_addr = (uint8_t)byte[0];
|
||||||
|
word_addr = word_addr + (high_addr << 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
//target reg retrieval
|
||||||
|
acc_wide = (((byte1 & wide_mask)) * 8);
|
||||||
|
|
||||||
|
//Stringify address
|
||||||
|
//EA STRING GENERATION
|
||||||
|
*ea_string_write_ptr = '[';
|
||||||
|
ea_string_write_ptr++;
|
||||||
|
disp_len = sprintf(ea_string_write_ptr, "%d", word_addr);
|
||||||
|
ea_string_write_ptr += disp_len;
|
||||||
|
*ea_string_write_ptr = ']';
|
||||||
|
//END
|
||||||
|
|
||||||
|
printf("%s %s, %s\n", "mov", is_M_T_A ? REG_ENCODING_TXT[acc_wide] : ea_string,
|
||||||
|
is_M_T_A ? ea_string : REG_ENCODING_TXT[acc_wide]);
|
||||||
|
fprintf(output, "%s %s, %s\n", "mov", is_M_T_A ? REG_ENCODING_TXT[acc_wide] : ea_string,
|
||||||
|
is_M_T_A ? ea_string : REG_ENCODING_TXT[acc_wide]);
|
||||||
|
|
||||||
|
return extra_bytes_read;
|
||||||
|
}
|
||||||
|
|
||||||
int MOV_I_T_R_parse(uint8_t byte1, uint8_t byte2, binary_data *binary, int bytes_read)
|
int MOV_I_T_R_parse(uint8_t byte1, uint8_t byte2, binary_data *binary, int bytes_read)
|
||||||
{
|
{
|
||||||
const uint8_t wide_mask = 0b0000'1000;
|
const uint8_t wide_mask = 0b0000'1000;
|
||||||
|
|
@ -266,8 +308,18 @@ int main(int argc, char** argv)
|
||||||
fread(byte, sizeof(byte), 1, bin.binary);
|
fread(byte, sizeof(byte), 1, bin.binary);
|
||||||
uint8_t manip_inst = (uint8_t)byte[0];
|
uint8_t manip_inst = (uint8_t)byte[0];
|
||||||
uint8_t inst = (uint8_t)byte[0];
|
uint8_t inst = (uint8_t)byte[0];
|
||||||
//We're checking for MOV RM_TF_R and MOV I_T_R
|
//We're checking for all MOV except segment registers
|
||||||
manip_inst = (manip_inst >> 2);
|
manip_inst = (manip_inst >> 1);
|
||||||
|
if (manip_inst == MOV_M_T_A || manip_inst == MOV_A_T_M)
|
||||||
|
{
|
||||||
|
if (bytes_read >= bin.size) break;
|
||||||
|
fread(byte, sizeof(byte), 1, bin.binary);
|
||||||
|
bytes_read++;
|
||||||
|
uint8_t inst_byte2 = (uint8_t)byte[0];
|
||||||
|
bytes_read += MOV_MA_T_AM_parse(inst, inst_byte2, 0, 0, (manip_inst == MOV_M_T_A));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
manip_inst = (manip_inst >> 1);
|
||||||
if (manip_inst == MOV_RM_TF_R)
|
if (manip_inst == MOV_RM_TF_R)
|
||||||
{
|
{
|
||||||
if (bytes_read >= bin.size) break;
|
if (bytes_read >= bin.size) break;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue