Mercurial > hg > qcc
changeset 385:14ff3d95e91b
[project @ 2005-09-03 22:03:39 by bellard]
segment override prefix support (Filip Navara)
author | bellard |
---|---|
date | Sat, 03 Sep 2005 22:03:39 +0000 |
parents | 7242363aa96d |
children | df250e9d55a8 |
files | i386-asm.c |
diffstat | 1 files changed, 26 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/i386-asm.c Sat Sep 03 21:54:47 2005 +0000 +++ b/i386-asm.c Sat Sep 03 22:03:39 2005 +0000 @@ -151,6 +151,15 @@ 0x0f, /* g */ }; +static const uint8_t segment_prefixes[] = { + 0x26, /* es */ + 0x2e, /* cs */ + 0x36, /* ss */ + 0x3e, /* ds */ + 0x64, /* fs */ + 0x65 /* gs */ +}; + static const ASMInstr asm_instrs[] = { #define ALT(x) x #define DEF_ASM_OP0(name, opcode) @@ -410,14 +419,15 @@ static void asm_opcode(TCCState *s1, int opcode) { const ASMInstr *pa; - int i, modrm_index, reg, v, op1, is_short_jmp; + int i, modrm_index, reg, v, op1, is_short_jmp, has_seg_prefix; int nb_ops, s, ss; - Operand ops[MAX_OPERANDS], *pop; + Operand ops[MAX_OPERANDS], *pop, seg_prefix; int op_type[3]; /* decoded op type */ /* get operands */ pop = ops; nb_ops = 0; + has_seg_prefix = 0; for(;;) { if (tok == ';' || tok == TOK_LINEFEED) break; @@ -425,6 +435,18 @@ error("incorrect number of operands"); } parse_operand(s1, pop); + if (tok == ':') { + if (pop->type != OP_SEG || has_seg_prefix) { + error("incorrect prefix"); + } + seg_prefix = *pop; + has_seg_prefix = 1; + next(); + parse_operand(s1, pop); + if (!(pop->type & OP_EA)) { + error("segment prefix must be followed by memory reference"); + } + } pop++; nb_ops++; if (tok != ',') @@ -538,6 +560,8 @@ /* now generates the operation */ if (pa->instr_type & OPC_FWAIT) g(0x9b); + if (has_seg_prefix) + g(segment_prefixes[seg_prefix.reg]); v = pa->opcode; if (v == 0x69 || v == 0x69) {