📄 asm.c
字号:
case DDIV: result = asm_float(instr, parm, 3); break; case ILLEGAL_F8: result = EMSYNTAX; break; case FDMUL: result = asm_float(instr, parm, 3); break; case ILLEGAL_FA: result = EMSYNTAX; break; case ILLEGAL_FB: result = EMSYNTAX; break; case ILLEGAL_FC: result = EMSYNTAX; break; case ILLEGAL_FD: result = EMSYNTAX; break; case ILLEGAL_FE: result = EMSYNTAX; break; case ILLEGAL_FF: result = EMSYNTAX; break; } /* end switch */ return (result); } /* End asm_instr() *//*** The following functions are used to convert instruction** parameters as an arrays of addr_29k_t memory space / address** pairs into a 32 bit Am29000 binary instruction.** All of the Am29000 instruction formats are supported below.*//*** Formats: <nmemonic>, RC, RA, (RB or I)** Examples: ADD, OR, SLL, all arithmetic and** logic instructions***/intasm_arith_logic(instr, parm, parm_count) struct instr_t *instr; struct addr_29k_t *parm; int parm_count; { if (parm_count != 3) return (EMSYNTAX); if (ISGENERAL(parm[0].memory_space) && ISGENERAL(parm[1].memory_space) && ISGENERAL(parm[2].memory_space)) { /* Make sure M flag is cleared */ instr->op = (BYTE) (instr->op & 0xfe); instr->c = (BYTE) (parm[0].address & 0xff); instr->a = (BYTE) (parm[1].address & 0xff); instr->b = (BYTE) (parm[2].address & 0xff); } else if (ISGENERAL(parm[0].memory_space) && ISGENERAL(parm[1].memory_space) && ISMEM(parm[2].memory_space)) { /* Make sure M flag is set */ instr->op = (BYTE) (instr->op | 0x01); instr->c = (BYTE) (parm[0].address & 0xff); instr->a = (BYTE) (parm[1].address & 0xff); instr->b = (BYTE) (parm[2].address & 0xff); } else return(EMSYNTAX); return (0); } /* end asm_arith_logic() *//*** Formats: <nmemonic>, VN, RA, (RB or I)** Examples: ASSEQ, ASLE, ASLT, all trap assertion** instructions***/intasm_vector(instr, parm, parm_count) struct instr_t *instr; struct addr_29k_t *parm; int parm_count; { if (parm_count != 3) return (EMSYNTAX); if (ISMEM(parm[0].memory_space) && ISGENERAL(parm[1].memory_space) && ISGENERAL(parm[2].memory_space)) { /* Make sure M flag is cleared */ instr->op = (BYTE) (instr->op & 0xfe); instr->c = (BYTE) (parm[0].address & 0xff); instr->a = (BYTE) (parm[1].address & 0xff); instr->b = (BYTE) (parm[2].address & 0xff); } else if (ISMEM(parm[0].memory_space) && ISGENERAL(parm[1].memory_space) && ISMEM(parm[2].memory_space)) { /* Make sure M flag is set */ instr->op = (BYTE) (instr->op | 0x01); instr->c = (BYTE) (parm[0].address & 0xff); instr->a = (BYTE) (parm[1].address & 0xff); instr->b = (BYTE) (parm[2].address & 0xff); } else return(EMSYNTAX); return (0); } /* end asm_vector() *//*** Formats: <nmemonic>, CE, CNTL, RA, (RB or I)** Examples: LOAD, LOADM, STORE, all load and store** instructions***/intasm_load_store(instr, parm, parm_count) struct instr_t *instr; struct addr_29k_t *parm; int parm_count; { int ce; int cntl; if (parm_count != 4) return (EMSYNTAX); if (ISMEM(parm[0].memory_space) && ISMEM(parm[1].memory_space) && ISGENERAL(parm[2].memory_space) && ISGENERAL(parm[3].memory_space)) { /* Make sure M flag is cleared */ instr->op = (BYTE) (instr->op & 0xfe); if (parm[0].address > 1) return (EMSYNTAX); if (parm[1].address > 0x7f) return (EMSYNTAX); ce = (int) ((parm[0].address << 7) & 0x80); cntl = (int) (parm[1].address & 0x7f); instr->c = (BYTE) (ce | cntl); instr->a = (BYTE) (parm[2].address & 0xff); instr->b = (BYTE) (parm[3].address & 0xff); } else if (ISMEM(parm[0].memory_space) && ISMEM(parm[1].memory_space) && ISGENERAL(parm[2].memory_space) && ISMEM(parm[3].memory_space)) { /* Make sure M flag is set */ instr->op = (BYTE) (instr->op | 0x01); if (parm[0].address > 1) return (EMSYNTAX); if (parm[1].address > 0x7f) return (EMSYNTAX); if (parm[3].address > 0xff) return (EMSYNTAX); ce = (int) ((parm[0].address << 7) & 0x80); cntl = (int) (parm[1].address & 0x7f); instr->c = (BYTE) (ce | cntl); instr->a = (BYTE) (parm[2].address & 0xff); instr->b = (BYTE) (parm[3].address & 0xff); } else return(EMSYNTAX); return (0); } /* end asm_load_store() *//*** Formats: <nmemonic>** Examples: HALT, INV, IRET*//*ARGSUSED*/intasm_no_parms(instr, parm, parm_count) struct instr_t *instr; struct addr_29k_t *parm; int parm_count; { if (parm_count != 0) return (EMSYNTAX); /* Put zeros in the "reserved" fields */ instr->c = 0; instr->a = 0; instr->b = 0; return (0); } /* end asm_no_parms() */intasm_one_parms(instr, parm, parm_count) struct instr_t *instr; struct addr_29k_t *parm; int parm_count; { if (parm_count != 1) return (EMSYNTAX); instr->c = (BYTE) (parm[0].address & 0x3); /* Put zeros in the "reserved" fields */ instr->a = 0; instr->b = 0; return (0); } /* end asm_one_parms *//*** Formats: <nmemonic>, RC, RA, RB** Examples: DADD, FADD, all floating point** instructions***/intasm_float(instr, parm, parm_count) struct instr_t *instr; struct addr_29k_t *parm; int parm_count; { if (parm_count != 3) return (EMSYNTAX); if (ISGENERAL(parm[0].memory_space) && ISGENERAL(parm[1].memory_space) && ISGENERAL(parm[2].memory_space)) { instr->c = (BYTE) (parm[0].address & 0xff); instr->a = (BYTE) (parm[1].address & 0xff); instr->b = (BYTE) (parm[2].address & 0xff); } else return(EMSYNTAX); return (0); } /* end asm_float() *//*** Formats: <nmemonic> RA, <target>** Examples: CALL, JMPF, JMPFDEC, JMPT**** Note: This function is used only with the CALL,** JMPF, JMPFDEC and JMPT operations.*/intasm_call_jmp(instr, parm, parm_count) struct instr_t *instr; struct addr_29k_t *parm; int parm_count; { if (parm_count != 2) return (EMSYNTAX); if (ISGENERAL(parm[0].memory_space) && ISMEM(parm[1].memory_space)) { /* Make sure M flag is set */ if (parm[1].memory_space != PC_RELATIVE) instr->op = (BYTE) (instr->op | 0x01); else instr->op = (BYTE) instr->op ; instr->c = (BYTE) ((parm[1].address >> 10) & 0xff); instr->a = (BYTE) (parm[0].address & 0xff); instr->b = (BYTE) ((parm[1].address >> 2) & 0xff); } else return(EMSYNTAX); return (0); } /* end asm_call_jmp() *//*** Formats: <nmemonic> RA, RB** Examples: CALLI, JMPFI, JMPTI**** Note: This function is used only with the CALLI,** JMPFI and JMPTI (but not JMPI) operations.*/intasm_calli_jmpi(instr, parm, parm_count) struct instr_t *instr; struct addr_29k_t *parm; int parm_count; { if (parm_count != 2) return (EMSYNTAX); if (ISGENERAL(parm[0].memory_space) && ISREG(parm[1].memory_space)) { instr->c = 0; instr->a = (BYTE) (parm[0].address & 0xff); instr->b = (BYTE) (parm[1].address & 0xff); } else return(EMSYNTAX); return (0); } /* end asm_calli_jmpi() *//*** Formats: <nmemonic> RC, RB, FS** Examples: CLASS**** Note: This function is used only with the CLASS** operation.*/intasm_class(instr, parm, parm_count) struct instr_t *instr; struct addr_29k_t *parm; int parm_count; { if (parm_count != 3) return (EMSYNTAX); if (ISGENERAL(parm[0].memory_space) && ISGENERAL(parm[1].memory_space) && ISMEM(parm[2].memory_space)) { if (parm[2].address > 0x03) return (EMSYNTAX); instr->c = (BYTE) (parm[0].address & 0xff); instr->a = (BYTE) (parm[1].address & 0xff); instr->b = (BYTE) (parm[2].address & 0x03); } else return(EMSYNTAX); return (0); } /* end asm_class() *//*** Formats: <nmemonic> RC, (RB or I)** Examples: CLZ**** Note: This function is used only with the CLZ** operation.*/intasm_clz(instr, parm, parm_count) struct instr_t *instr; struct addr_29k_t *parm; int parm_count; { if (parm_count != 2) return (EMSYNTAX); if (ISGENERAL(parm[0].memory_space) && ISGENERAL(parm[1].memory_space)) { /* Make sure M flag is cleared */ instr->op = (BYTE) (instr->op & 0xfe); instr->c = (BYTE) (parm[0].address & 0xff); instr->a = 0; instr->b = (BYTE) (parm[1].address & 0xff); } else if (ISGENERAL(parm[0].memory_space) && ISMEM(parm[1].memory_space)) { /* Check param1 */ if ((parm[1].address) > 0xff) return(EMSYNTAX); /* Make sure M flag is set */ instr->op = (BYTE) (instr->op | 0x01); instr->c = (BYTE) (parm[0].address & 0xff); instr->a = 0; instr->b = (BYTE) (parm[1].address & 0xff); } else return(EMSYNTAX); return (0); } /* end asm_clz() *//*** Formats: <nmemonic> RA, <const16>** Examples: CONST, CONSTN***/intasm_const(instr, parm, parm_count) struct instr_t *instr; struct addr_29k_t *parm; int parm_count; { if (parm_count != 2) return (EMSYNTAX); if (ISGENERAL(parm[0].memory_space) && ISMEM(parm[1].memory_space)) { instr->c = (BYTE) ((parm[1].address >> 8) & 0xff); instr->a = (BYTE) (parm[0].address & 0xff); instr->b = (BYTE) (parm[1].address & 0xff); } else return(EMSYNTAX); return (0); } /* end asm_const() *//*** Formats: <nmemonic> RA, <const16>** Examples: CONSTH***/intasm_consth(instr, parm, parm_count) struct instr_t *instr; struct addr_29k_t *parm; int parm_count;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -