void Phaser::changepar(int npar, unsigned char value) { switch (npar) { case 0: setvolume(value); break; case 1: setpanning(value); break; case 2: lfo.Pfreq = value; lfo.updateparams(); break; case 3: lfo.Prandomness = value; lfo.updateparams(); break; case 4: lfo.PLFOtype = value; lfo.updateparams(); barber = (2 == value); break; case 5: lfo.Pstereo = value; lfo.updateparams(); break; case 6: setdepth(value); break; case 7: setfb(value); break; case 8: setstages(value); break; case 9: setlrcross(value); setoffset(value); break; case 10: Poutsub = (value > 1) ? 1 : value; break; case 11: setphase(value); setwidth(value); break; case 12: Phyper = min((int)value, 1); break; case 13: setdistortion(value); break; case 14: Panalog = value; break; } }
/* CLEAR-SUBR subr */ LVAL xclearsubr() { LVAL x = xlgasubr(); xllastarg(); setsubr(x, errsubr); setoffset(x, 0); setmulvalp(x, FALSE); return NIL; }
void Analog_Phaser::changepar (int npar, int value) { switch (npar) { case 0: setvolume (value); break; case 1: setdistortion (value); break; case 2: lfo.Pfreq = value; lfo.updateparams (); break; case 3: lfo.Prandomness = value; lfo.updateparams (); break; case 4: lfo.PLFOtype = value; lfo.updateparams (); barber = 0; if (value == 2) barber = 1; break; case 5: lfo.Pstereo = value; lfo.updateparams (); break; case 6: setwidth (value); break; case 7: setfb (value); break; case 8: setstages (value); break; case 9: setoffset (value); break; case 10: if (value > 1) value = 1; Poutsub = value; break; case 11: setdepth (value); break; case 12: if (value > 1) value = 1; Phyper = value; break; }; };
char* reg(FILE* fp,Operand h,int flag){ if(h->kind==CONSTANT){ fprintf(fp,"li $t%d, %d\n",flag,h->u.value); if(flag==1) return "$t1"; else if(flag==2) return "$t2"; else return "$t3"; } if(getoffset(h)!=-1){ if(flag==1){ fprintf(fp,"lw $t1, %d($sp)\n",getoffset(h)); return "$t1"; } if(flag==2){ fprintf(fp,"lw $t2, %d($sp)\n",getoffset(h)); return "$t2"; } if(flag==3){ fprintf(fp,"lw $t3, %d($sp)\n",getoffset(h)); return "$t3"; } } else{ setoffset(h,stackoffset); stackoffset=stackoffset+4; if(flag==1) return "$t1"; else if(flag==2) return "$t2"; else return "$t3"; } }
void mipscode(code* h,char* filename){ FILE *fp=fopen(filename,"w"); if(fp==NULL){ printf("fail to open file\n"); return; } fprintf(fp,".data\n"); fprintf(fp,"_prompt: .asciiz \"Enter an integer:\"\n"); fprintf(fp,"_ret: .asciiz \"\\n\"\n"); fprintf(fp,".globl main\n"); fprintf(fp,".text\n"); fprintf(fp,"read:\n"); fprintf(fp,"li $v0, 4\n"); fprintf(fp,"la $a0, _prompt\n"); fprintf(fp,"syscall\n"); fprintf(fp,"li $v0 5\n"); fprintf(fp,"syscall\n"); fprintf(fp,"jr $ra\n"); fprintf(fp,"\n"); fprintf(fp,"write:\n"); fprintf(fp,"li $v0, 1\n"); fprintf(fp,"syscall\n"); fprintf(fp,"li $v0, 4\n"); fprintf(fp,"la $a0, _ret\n"); fprintf(fp,"syscall\n"); fprintf(fp,"move $v0, $0\n"); fprintf(fp,"jr $ra\n"); fprintf(fp,"\n"); printf("begin hhh\n"); code* p=h; code *tempcode; while(p!=NULL){ switch(p->word.kind){ case LAB: fprintf(fp,"%s:\n",getop(p->word.u.lab.op1)); break; case ASSIGN: if(p->word.u.assign.right->kind==CONSTANT){ fprintf(fp,"li %s, %d\n",reg(fp,p->word.u.assign.left,1),p->word.u.assign.right->u.value); save(fp,p->word.u.assign.left,1); } else{ fprintf(fp,"move %s, %s\n",reg(fp,p->word.u.assign.left,1),reg(fp,p->word.u.assign.right,2)); save(fp,p->word.u.assign.left,1); } break; case ADD: fprintf(fp,"add %s, %s, %s\n",reg(fp,p->word.u.calcu.result,1),reg(fp,p->word.u.calcu.op1,2),reg(fp,p->word.u.calcu.op2,3)); save(fp,p->word.u.calcu.result,1); break; case MIN: fprintf(fp,"sub %s, %s, %s\n",reg(fp,p->word.u.calcu.result,1),reg(fp,p->word.u.calcu.op1,2),reg(fp,p->word.u.calcu.op2,3)); save(fp,p->word.u.calcu.result,1); break; case MUL: fprintf(fp,"mul %s, %s, %s\n",reg(fp,p->word.u.calcu.result,1),reg(fp,p->word.u.calcu.op1,2),reg(fp,p->word.u.calcu.op2,3)); save(fp,p->word.u.calcu.result,1); break; case DIVID: fprintf(fp,"div %s, %s\n",reg(fp,p->word.u.calcu.op1,2),reg(fp,p->word.u.calcu.op2,3)); fprintf(fp,"mflo %s\n",reg(fp,p->word.u.calcu.result,1)); save(fp,p->word.u.calcu.result,1); break; case ADDRTO: fprintf(fp,"lw %s, 0(%s)\n",reg(fp,p->word.u.assign.left,1),reg(fp,p->word.u.assign.right,2)); save(fp,p->word.u.assign.left,1); break; case TOADD: fprintf(fp,"sw %s,0(%s)\n",reg(fp,p->word.u.assign.right,1),reg(fp,p->word.u.assign.left,2)); break; case GOTO: fprintf(fp,"j %s\n",getop(p->word.u.got.op1)); break; case CALL: case READ: case WRITE: parnum=0; if(p->word.kind==WRITE) fprintf(fp,"move $a0, %s\n",reg(fp,p->word.u.ret.op1,1)); fprintf(fp,"addi $sp, $sp, %d\n",stackoffset+4); fprintf(fp,"sw $ra, -4($sp)\n"); if(p->word.kind==CALL) fprintf(fp,"jal %s\n",getop(p->word.u.assign.right)); else if(p->word.kind==READ) fprintf(fp,"jal read\n"); else{ fprintf(fp,"jal write\n"); } fprintf(fp,"lw $ra, -4($sp)\n"); fprintf(fp,"addi $sp, $sp, -%d\n",stackoffset+4); if(p->word.kind==CALL) fprintf(fp,"move %s,$v0\n",reg(fp,p->word.u.assign.left,1)); else fprintf(fp,"move %s,$v0\n",reg(fp,p->word.u.ret.op1,1)); if(p->word.kind==CALL) save(fp,p->word.u.assign.left,1); else save(fp,p->word.u.ret.op1,1); break; case RET: fprintf(fp,"move $v0, %s\n",reg(fp,p->word.u.ret.op1,1)); fprintf(fp,"jr $ra\n"); break; case IFGOTO: printf("%s\n",getop(p->word.u.ifgoto.op4)); if(strcmp(getop(p->word.u.ifgoto.op2),"==")==0) fprintf(fp,"beq %s, %s, %s\n",reg(fp,p->word.u.ifgoto.op1,1),reg(fp,p->word.u.ifgoto.op3,2),getop(p->word.u.ifgoto.op4)); else if(strcmp(getop(p->word.u.ifgoto.op2),"!=")==0) fprintf(fp,"bne %s, %s, %s\n",reg(fp,p->word.u.ifgoto.op1,1),reg(fp,p->word.u.ifgoto.op3,2),getop(p->word.u.ifgoto.op4)); else if(strcmp(getop(p->word.u.ifgoto.op2),">")==0) fprintf(fp,"bgt %s, %s, %s\n",reg(fp,p->word.u.ifgoto.op1,1),reg(fp,p->word.u.ifgoto.op3,2),getop(p->word.u.ifgoto.op4)); else if(strcmp(getop(p->word.u.ifgoto.op2),"<")==0) fprintf(fp,"blt %s, %s, %s\n",reg(fp,p->word.u.ifgoto.op1,1),reg(fp,p->word.u.ifgoto.op3,2),getop(p->word.u.ifgoto.op4)); else if(strcmp(getop(p->word.u.ifgoto.op2),">=")==0) fprintf(fp,"bge %s, %s, %s\n",reg(fp,p->word.u.ifgoto.op1,1),reg(fp,p->word.u.ifgoto.op3,2),getop(p->word.u.ifgoto.op4)); else fprintf(fp,"ble %s, %s, %s\n",reg(fp,p->word.u.ifgoto.op1,1),reg(fp,p->word.u.ifgoto.op3,2),getop(p->word.u.ifgoto.op4)); break; case FUNCTION: fprintf(fp, "\n"); fprintf(fp,"%s:\n",getop(p->word.u.ret.op1)); stackoffset=0; break; case ARG: while(p->next->word.kind == ARG)p=p->next; tempcode = p; parnum = 0; while(tempcode->word.kind==ARG){ if(parnum<=3){ fprintf(fp,"move $a%d, %s\n",parnum,reg(fp,tempcode->word.u.ret.op1,1)); parnum++; } else{ fprintf(fp,"sw %s, %d($sp)\n",reg(fp,tempcode->word.u.ret.op1,1),stackoffset+4+(parnum-4)*4); parnum++; } tempcode = tempcode->pre; } break; case PARAM: tempcode = p; parnum=0; while(tempcode->word.kind == PARAM){ parnum++; tempcode=tempcode->next; } tempcode = p; if(parnum<=4) stackoffset = 0; else stackoffset = (parnum-4)*4; for(int i=0;i<parnum;i++){ setoffset(tempcode->word.u.ret.op1,stackoffset); stackoffset+=4; tempcode=tempcode->next; } tempcode = p; for(int i=0;i<4 && tempcode->word.kind == PARAM;i++){ fprintf(fp, "sw $a%d, %d($sp)\n",i,getoffset(tempcode->word.u.ret.op1)); tempcode = tempcode->next; } if(parnum>=4){ for(int i=4;i<=parnum;++i){ fprintf(fp, "lw $t1, %d($sp)\n", (i-4)*4); fprintf(fp, "sw $t1, %d($sp)\n", getoffset(tempcode->word.u.ret.op1)); tempcode = tempcode->next; } } for(;p->next->word.kind == PARAM;p=p->next); parnum=0; break; /*for(int i=4;i<parnum;i++){ if(i<4) fprintf(fp,"sw $a%d, %d($sp)\n",i,(i+parnum-4)*4); else{ fprintf(fp,"lw $t1, %d($sp)\n",(i-4)*4); fprintf(fp,"sw $t1, %d($sp)\n",(i+parnum-4)*4); } } else for(int i=0;i<parnum;i++) fprintf(fp,"sw $a%d, %d($sp)\n",i,i*4); for(;p->next->word.kind==PARAM;) p=p->next; */ default: printf("not finished\n"); } p=p->next; } fclose(fp); return; }
/* block_hook - called at block entry */ static void block_hook(void *cl, Symbol *p) { while (*p) setoffset(*p++, tos); }