diff options
Diffstat (limited to 'ecomp-c/asm-i386.c')
-rw-r--r-- | ecomp-c/asm-i386.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/ecomp-c/asm-i386.c b/ecomp-c/asm-i386.c index a796398..62e15ca 100644 --- a/ecomp-c/asm-i386.c +++ b/ecomp-c/asm-i386.c @@ -46,6 +46,7 @@ * use32 * org 0x0000 * dd 0x0000 + * db 0x00 */ /* constants */ @@ -497,6 +498,11 @@ static void Emit_char( int c ) fputc( c, stdout ); } +static void Emit_byte( int d ) +{ + Emit_char( ( d & 0xFF ) ); +} + static void Emit_double_little_endian( int d ) { Emit_char( ( d & 0xFF ) ); @@ -595,6 +601,7 @@ static Symbol *parseLabel( void ) typedef enum { OPCODE_PSEUDO_ORG, OPCODE_PSEUDO_DD, + OPCODE_PSEUDO_DB, OPCODE_MOV, OPCODE_PUSH, OPCODE_POP, @@ -617,6 +624,7 @@ typedef enum { static char *opcodename[OPCODE_UNKNOWN+1] = { "org", "dd", + "db", "mov", "push", "pop", @@ -711,6 +719,10 @@ static OpcodeInfo *parseOpcode( void ) opcode_info->opcode = OPCODE_PSEUDO_DD; opcode_info->nof_operands = 1; opcode_info->size = 4; + } else if( strcmp( ident, "db" ) == 0 ) { + opcode_info->opcode = OPCODE_PSEUDO_DB; + opcode_info->nof_operands = 1; + opcode_info->size = 1; } else if( strcmp( ident, "div" ) == 0 ) { opcode_info->opcode = OPCODE_DIV; opcode_info->nof_operands = 1; @@ -934,6 +946,7 @@ static void parseOperands( OpcodeInfo *opcode_info ) switch( opcode_info->opcode ) { case OPCODE_HLT: case OPCODE_PSEUDO_DD: + case OPCODE_PSEUDO_DB: break; case OPCODE_MOV: if( opcode_info->operand->type == OPERAND_REGISTER && @@ -1280,6 +1293,7 @@ static void compute_addresses( OpcodeInfo *opcode_info ) break; case OPCODE_PSEUDO_DD: + case OPCODE_PSEUDO_DB: case OPCODE_MOV: case OPCODE_PUSH: case OPCODE_POP: @@ -1362,6 +1376,9 @@ static void emit_opcode( OpcodeInfo *opcode_info ) case OPCODE_PSEUDO_DD: Emit_double_little_endian( opcode_info->operand->num ); break; + case OPCODE_PSEUDO_DB: + Emit_byte( opcode_info->operand->num ); + break; case OPCODE_HLT: Emit( "%c", 0xF4 ); break; |