1 /* 2 * LC-3b Architecture header file 3 * 4 * Copyright (C) 2003-2007 Peter Johnson 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS'' 16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE 19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 * POSSIBILITY OF SUCH DAMAGE. 26 */ 27 #ifndef YASM_LC3BARCH_H 28 #define YASM_LC3BARCH_H 29 30 /* Types of immediate. All immediates are stored in the LSBs of the insn. */ 31 typedef enum lc3b_imm_type { 32 LC3B_IMM_NONE = 0, /* no immediate */ 33 LC3B_IMM_4, /* 4-bit */ 34 LC3B_IMM_5, /* 5-bit */ 35 LC3B_IMM_6_WORD, /* 6-bit, word-multiple (byte>>1) */ 36 LC3B_IMM_6_BYTE, /* 6-bit, byte-multiple */ 37 LC3B_IMM_8, /* 8-bit, word-multiple (byte>>1) */ 38 LC3B_IMM_9, /* 9-bit, signed, word-multiple (byte>>1) */ 39 LC3B_IMM_9_PC /* 9-bit, signed, word-multiple, PC relative */ 40 } lc3b_imm_type; 41 42 /* Bytecode types */ 43 44 typedef struct lc3b_insn { 45 yasm_value imm; /* immediate or relative value */ 46 lc3b_imm_type imm_type; /* size of the immediate */ 47 48 unsigned int opcode; /* opcode */ 49 } lc3b_insn; 50 51 void yasm_lc3b__bc_transform_insn(yasm_bytecode *bc, lc3b_insn *insn); 52 53 yasm_arch_insnprefix yasm_lc3b__parse_check_insnprefix 54 (yasm_arch *arch, const char *id, size_t id_len, unsigned long line, 55 /*@out@*/ /*@only@*/ yasm_bytecode **bc, /*@out@*/ uintptr_t *prefix); 56 yasm_arch_regtmod yasm_lc3b__parse_check_regtmod 57 (yasm_arch *arch, const char *id, size_t id_len, 58 /*@out@*/ uintptr_t *data); 59 60 int yasm_lc3b__intnum_tobytes 61 (yasm_arch *arch, const yasm_intnum *intn, unsigned char *buf, 62 size_t destsize, size_t valsize, int shift, const yasm_bytecode *bc, 63 int warn); 64 65 /*@only@*/ yasm_bytecode *yasm_lc3b__create_empty_insn(yasm_arch *arch, 66 unsigned long line); 67 68 void yasm_lc3b__ea_destroy(/*@only@*/ yasm_effaddr *ea); 69 70 #endif 71