gbasm: do not differentiate immediate bit lengths
Instead, treat them simply as values. Specific instructions can determine if their values are valid or representable.
This commit is contained in:
@@ -10,11 +10,10 @@
|
|||||||
enum gbasm_operand_type {
|
enum gbasm_operand_type {
|
||||||
GBASM_OPERAND_REG_8 = 0x01, /* A, B, etc */
|
GBASM_OPERAND_REG_8 = 0x01, /* A, B, etc */
|
||||||
GBASM_OPERAND_REG_16 = 0x02, /* BC, DE, etc */
|
GBASM_OPERAND_REG_16 = 0x02, /* BC, DE, etc */
|
||||||
GBASM_OPERAND_IMM_8 = 0x04, /* $08, $FF */
|
GBASM_OPERAND_IMM = 0x04, /* $08, $FF */
|
||||||
GBASM_OPERAND_IMM_16 = 0x08, /* $FF40, $0100 */
|
GBASM_OPERAND_ADDR = 0x08, /* START, */
|
||||||
GBASM_OPERAND_ADDR = 0x10, /* START, */
|
GBASM_OPERAND_DEREF = 0x10, /* (HL), (HL+) */
|
||||||
GBASM_OPERAND_DEREF = 0x20, /* (HL), (HL+) */
|
GBASM_OPERAND_COND = 0x20, /* C, NZ, etc */
|
||||||
GBASM_OPERAND_COND = 0x40, /* C, NZ, etc */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum gbasm_operand_r8_type {
|
enum gbasm_operand_r8_type {
|
||||||
@@ -43,11 +42,7 @@ struct gbasm_operand_r16 {
|
|||||||
enum gbasm_operand_r16_type type;
|
enum gbasm_operand_r16_type type;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct gbasm_operand_d8 {
|
struct gbasm_operand_imm {
|
||||||
uint8_t value;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct gbasm_operand_d16 {
|
|
||||||
uint16_t value;
|
uint16_t value;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -69,8 +64,7 @@ struct gbasm_operand {
|
|||||||
union {
|
union {
|
||||||
struct gbasm_operand_r8 r8;
|
struct gbasm_operand_r8 r8;
|
||||||
struct gbasm_operand_r16 r16;
|
struct gbasm_operand_r16 r16;
|
||||||
struct gbasm_operand_d8 d8;
|
struct gbasm_operand_imm imm;
|
||||||
struct gbasm_operand_d16 d16;
|
|
||||||
struct gbasm_operand_cond cond;
|
struct gbasm_operand_cond cond;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -137,17 +137,10 @@ static const struct gbasm_operand_info gbasm_operand_infos[] = {
|
|||||||
|
|
||||||
static int convert_constant(const char *token, struct gbasm_operand *info)
|
static int convert_constant(const char *token, struct gbasm_operand *info)
|
||||||
{
|
{
|
||||||
int val = strtol(token + 1, NULL, 0);
|
long val = strtol(token + 1, NULL, 0);
|
||||||
|
|
||||||
if (val <= 0xff || val >= -0xff) {
|
info->type = GBASM_OPERAND_IMM;
|
||||||
info->type = GBASM_OPERAND_IMM_8;
|
info->imm.value = val;
|
||||||
info->d8.value = val;
|
|
||||||
} else if (val <= 0xffff || val >= 0xffff) {
|
|
||||||
info->type = GBASM_OPERAND_IMM_16;
|
|
||||||
info->d16.value = val;
|
|
||||||
} else {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user