void GGLAssembler::build_blendFOneMinusF( component_t& temp, const integer_t& factor, const integer_t& fragment, const integer_t& fb) { // R = S*f + D*(1-f) = (S-D)*f + D Scratch scratches(registerFile()); // compute S-D integer_t diff(fragment.flags & CORRUPTIBLE ? fragment.reg : scratches.obtain(), fb.size(), CORRUPTIBLE); const int shift = fragment.size() - fb.size(); if (shift>0) RSB(AL, 0, diff.reg, fb.reg, reg_imm(fragment.reg, LSR, shift)); else if (shift<0) RSB(AL, 0, diff.reg, fb.reg, reg_imm(fragment.reg, LSL,-shift)); else RSB(AL, 0, diff.reg, fb.reg, fragment.reg); mul_factor_add(temp, diff, factor, component_t(fb)); }
void GGLAssembler::expand(integer_t& dst, const integer_t& src, int dbits) { assert(src.size()); int sbits = src.size(); int s = src.reg; int d = dst.reg; // be sure to set 'dst' after we read 'src' as they may be identical dst.s = dbits; dst.flags = 0; if (dbits<=sbits) { if (s != d) { MOV(AL, 0, d, s); } return; } if (sbits == 1) { RSB(AL, 0, d, s, reg_imm(s, LSL, dbits)); // d = (s<<dbits) - s; return; } if (dbits % sbits) { MOV(AL, 0, d, reg_imm(s, LSL, dbits-sbits)); // d = s << (dbits-sbits); dbits -= sbits; do { ORR(AL, 0, d, d, reg_imm(d, LSR, sbits)); // d |= d >> sbits; dbits -= sbits; sbits *= 2; } while(dbits>0); return; } dbits -= sbits; do { ORR(AL, 0, d, s, reg_imm(s, LSL, sbits)); // d |= d<<sbits; s = d; dbits -= sbits; if (sbits*2 < dbits) { sbits *= 2; } } while(dbits>0); }
int main() { int op; uint32_t registro[16]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; char banderas[4]; do{ system("cls"); printf("seleccione la opcion 1 para mostrar los valores de los registros\n"); printf("seleccione la opcion 2 para sumar registros \n"); printf("seleccione la opcion 3 para multiplicacion logica (AND) de registros \n"); printf("seleccione la opcion 4 para Eor a nivel de bits \n"); printf("seleccione la opcion 5 para desplazar de un registro a otro \n"); printf("seleccione la opcion 6 para suma logica (OR) de registro\n"); printf("seleccione la opcion 7 para ADN sin almacenar, solo modifica banderas \n"); printf("seleccione la opcion 8 para comparar (SUB sin almacenar), solo modifica banderas\n"); printf("seleccione la opcion 9 Multiplicacion de registros, solo se alacenan 32 bits menos significativos\n"); printf("seleccione la opcion 10 AND sin almacenacmiento, solo modifica banderas\n"); printf("seleccione la opcion 11 para LSL desplazamiento logico a la izquierda \n"); printf("seleccione la opcion 12 para LSR desplazamiento logico a la derecha \n"); printf("seleccione la opcion 13 para ROR rotacion a la derecha \n"); printf("seleccione la opcion 14 para ASR desplazamiento aritmetico a la derecha \n"); printf("seleccione la opcion 15 para BIC Realiza una AND de un registro con otro negado \n"); printf("seleccione la opcion 16 para MUN guarda en un registro la negacion de otro\n"); printf("seleccione la opcion 17 para RSB niega un valor de registro\n"); printf("seleccione la opcion 18 para NOP da un retardo de un ciclo de reloj (no hace nada) \n"); printf("seleccione la opcion 19 para REV toma grupos de 8 bits y los desplaza \n"); printf("seleccione la opcion 20 para REVIG toma grupos de 16 bits y los agrupa en grupos de dos bytes\n"); printf("seleccione la opcion 21 para REVSH extencion con signo\n\n"); scanf("%d",&op); system("cls"); switch(op){ case 1: //mostrar_valores(registro); break; case 2: printf("ingrese el valor del primer registro:\n"); scanf("%d",®istro[1]); printf("ingrese el valor del segundo registro:\n"); scanf("%d",®istro[2]); ADD(registro,®istro[0],registro[1],registro[2],&banderas[0]); printf("%d valor del resultado \n",registro[0]); printf("%d valor del resultado bandera n \n",banderas[N]); printf("%d valor del resultado bandera z \n",banderas[Z]); printf("%d valor del resultado bandera c \n",banderas[C]); printf("%d valor del resultado bandera v \n",banderas[V]); break; case 3: printf("ingrese el valor del primer registro:\n"); scanf("%d",®istro[1]); printf("ingrese el valor del segundo registro:\n"); scanf("%d",®istro[2]); AND(registro,®istro[0],registro[1],registro[2],&banderas[0]); printf("%d valor del resultado \n",registro[0]); printf("%d valor del resultado bandera n \n",banderas[N]); printf("%d valor del resultado bandera z \n",banderas[Z]); printf("%d valor del resultado bandera c \n",banderas[C]); printf("%d valor del resultado bandera v \n",banderas[V]); break; case 4: printf("ingrese el valor del primer registro:\n"); scanf("%d",®istro[1]); printf("ingrese el valor del segundo registro:\n"); scanf("%d",®istro[2]); EOR(registro,®istro[0],registro[1],registro[2],&banderas[0]); printf("%d valor del resultado \n",registro[0]); printf("%d valor del resultado bandera n \n",banderas[N]); printf("%d valor del resultado bandera z \n",banderas[Z]); printf("%d valor del resultado bandera c \n",banderas[C]); printf("%d valor del resultado bandera v \n",banderas[V]); break; case 5: printf("ingrese el valor del registro origen:\n"); scanf("%d",®istro[1]); MOV(registro,®istro[0],registro[1],banderas); printf("%d valor del resultado \n",registro[0]); break; case 7: printf("ingrese el valor del primer registro:\n"); scanf("%d",®istro[1]); printf("ingrese el valor del segundo registro:\n"); scanf("%d",®istro[2]); CMN(registro,registro[1],registro[2],&banderas[0]); printf("%d valor del resultado \n",registro[0]); printf("%d valor del resultado bandera n \n",banderas[N]); printf("%d valor del resultado bandera z \n",banderas[Z]); printf("%d valor del resultado bandera c \n",banderas[C]); printf("%d valor del resultado bandera v \n",banderas[V]); break; case 8: printf("ingrese el valor del primer registro:\n"); scanf("%d",®istro[1]); printf("ingrese el valor del segundo registro:\n"); scanf("%d",®istro[2]); CMP(registro,registro[1],registro[2],&banderas[0]); printf("%d valor del resultado \n",registro[0]); printf("%d valor del resultado bandera n \n",banderas[N]); printf("%d valor del resultado bandera z \n",banderas[Z]); printf("%d valor del resultado bandera c \n",banderas[C]); printf("%d valor del resultado bandera v \n",banderas[V]); break; case 9: printf("ingrese el valor del primer registro:\n"); scanf("%d",®istro[1]); printf("ingrese el valor del segundo registro:\n"); scanf("%d",®istro[2]); MUL(registro,®istro[0],registro[1],registro[2],&banderas[0]); printf("%d valor del resultado \n",registro[0]); printf("%d valor del resultado bandera n \n",banderas[N]); printf("%d valor del resultado bandera z \n",banderas[Z]); printf("%d valor del resultado bandera c \n",banderas[C]); printf("%d valor del resultado bandera v \n",banderas[V]); break; case 10: printf("ingrese el valor del primer registro:\n"); scanf("%d",®istro[1]); printf("ingrese el valor del segundo registro:\n"); scanf("%d",®istro[2]); TST(registro,registro[1],registro[2],&banderas[0]); printf("%d valor del resultado \n",registro[0]); printf("%d valor del resultado bandera n \n",banderas[N]); printf("%d valor del resultado bandera z \n",banderas[Z]); printf("%d valor del resultado bandera c \n",banderas[C]); printf("%d valor del resultado bandera v \n",banderas[V]); break; case 11: printf("ingrese el valor del registro:\n"); scanf("%d",®istro[1]); printf("ingrese el numero de desplazamientos:\n"); scanf("%d",®istro[2]); LSL(registro,®istro[0],registro[1],registro[2],banderas); printf("%d valor del resultado \n",registro[0]); break; case 12: printf("ingrese el valor del primer registro:\n"); scanf("%d",®istro[1]); printf("ingrese elnumero de desplazamientos:\n"); scanf("%d",®istro[2]); LSR(registro,®istro[0],registro[1],registro[2],banderas); printf("%d valor del resultado \n",registro[0]); break; case 13: printf("ingrese el valor del primer registro:\n"); scanf("%d",®istro[1]); printf("ingrese elnumero de desplazamientos:\n"); scanf("%d",®istro[2]); ROR(registro,®istro[0],registro[1],registro[2],banderas); printf("%d valor del resultado \n",registro[0]); break; case 14: printf("ingrese el valor del primer registro:\n"); scanf("%d",®istro[1]); printf("ingrese elnumero de desplazamientos:\n"); scanf("%d",®istro[2]); ASR(registro,®istro[0],registro[1],registro[2],banderas); printf("%d valor del resultado \n",registro[0]); break; case 15: printf("ingrese el valor del primer registro:\n"); scanf("%d",®istro[0]); printf("ingrese el valor del segundo registro:\n"); scanf("%d",®istro[1]); BIC(registro,®istro[0],registro[1],banderas); printf("%d valor del resultado \n",registro[0]); break; case 16: printf("ingrese un valor del registro origen\n"); scanf("%d",®istro[1]); MVN(registro,®istro[0],registro[1],banderas); printf("%d valor del resultado \n",registro[0]); break; case 17: printf("ingrese un valor de registro\n"); scanf("%d",®istro[1]); RSB(registro,®istro[0],registro[1],0,banderas); printf("%d valor del resultado \n",registro[0]); break; case 18: NOP(registro); break; case 19: printf("ingrese un valor de registro \n"); scanf("%d",®istro[0]); REV(registro,®istro[0]); printf("%d valor del resultado \n",registro[0]); break; case 20: printf("ingrese un valor de registro \n"); scanf("%d",®istro[0]); REVIG(registro,®istro[0]); printf("%d valor del resultado \n",registro[0]); break; case 21: printf("ingrese un valor de registro \n"); scanf("%d",®istro[0]); REVSH(registro,®istro[0]); printf("%d valor del resultado \n",registro[0]); break; default: printf("Opcion invalida\n\n"); break; } printf("\nDesea realizar otra operacion?\n<1>-si\n<0>-no\n"); scanf("%d",&op); system("cls"); }while(op); return 0; }
void GGLAssembler::build_blend_factor( integer_t& factor, int f, int component, const pixel_t& dst_pixel, integer_t& fragment, integer_t& fb, Scratch& scratches) { integer_t src_alpha(fragment); // src_factor/dst_factor won't be used after blending, // so it's fine to mark them as CORRUPTIBLE (if not aliased) factor.flags |= CORRUPTIBLE; switch(f) { case GGL_ONE_MINUS_SRC_ALPHA: case GGL_SRC_ALPHA: if (component==GGLFormat::ALPHA && !isAlphaSourceNeeded()) { // we're processing alpha, so we already have // src-alpha in fragment, and we need src-alpha just this time. } else { // alpha-src will be needed for other components if (!mBlendFactorCached || mBlendFactorCached==f) { src_alpha = mAlphaSource; factor = mAlphaSource; factor.flags &= ~CORRUPTIBLE; // we already computed the blend factor before, nothing to do. if (mBlendFactorCached) return; // this is the first time, make sure to compute the blend // factor properly. mBlendFactorCached = f; break; } else { // we have a cached alpha blend factor, but we want another one, // this should really not happen because by construction, // we cannot have BOTH source and destination // blend factors use ALPHA *and* ONE_MINUS_ALPHA (because // the blending stage uses the f/(1-f) optimization // for completeness, we handle this case though. Since there // are only 2 choices, this meens we want "the other one" // (1-factor) factor = mAlphaSource; factor.flags &= ~CORRUPTIBLE; RSB(AL, 0, factor.reg, factor.reg, imm((1<<factor.s))); mBlendFactorCached = f; return; } } // fall-through... case GGL_ONE_MINUS_DST_COLOR: case GGL_DST_COLOR: case GGL_ONE_MINUS_SRC_COLOR: case GGL_SRC_COLOR: case GGL_ONE_MINUS_DST_ALPHA: case GGL_DST_ALPHA: case GGL_SRC_ALPHA_SATURATE: // help us find out what register we can use for the blend-factor // CORRUPTIBLE registers are chosen first, or a new one is allocated. if (fragment.flags & CORRUPTIBLE) { factor.setTo(fragment.reg, 32, CORRUPTIBLE); fragment.flags &= ~CORRUPTIBLE; } else if (fb.flags & CORRUPTIBLE) { factor.setTo(fb.reg, 32, CORRUPTIBLE); fb.flags &= ~CORRUPTIBLE; } else { factor.setTo(scratches.obtain(), 32, CORRUPTIBLE); } break; } // XXX: doesn't work if size==1 switch(f) { case GGL_ONE_MINUS_DST_COLOR: case GGL_DST_COLOR: factor.s = fb.s; ADD(AL, 0, factor.reg, fb.reg, reg_imm(fb.reg, LSR, fb.s-1)); break; case GGL_ONE_MINUS_SRC_COLOR: case GGL_SRC_COLOR: factor.s = fragment.s; ADD(AL, 0, factor.reg, fragment.reg, reg_imm(fragment.reg, LSR, fragment.s-1)); break; case GGL_ONE_MINUS_SRC_ALPHA: case GGL_SRC_ALPHA: factor.s = src_alpha.s; ADD(AL, 0, factor.reg, src_alpha.reg, reg_imm(src_alpha.reg, LSR, src_alpha.s-1)); break; case GGL_ONE_MINUS_DST_ALPHA: case GGL_DST_ALPHA: // XXX: should be precomputed extract(factor, dst_pixel, GGLFormat::ALPHA); ADD(AL, 0, factor.reg, factor.reg, reg_imm(factor.reg, LSR, factor.s-1)); break; case GGL_SRC_ALPHA_SATURATE: // XXX: should be precomputed // XXX: f = min(As, 1-Ad) // btw, we're guaranteed that Ad's size is <= 8, because // it's extracted from the framebuffer break; } switch(f) { case GGL_ONE_MINUS_DST_COLOR: case GGL_ONE_MINUS_SRC_COLOR: case GGL_ONE_MINUS_DST_ALPHA: case GGL_ONE_MINUS_SRC_ALPHA: RSB(AL, 0, factor.reg, factor.reg, imm((1<<factor.s))); } // don't need more than 8-bits for the blend factor // and this will prevent overflows in the multiplies later if (factor.s > 8) { MOV(AL, 0, factor.reg, reg_imm(factor.reg, LSR, factor.s-8)); factor.s = 8; } }
void decodeInstruction(instruction_t instruction, uint32_t *dir_reg, char *dir_flags, uint8_t *SRAM, uint16_t *dec) { uint8_t *R_activos=instruction.registers_list; /* Comparacion de mnemonic y Llamado de las funciones */ if( strcmp(instruction.mnemonic,"ADC") == 0 || strcmp(instruction.mnemonic,"ADCS") == 0){ dir_reg[PC]++; *dec=16704; *dec=*dec|instruction.op3_value<<3|instruction.op1_value; dir_reg[instruction.op1_value]=ADC(dir_reg[instruction.op2_value],dir_reg[instruction.op3_value],dir_flags); } if( strcmp(instruction.mnemonic,"ADDS") == 0 || strcmp(instruction.mnemonic,"ADD") == 0){ dir_reg[PC]++; if(instruction.op2_type=='S'){ *dec=45056; dir_reg[SP]=ADD(dir_reg[SP],instruction.op3_value,dir_flags); *dec=*dec|instruction.op3_value;} else if(instruction.op3_type=='#'){ *dec=7168; *dec=*dec|instruction.op3_value<<6|instruction.op2_value<<3|instruction.op1_value; dir_reg[instruction.op1_value]=ADD(dir_reg[instruction.op2_value], instruction.op3_value,dir_flags); mvprintw(4,20,"%X",*dec);} else{ *dec=6144; *dec=*dec|instruction.op3_value<<6|instruction.op2_value<<3|instruction.op1_value; dir_reg[instruction.op1_value]=ADD(dir_reg[instruction.op2_value],dir_reg[instruction.op3_value],dir_flags);} } if( strcmp(instruction.mnemonic,"AND") == 0 || strcmp(instruction.mnemonic,"ANDS") == 0){ dir_reg[PC]++; *dec=16384; if(instruction.op3_type=='#'){ dir_reg[instruction.op1_value]=AND(dir_reg[instruction.op2_value],instruction.op3_value,dir_flags);} else dir_reg[instruction.op1_value]=AND(dir_reg[instruction.op2_value],dir_reg[instruction.op3_value],dir_flags); } if( strcmp(instruction.mnemonic,"ASR") == 0 || strcmp(instruction.mnemonic,"ASRS") == 0){ dir_reg[PC]++; if(instruction.op3_type=='#'){ *dec=4096; *dec=*dec|instruction.op3_value<<6|instruction.op2_value<<3|instruction.op1_value; dir_reg[instruction.op1_value]=ASR(dir_reg[instruction.op2_value],instruction.op3_value,dir_flags);} else{ *dec=16640; *dec=*dec|instruction.op3_value<<3|instruction.op1_value; dir_reg[instruction.op1_value]=ASR(dir_reg[instruction.op2_value],dir_reg[instruction.op3_value],dir_flags);} } if( strcmp(instruction.mnemonic,"BICS") == 0 || strcmp(instruction.mnemonic,"BICS") == 0){ dir_reg[PC]++; if(instruction.op3_type=='#') dir_reg[instruction.op1_value]=BIC(dir_reg[instruction.op2_value],instruction.op3_value,dir_flags); else{ *dec=17280; dir_reg[instruction.op1_value]=BIC(dir_reg[instruction.op2_value],dir_reg[instruction.op3_value],dir_flags); *dec=*dec|instruction.op3_value<<3|instruction.op1_value;} } if( strcmp(instruction.mnemonic,"CMN" ) == 0 || strcmp(instruction.mnemonic,"CMNS") == 0){ dir_reg[PC]++; CMN(dir_reg[instruction.op1_value], dir_reg[instruction.op2_value],dir_flags); *dec=17088; *dec=*dec|instruction.op2_value<<3|instruction.op1_value; mvprintw(4,20,"%X",*dec); } if( strcmp(instruction.mnemonic,"CMP") == 0 || strcmp(instruction.mnemonic,"CMPS") == 0){ dir_reg[PC]++; CMP(dir_reg[instruction.op1_value],dir_reg[instruction.op2_value],dir_flags); *dec=17024; *dec=*dec|instruction.op2_value<<3|instruction.op1_value; mvprintw(4,20,"%X",*dec); } if( strcmp(instruction.mnemonic,"EOR") == 0 || strcmp(instruction.mnemonic,"EORS") == 0){ dir_reg[PC]++; *dec=16448; if(instruction.op3_type=='#') dir_reg[instruction.op1_value]=EOR(dir_reg[instruction.op2_value],instruction.op3_value,dir_flags); else dir_reg[instruction.op1_value]=EOR(dir_reg[instruction.op2_value],dir_reg[instruction.op3_value],dir_flags); } if( strcmp(instruction.mnemonic,"LSLS") == 0 || strcmp(instruction.mnemonic,"LSL") == 0){ dir_reg[PC]++; if(instruction.op3_type=='#'){ *dec=0; dir_reg[instruction.op1_value]=LSL(dir_reg[instruction.op2_value],instruction.op3_value,dir_flags); *dec=*dec|instruction.op3_value<<6|instruction.op2_value<<3|instruction.op1_value;} else{ *dec=16512; dir_reg[instruction.op1_value]=LSL(dir_reg[instruction.op2_value],dir_reg[instruction.op3_value],dir_flags); *dec=*dec|instruction.op3_value<<3|instruction.op1_value;} } if( strcmp(instruction.mnemonic,"LSRS") == 0 || strcmp(instruction.mnemonic,"LSR") == 0){ dir_reg[PC]++; if(instruction.op3_type=='#'){ *dec=2048; dir_reg[instruction.op1_value]=LSR(dir_reg[instruction.op2_value],instruction.op3_value,dir_flags); *dec=*dec|instruction.op3_value<<6|instruction.op2_value<<3|instruction.op1_value;} else{ *dec=16576; dir_reg[instruction.op1_value]=LSR(dir_reg[instruction.op2_value],dir_reg[instruction.op3_value],dir_flags); *dec=*dec|instruction.op3_value<<3|instruction.op1_value;} } if( strcmp(instruction.mnemonic,"MOV") == 0 || strcmp(instruction.mnemonic,"MOVS") == 0){ dir_reg[PC]++; if(instruction.op2_type=='#'){ *dec=8192; dir_reg[instruction.op1_value]=MOV(instruction.op2_value,dir_flags); *dec=*dec|instruction.op1_value<<8|instruction.op2_value;} else{ *dec=0; dir_reg[instruction.op1_value]=MOV(dir_reg[instruction.op2_value],dir_flags); *dec=*dec|instruction.op2_value<<3|instruction.op1_value;} } if( strcmp(instruction.mnemonic,"MUL") == 0 || strcmp(instruction.mnemonic,"MULS") == 0){ dir_reg[PC]++; *dec=17216; if(instruction.op3_type=='#'){ dir_reg[instruction.op1_value]=MUL(dir_reg[instruction.op2_value],instruction.op3_value,dir_flags);} else{ dir_reg[instruction.op1_value]=MUL(dir_reg[instruction.op2_value],dir_reg[instruction.op3_value],dir_flags); *dec=*dec|instruction.op2_value<<3|instruction.op1_value;} } if( strcmp(instruction.mnemonic,"MVN") == 0 || strcmp(instruction.mnemonic,"MVNS") == 0){ dir_reg[PC]++; *dec=17344; dir_reg[instruction.op1_value]=MVN(dir_reg[instruction.op2_value], dir_flags); *dec=*dec|instruction.op2_value<<3|instruction.op1_value; } if( strcmp(instruction.mnemonic,"ORR") == 0 || strcmp(instruction.mnemonic,"ORRS") == 0){ dir_reg[PC]++; *dec=17152; if(instruction.op3_type=='#'){ dir_reg[instruction.op1_value]=ORR(dir_reg[instruction.op2_value],instruction.op3_value,dir_flags);} else{ dir_reg[instruction.op1_value]=ORR(dir_reg[instruction.op2_value],dir_reg[instruction.op3_value],dir_flags); *dec=*dec|instruction.op3_value<<3|instruction.op1_value;} } if( strcmp(instruction.mnemonic,"REV") == 0 || strcmp(instruction.mnemonic,"REVS") == 0){ dir_reg[PC]++; *dec=47616; dir_reg[instruction.op1_value]=REV(dir_reg[instruction.op2_value]); *dec=*dec|instruction.op2_value<<3|instruction.op1_value; } if( strcmp(instruction.mnemonic,"REVG") == 0 || strcmp(instruction.mnemonic,"REVGS") == 0){ dir_reg[PC]++; *dec=47680; dir_reg[instruction.op1_value]=REVG(dir_reg[instruction.op2_value]); *dec=*dec|instruction.op2_value<<3|instruction.op1_value; } if( strcmp(instruction.mnemonic,"REVSH") == 0 || strcmp(instruction.mnemonic,"REVSHS") == 0){ dir_reg[PC]++; *dec=47808; dir_reg[instruction.op1_value]=REVSH(dir_reg[instruction.op2_value]); *dec=*dec|instruction.op2_value<<3|instruction.op1_value; } if( strcmp(instruction.mnemonic,"ROR") == 0 || strcmp(instruction.mnemonic,"RORS") == 0){ dir_reg[PC]++; *dec=16832; if(instruction.op3_type=='#'){ dir_reg[instruction.op1_value]=ROR(dir_reg[instruction.op2_value],instruction.op3_value,dir_flags);} else{ dir_reg[instruction.op1_value]=ROR(dir_reg[instruction.op2_value],dir_reg[instruction.op3_value],dir_flags); *dec=*dec|instruction.op3_value<<3|instruction.op1_value;} } if( strcmp(instruction.mnemonic,"RSB") == 0 || strcmp(instruction.mnemonic,"RSBS") == 0){ dir_reg[PC]++; *dec=16690; dir_reg[instruction.op1_value]=RSB(dir_reg[instruction.op2_value], dir_flags); *dec=*dec|instruction.op2_value<<3|instruction.op1_value; } if( strcmp(instruction.mnemonic,"SBC") == 0 || strcmp(instruction.mnemonic,"SBCS") == 0){ dir_reg[PC]++; *dec=16768; SBC(dir_reg[instruction.op1_value],dir_reg[instruction.op2_value], dir_flags); *dec=*dec|instruction.op2_value<<3|instruction.op1_value; } if( strcmp(instruction.mnemonic,"SUBS") == 0 || strcmp(instruction.mnemonic,"SUB") == 0){ dir_reg[PC]++; if(instruction.op2_type=='S'){ *dec=45184; dir_reg[SP]=SUB(dir_reg[SP],instruction.op3_value,dir_flags); *dec=*dec|instruction.op3_value;} else if(instruction.op3_type=='#'){ *dec=7680; dir_reg[instruction.op1_value]=SUB(dir_reg[instruction.op2_value],instruction.op3_value,dir_flags); *dec=*dec|instruction.op3_value<<6|instruction.op2_value<<3|instruction.op1_value;} else{ *dec=6656; dir_reg[instruction.op1_value]=SUB(dir_reg[instruction.op2_value],dir_reg[instruction.op3_value],dir_flags); *dec=*dec|instruction.op3_value<<6|instruction.op2_value<<3|instruction.op1_value;} } if( strcmp(instruction.mnemonic,"TST") == 0 || strcmp(instruction.mnemonic,"TSTS") == 0){ dir_reg[PC]++; *dec=16896; TST(dir_reg[instruction.op1_value], dir_reg[instruction.op2_value], dir_flags); *dec=*dec|instruction.op2_value<<3|instruction.op1_value; } if( strcmp(instruction.mnemonic,"NOP") == 0 ){ NOP(dir_reg); *dec=48896; } if( strcmp(instruction.mnemonic,"B") == 0 ){ *dec=57344; *dec=*dec|instruction.op1_value; B(instruction.op1_value, dir_reg); } if( strcmp(instruction.mnemonic,"BL") == 0 ){ *dec=0; BL(instruction.op1_value, dir_reg); } if( strcmp(instruction.mnemonic,"BX") == 0 ){ *dec=18176; BX(dir_reg); } if( strcmp(instruction.mnemonic,"BEQ") == 0 ){ *dec=0; BEQ(instruction.op1_value, dir_reg, dir_flags); } if( strcmp(instruction.mnemonic,"BNE") == 0 ){ *dec=0; BNE(instruction.op1_value, dir_reg, dir_flags); } if( strcmp(instruction.mnemonic,"BCS") == 0 ){ *dec=0; BCS(instruction.op1_value, dir_reg, dir_flags); } if( strcmp(instruction.mnemonic,"BCC") == 0 ){ *dec=0; BCC(instruction.op1_value, dir_reg, dir_flags); } if( strcmp(instruction.mnemonic,"BMI") == 0 ){ *dec=0; BMI(instruction.op1_value, dir_reg, dir_flags); } if( strcmp(instruction.mnemonic,"BPL") == 0 ){ *dec=0; BPL(instruction.op1_value, dir_reg, dir_flags); } if( strcmp(instruction.mnemonic,"BVS") == 0 ){ *dec=0; BVS(instruction.op1_value, dir_reg, dir_flags); } if( strcmp(instruction.mnemonic,"BVC") == 0 ){ *dec=0; BVC(instruction.op1_value, dir_reg, dir_flags); } if( strcmp(instruction.mnemonic,"BHI") == 0 ){ *dec=0; BHI(instruction.op1_value, dir_reg, dir_flags); } if( strcmp(instruction.mnemonic,"BLS") == 0 ){ *dec=0; BLS(instruction.op1_value, dir_reg, dir_flags); } if( strcmp(instruction.mnemonic,"BGE") == 0 ){ *dec=0; BGE(instruction.op1_value, dir_reg, dir_flags); } if( strcmp(instruction.mnemonic,"BLT") == 0 ){ *dec=0; BLT(instruction.op1_value, dir_reg, dir_flags); } if( strcmp(instruction.mnemonic,"BGT") == 0 ){ *dec=0; BGT(instruction.op1_value, dir_reg, dir_flags); } if( strcmp(instruction.mnemonic,"BLE") == 0 ){ *dec=0; BLE(instruction.op1_value, dir_reg, dir_flags); } if( strcmp(instruction.mnemonic,"BAL") == 0 ){ *dec=0; BAL(instruction.op1_value, dir_reg); } if(strcmp(instruction.mnemonic,"PUSH")==0){ dir_reg[PC]++; *dec=46080; PUSH(SRAM, dir_reg,R_activos); } if(strcmp(instruction.mnemonic,"POP")==0){ dir_reg[PC]++; *dec=48128; POP(SRAM,dir_reg,R_activos); } data=(uint8_t)dir_reg[instruction.op1_value]; if(strcmp(instruction.mnemonic,"LDR")==0){ dir_reg[PC]++; if(instruction.op2_type=='=' && instruction.op3_type=='N'){ *dec=0; dir_reg[instruction.op1_value]=instruction.op2_value;} else if(instruction.op2_type=='S'){ *dec=38912; dir_reg[instruction.op1_value]=LDR(dir_reg[SP], instruction.op3_value<<2, SRAM); *dec=*dec|instruction.op3_value|instruction.op1_value<<8;} else if(instruction.op3_type=='#' || instruction.op3_type=='N'){ *dec=26624; if((dir_reg[instruction.op2_value]+(instruction.op3_value<<2))>=0x40000000) IOAccess((uint8_t)(dir_reg[instruction.op2_value]+(instruction.op3_value<<2)), &data,Read); else dir_reg[instruction.op1_value]=LDR(dir_reg[instruction.op2_value], instruction.op3_value<<2, SRAM); *dec=*dec|instruction.op3_value<<6|instruction.op2_value|instruction.op1_value;} else{ *dec=22528; if((dir_reg[instruction.op2_value]+dir_reg[instruction.op3_value])>=0x40000000) IOAccess((uint8_t)(dir_reg[instruction.op2_value]+dir_reg[instruction.op3_value]), &data,Read); else dir_reg[instruction.op1_value]=LDR(dir_reg[instruction.op2_value], dir_reg[instruction.op3_value], SRAM); *dec=*dec|instruction.op3_value<<6|instruction.op2_value<<3|instruction.op1_value;} } if(strcmp(instruction.mnemonic,"LDRB")==0){ dir_reg[PC]++; if(instruction.op3_type=='#' || instruction.op3_type=='N'){ *dec=30720; if((dir_reg[instruction.op2_value]+instruction.op3_value)>=0x40000000) IOAccess((uint8_t)(dir_reg[instruction.op2_value]+instruction.op3_value), &data,Read); else dir_reg[instruction.op1_value]=LDRB(dir_reg[instruction.op2_value], instruction.op3_value, SRAM); *dec=*dec|instruction.op3_value<<6|instruction.op2_value<<3|instruction.op1_value;} else{ *dec=23552; if((dir_reg[instruction.op2_value]+dir_reg[instruction.op3_value])>=0x40000000) IOAccess((uint8_t)(dir_reg[instruction.op2_value]+dir_reg[instruction.op3_value]), &data,Read); else dir_reg[instruction.op1_value]=LDRB(dir_reg[instruction.op2_value], dir_reg[instruction.op3_value], SRAM); *dec=*dec|instruction.op3_value<<6|instruction.op2_value<<3|instruction.op1_value;} } if(strcmp(instruction.mnemonic,"LDRH")==0){ dir_reg[PC]++; if(instruction.op3_type=='#' || instruction.op3_type=='N'){ *dec=34816; if((dir_reg[instruction.op2_value]+(instruction.op3_value<<1))>=0x40000000) IOAccess((uint8_t)(dir_reg[instruction.op2_value]+(instruction.op3_value<<1)), &data,Read); else dir_reg[instruction.op1_value]=LDRH(dir_reg[instruction.op2_value], instruction.op3_value<<1, SRAM); *dec=*dec|instruction.op3_value<<6|instruction.op2_value<<3|instruction.op1_value;} else{ *dec=23040; if((dir_reg[instruction.op2_value]+dir_reg[instruction.op3_value])>=0x40000000) IOAccess((uint8_t)(dir_reg[instruction.op2_value]+dir_reg[instruction.op3_value]), &data,Read); else dir_reg[instruction.op1_value]=LDRH(dir_reg[instruction.op2_value], dir_reg[instruction.op3_value], SRAM); *dec=*dec|instruction.op3_value<<6|instruction.op2_value<<3|instruction.op1_value;} } if(strcmp(instruction.mnemonic,"LDRSB")==0){ dir_reg[PC]++; *dec=22016; *dec=*dec|instruction.op3_value<<6|instruction.op2_value<<3|instruction.op1_value; if((dir_reg[instruction.op2_value]+dir_reg[instruction.op3_value])>=0x40000000) IOAccess((uint8_t)(dir_reg[instruction.op2_value]+dir_reg[instruction.op3_value]), &data,Read); else dir_reg[instruction.op1_value]=LDRSB(dir_reg[instruction.op2_value], dir_reg[instruction.op3_value], SRAM); } if(strcmp(instruction.mnemonic,"LDRSH")==0){ dir_reg[PC]++; *dec=24064; *dec=*dec|instruction.op3_value<<6|instruction.op2_value<<3|instruction.op1_value; if((dir_reg[instruction.op2_value]+dir_reg[instruction.op3_value])>=0x40000000) IOAccess((uint8_t)(dir_reg[instruction.op2_value]+dir_reg[instruction.op3_value]), &data,Read); else dir_reg[instruction.op1_value]=LDRSH(dir_reg[instruction.op2_value], dir_reg[instruction.op3_value], SRAM); } if(strcmp(instruction.mnemonic,"STR")==0){ dir_reg[PC]++; if(instruction.op2_type=='S'){ *dec=38912; STR(dir_reg[instruction.op1_value],dir_reg[SP], instruction.op3_value<<2, SRAM); *dec=*dec|instruction.op3_value|instruction.op1_value<<8;} else if(instruction.op3_type=='#' || instruction.op3_type=='N'){ *dec=24576; if((dir_reg[instruction.op2_value]+(instruction.op3_value<<2))>=0x40000000){ IOAccess((uint8_t)(dir_reg[instruction.op2_value]+(instruction.op3_value<<2)), &data,Write);} else{ STR(dir_reg[instruction.op1_value], dir_reg[instruction.op2_value], instruction.op3_value<<2, SRAM);} *dec=*dec|instruction.op3_value<<6|instruction.op2_value<<3|instruction.op1_value; mvprintw(1,3,"Hola");} else{ *dec=20480; if((dir_reg[instruction.op2_value]+dir_reg[instruction.op2_value])>=0x40000000) IOAccess((uint8_t)(dir_reg[instruction.op2_value]+(dir_reg[instruction.op3_value])), &data,Write); else{ STR(dir_reg[instruction.op1_value], instruction.op2_value, instruction.op3_value, SRAM);} *dec=*dec|instruction.op3_value<<6|instruction.op2_value<<3|instruction.op1_value;} } if(strcmp(instruction.mnemonic,"STRB")==0){ dir_reg[PC]++; if(instruction.op3_type=='#' || instruction.op3_type=='N'){ *dec=28672; if(dir_reg[instruction.op2_value]+instruction.op3_value>=0x40000000){ IOAccess((uint8_t)(dir_reg[instruction.op2_value]+instruction.op3_value), &data,Write);} else{ STRB(dir_reg[instruction.op1_value], dir_reg[instruction.op2_value], instruction.op3_value, SRAM);} *dec=*dec|instruction.op3_value<<6|instruction.op2_value<<3|instruction.op1_value;} else{ *dec=21504; if((dir_reg[instruction.op2_value]+dir_reg[instruction.op3_value])>=0x40000000){ IOAccess((uint8_t)(dir_reg[instruction.op2_value]+(dir_reg[instruction.op3_value])), &data,Write);} else{ STRB(dir_reg[instruction.op1_value], dir_reg[instruction.op2_value], dir_reg[instruction.op3_value], SRAM);} *dec=*dec|instruction.op3_value<<6|instruction.op2_value<<3|instruction.op1_value;} } if(strcmp(instruction.mnemonic,"STRH")==0){ dir_reg[PC]++; if(instruction.op3_type=='#' || instruction.op3_type=='N'){ *dec=32768; if(((dir_reg[instruction.op2_value])+(instruction.op3_value<<1))>=0x40000000) IOAccess((uint8_t)(dir_reg[instruction.op2_value]+(instruction.op3_value<<1)),&data,Write); else STRH(dir_reg[instruction.op1_value], dir_reg[instruction.op2_value], instruction.op3_value<<1, SRAM); *dec=*dec|instruction.op3_value<<6|instruction.op2_value<<3|instruction.op1_value;} else{ *dec=20992; if((dir_reg[instruction.op2_value]+dir_reg[instruction.op3_value])>=0x40000000) IOAccess((uint8_t)(dir_reg[instruction.op2_value]+(dir_reg[instruction.op3_value])), &data,Write); else STRH(dir_reg[instruction.op1_value], dir_reg[instruction.op2_value], dir_reg[instruction.op3_value], SRAM); *dec=*dec|instruction.op3_value<<6|instruction.op2_value<<3|instruction.op1_value;} } }