Example #1
0
void initialise(void) 				//make the LCD ready for 4-bit data interface
{
	_delay_ms(20);   				//Power-up delay
	RS_port &= ~(1<<RS_bit);		//RS-bit low i.e selecting the Instruction Register
	E_port &= ~(1<<E_bit);			//Enable low

	//3-step reset sequence as mentioned in the Instruction manual

	send_data(Reset);				//Step-1
	_delay_ms(5);

	send_data(Reset);				//Step-2
	_delay_us(200);

	send_data(Reset);				//Step-3
	_delay_us(200);

	send_data(Set4_bit);			//4-bit interface set-up
	_delay_ms(5);					//Data up-time

	write_instruction(Set4_bit);	//Set lines,font and mode
	_delay_ms(5);					//Data up-time

	write_instruction(Display_off);	//Turn off the display
	_delay_ms(5);					//Delay

	write_instruction(clear);		//Clear everyhthing from screen i.e empty the display RAM
	_delay_ms(4);					//Delay

	write_instruction(Entry_mode);	//Instruct the chip how you want to enter the data i.e left-to-right / right-to-left
	_delay_us(80);					//We have chosen left-to-right mode i.e the cursor moves from left-to-right

	write_instruction(Display_on);	//Finally, turn the display-on so that we can start printing the data
	_delay_us(80);					//Delay
}
Example #2
0
int main()
{
	//4 data lines
	D7_DDR |= (1<<D7_bit); //Sets PD7 as output
	D6_DDR |= (1<<D6_bit); //Sets PD6 as output
	D5_DDR |= (1<<D5_bit); //Sets PD5 as output
	D4_DDR |= (1<<D4_bit); //Sets PD4 as output

	E_DDR |= (1<<E_bit);	//sets enable pin as output
	RS_DDR |= (1<<RS_bit);	//sets Register_select pin as output

	uint8_t Name1[] = "Akash Deep Singh"; //String Name1
	uint8_t Name2[] = "Vahini Ummalaneni";//String Name2

	initialise();
	while(1)
	{
		print_string(Name1);		       //Prints Name1
		_delay_ms(2000);				   //Wait for 2s
		write_instruction(clear);          //clear the screen
		_delay_ms(4);					   //wait time
		print_string(Name2);		       //Prints Name2
		_delay_ms(2000);				   //Wait for 2s
		write_instruction(clear);          //clear the screen
		_delay_ms(4);					   //wait time

	}
	return 0;
}
Example #3
0
int	write_file(t_label *list, char *name, header_t *header)
{
  int	fd;

  fd = create_file(name);
  write_header(fd, header, list);
  write_instruction(fd, list);
  return (0);
}
Example #4
0
void SDI_Start(void)
{

	while(1) {
		uint8_t command[CMD_LEN];
		UART_GetData(command, CMD_LEN);
	
		if (command[0] == 'w' && command[1] == 'i') {
			write_instruction(command);
		} else if ( command[0] == 'w' && command[1] == 'd' ) {
			write_data(command);
		} else if ( command[0] == 'r' && command[1] == 'd' ) {
			read_data(command);
		} else if ( command[0] == 'e') {
			execute(command);
		}
	}
}
Example #5
0
static void write_code(struct oport *f, struct code *c)
{
  u16 nbins, i;

  GCPRO2(f, c);
  nbins = code_length(c);
  if (c->varname)
    {
      write_string(f, prt_display, c->varname);
      pputs(": ", f);
    }
  pprintf(f, "Code[");
  write_string(f, prt_display, c->filename);
  pprintf(f, ":%u] %u bytes:\n", c->lineno, nbins);
  i = 0;
  while (i < nbins)
    i += write_instruction(f, c->ins + i, i);

  pprintf(f, "\n%u locals, %u stack\n",
	  c->nb_locals, c->stkdepth);
  GCPOP(2);
}
Example #6
0
int write_binary_file(char* n){
    assert(n!=NULL);

    char fname[512];
    strcpy(fname, n);
    strcat(fname, ".abc");
    puts(fname);

    FILE *fp;
    fp = fopen(fname, "wb");

    if(fp == NULL){
        return -1;
    }

    unsigned magic = 340200501;
	fwrite(&programVarOffset, sizeof(unsigned), 1, fp);


    write_const_tables(fp);

    unsigned numInstr = currInstruction - 1;
    fwrite(&numInstr, sizeof(unsigned), 1, fp);
    unsigned i;
    for(i=1; i<currInstruction; i++){
        write_instruction(fp, &instructions[i]);
    }

    fclose(fp);

    numConsts = NULL;
    stringConsts = NULL;
    namedLibfuncs = NULL;
    userFuncs = NULL;
    instructions = NULL;

    return 0;
}
Example #7
0
void process_instruction(char *line) {
	const char *p = strchr(line, ' ');
	char inst[32];
	char param[32];
	memset(&inst,0,sizeof(inst));
	memset(&param,0,sizeof(param));
	int end = strlen(line);
	if(p) {
		end = p - line;
	}
	strncpy(inst, line, end);
	EShaderInstruction instruction =  find_instruction_by_name(inst);
	EOperandInfo oper;
	memset(&oper,0,sizeof(oper));

	printf("Inst: %s\n", inst);

	char operandtxt[128];
	int idx = 1;

	EOperandInfo operand;
	memset(&operand,0,sizeof(operand));

	InstructionModifiers modifiers;
	memset(&modifiers, 0, sizeof(modifiers));

	parse_result_modifiers(line, &modifiers);
	while(true) {
		memset(&operandtxt,0,sizeof(operand));
		find_nth((char *)line, idx++, operandtxt, sizeof(operand));
		if(strlen(operandtxt) < 1 || idx-1 > MAX_OPERANDS) break;
		parse_operand(operandtxt, &operand, idx-2, instruction);
		printf("oper: %s\n", operandtxt);
	}
	write_instruction(instruction, &operand, &modifiers);
	
}
Example #8
0
/*
 *	assemble a file and load into memory
 */
Assembly* parse_file(FILE* file) {
	Assembly* assembly;					/* assembly structure */
	int labelid;								/* new label id */
	Segment* current_segment;		/* holds current segment */
	char line[MAX_LINE];				/* holds one line */
	char* items[MAX_ARGS];			/* split line into items (split on ' ' and '\t') */
	int segment;								/* holds current segment id */
	int count, i, size;					/* loop variables */
	long long params[MAX_ARGS];	/* parsed items array */
	char sbuffer[1024];					/* 1K string buffer */
	char* sourcefile;						/* current source file */
	Label* label;
	
	/* initialize variables */
	assembly = new_assembly();
	labelid = 0;
	
	linenr = 0;
	segment = UNKNOWN;
	sourcefile = NULL;
	
	/* read a line lines (returns nr of characters read, -1 if eof) */
	while(read_line(file, line, MAX_LINE) >= 0) {
		linenr++;
		/* get rid of spaces/tabs in front of the line */
		trim_line(line);

		/* split the line on spaces/tabs */
		count = split_line(line, items);
		/* note: line == items[0] */
		
		/* check if the line was not empty */
		if (strlen(line) > 0) {
			if (strcmp(line, "code") == 0) {
				/* code segment */
				segment = CODE;
				current_segment = assembly->code;
			} else if (strcmp(line, "bss") == 0) {
				/* bss segment */
				segment = BSS;
				/* bss has no segment structure */
				/* (no point in saving uninitialized data */
				current_segment = 0;
			} else if (strcmp(line, "lit") == 0) {
				/* lit segment */
				segment = LIT;
				current_segment = assembly->lit;
			} else if (strcmp(line, "data") == 0) {
				/* data segment */
				segment = DATA;
				current_segment = assembly->data;
			} else if (strcmp(line, "export") == 0) {
				/* mark label as public */
				if (count != 2) error(linenr, "invalid number of parameters");
				label = get_label(assembly, items[1]);
				/* any exported function should be included */
				label->accessed = 1;
				label->exported = TRUE;
			} else if (strcmp(line, "import") == 0) {
				/* mark label as imported */
				if (count != 2) error(linenr, "invalid number of parameters");
				get_label(assembly, items[1])->imported = TRUE;
			} else if (segment == UNKNOWN) {
				/* all other things must be in segments */
				error(linenr, "code outside segment");
			} else if (strcmp(line, "align") == 0) {
				/* align a segment */
				if (count != 2) error(linenr, "invalid number of parameters");
				params[0] = parse_numeric(items[1]);
				if (segment == BSS) {
					/* align bss just by size */
					while(assembly->bss_size % params[0]) assembly->bss_size++;
				} else {
					align_segment(current_segment, params[0]);
				}
			}	else if (strcmp(line, "byte") == 0) {
				/* one byte of data */
				if (count != 3) error(linenr, "invalid number of parameters");
				if (segment == BSS) {
					error(linenr, "can't put initialized data in bss, use data segment instead");
				} else {
					/* parse */
					params[0] = parse_numeric(items[1]);
					params[1] = parse_numeric(items[2]);
					/* write to segment */
					MS_WriteBE(current_segment->data, params[1], (int)params[0]);
					for (i = 0; i < (int)params[0]; i++) MS_WriteBit(current_segment->mask, FALSE);
				}
			}	else if (strcmp(line, "skip") == 0) {
				/* some empty space */
				if (count != 2) error(linenr, "invalid number of parameters");
				/* parse */
				params[0] = parse_numeric(items[1]);
				if (segment == BSS) {
					/* for bss: just update the size */
					assembly->bss_size += params[0];
				} else {
					/* for other segment: write zeros */
					MS_Write(current_segment->data, 0, (int)params[0]);
					for (i = 0; i < (int)params[0]; i++) MS_WriteBit(current_segment->mask, FALSE);
				}
			} else if (strcmp(line, "address") == 0) {
				/* insert address to label here */

				/* some empty space */
				if (count != 2) error(linenr, "invalid number of parameters");
				/* write the id to the current segment */
				MS_WriteBE(current_segment->data, get_label(assembly, items[1])->id, PTR_SIZE);
				/* needs to be resolved */
				for (i = 0; i < PTR_SIZE; i++) MS_WriteBit(current_segment->mask, TRUE);
			} else if (strcmp(line, "line") == 0) {
				if (count < 2) error(linenr, "invalid number of parameters");
				if (sourcefile == NULL) error(linenr, "file directive must precede line directive");

				size = sprintf(sbuffer, "$%s:", sourcefile);
				for (i = 1; i < count; i++) {
					size += sprintf(sbuffer+size, "%s", items[i]);
					if (i == count-1) {
						sbuffer[size++] = 0;
					} else {
						sbuffer[size++] = ' ';
					}
				}
				
				/* register debug label */
				label = get_label(assembly, sbuffer);
				if (label->segment == UNKNOWN) {
					if (segment == BSS) {
						label->location = assembly->bss_size;
					} else {
						label->location = current_segment->data->size;
					}
					label->segment = segment;
				}
				/* mark as debug function, set accessed to 1 to include it in the assembly */
				label->accessed = 1;
				label->debuginfo = LABEL_DEBUG_LINE;
			} else if (strcmp(line, "file") == 0) {
				if (count < 2) error(linenr, "invalid number of parameters");

				size = sprintf(sbuffer, "$");
				for (i = 1; i < count; i++) {
					size += sprintf(sbuffer+size, "%s", items[i]);
					if (i == count-1) {
						sbuffer[size++] = 0;
					} else {
						sbuffer[size++] = ' ';
					}
				}

				if (sourcefile != NULL) free(sourcefile);
				sourcefile = malloc(size-1);
				strcpy(sourcefile, sbuffer+1);
				
				/* register debug label */
				label = get_label(assembly, sbuffer);
				if (segment == BSS) {
					label->location = assembly->bss_size;
				} else {
					label->location = current_segment->data->size;
				}
				label->segment = segment;
				/* mark as debug function, set accessed to 1 to include it in the assembly */
				label->accessed = 1;
				label->debuginfo = LABEL_DEBUG_FILE;
			} else if (strcmp(line, "local") == 0) {
				if (count < 3) error(linenr, "invalid number of parameters");

				size = sprintf(sbuffer, "$");
				for (i = 1; i < count; i++) {
					if (i != 2) {
						size += sprintf(sbuffer+size, "%s", items[i]);
						if (i == count-1) {
							sbuffer[size++] = 0;
						} else {
							sbuffer[size++] = ' ';
						}
					}
				}
				
				/* register debug label */
				label = get_label(assembly, sbuffer);
				label->location = parse_numeric(items[2]);				

				label->segment = UNKNOWN;
				/* mark as debug function, set accessed to 1 to include it in the assembly */
				label->accessed = 1;
				label->debuginfo = LABEL_DEBUG_LOCAL;
			} else if (strcmp(line, "param") == 0) {
				if (count < 3) error(linenr, "invalid number of parameters");

				size = sprintf(sbuffer, "$");
				for (i = 1; i < count; i++) {
					if (i != 2) {
						size += sprintf(sbuffer+size, "%s", items[i]);
						if (i == count-1) {
							sbuffer[size++] = 0;
						} else {
							sbuffer[size++] = ' ';
						}
					}
				}
				
				/* register debug label */
				label = get_label(assembly, sbuffer);
				label->location = parse_numeric(items[2]);
				label->segment = UNKNOWN;
				/* mark as debug function, set accessed to 1 to include it in the assembly */
				label->accessed = 1;
				label->debuginfo = LABEL_DEBUG_PARAM;
			} else if (strcmp(line, "global") == 0) {
				if (count < 2) error(linenr, "invalid number of parameters");

				size = sprintf(sbuffer, "$");
				for (i = 1; i < count; i++) {
					size += sprintf(sbuffer+size, "%s", items[i]);
					if (i == count-1) {
						sbuffer[size++] = 0;
					} else {
						sbuffer[size++] = ' ';
					}
				}
				
				/* register debug label */
				label = get_label(assembly, sbuffer);
				label->ref = get_label(assembly, items[1]);
				/* mark as debug function, set accessed to 1 to include it in the assembly */
				label->accessed = 1;
				label->debuginfo = LABEL_DEBUG_GLOBAL;
			} else if (strcmp(line, "function") == 0) {
				if (count < 2) error(linenr, "invalid number of parameters");

				size = sprintf(sbuffer, "$");
				for (i = 1; i < count; i++) {
					size += sprintf(sbuffer+size, "%s", items[i]);
					if (i == count-1) {
						sbuffer[size++] = 0;
					} else {
						sbuffer[size++] = ' ';
					}
				}
				
				/* register debug label */
				label = get_label(assembly, sbuffer);
				label->ref = get_label(assembly, items[1]);
				/* mark as debug function, set accessed to 1 to include it in the assembly */
				label->accessed = 1;
				label->debuginfo = LABEL_DEBUG_FUNCTION;
			} else if (strcmp(line, "label") == 0) {
				/* a label; register */
				if (count != 2) error(linenr, "invalid number of parameters");

				if (segment == BSS) {
					register_label(assembly, items[1], segment, assembly->bss_size);
				} else {
					register_label(assembly, items[1], segment, current_segment->data->size);
				}
			} else if (strcmp(line, "typedef") == 0) {
				if (count < 2) error(linenr, "invalid number of parameters");

				size = sprintf(sbuffer, "$");
				for (i = 1; i < count; i++) {
					size += sprintf(sbuffer+size, "%s", items[i]);
					if (i == count-1) {
						sbuffer[size++] = 0;
					} else {
						sbuffer[size++] = ' ';
					}
				}

				/* register debug label */
				label = get_label(assembly, sbuffer);
				/* mark as debug function, set accessed to 1 to include it in the assembly */
				label->accessed = 1;
				label->debuginfo = LABEL_DEBUG_TYPEDEF;
			} else if (strcmp(line, "field") == 0) {
				if (count < 2) error(linenr, "invalid number of parameters");

				size = sprintf(sbuffer, "$");
				for (i = 1; i < count; i++) {
					if (i != 2) {
						size += sprintf(sbuffer+size, "%s", items[i]);
						if (i == count-1) {
							sbuffer[size++] = 0;
						} else {
							sbuffer[size++] = ' ';
						}
					}
				}

				/* register debug label */
				label = get_label(assembly, sbuffer);
				label->location = parse_numeric(items[2]);				

				label->segment = UNKNOWN;
				/* mark as debug function, set accessed to 1 to include it in the assembly */
				label->accessed = 1;
				label->debuginfo = LABEL_DEBUG_FIELD;
			} else {
				/* not identified; should be an instruction */
				write_instruction(assembly, items, count, current_segment);
			}
		}
	}	
	
	if (sourcefile != NULL) free(sourcefile);

	/* return the structure */
	return assembly;
}
int iAPSExpPlusPlugin::set_param(int ndx, kxparam_t value)
{
	_params[ndx] = value; // saving value into _params[] for later use

	double x;
	int gain1;
	double gain2;
	kxparam_t t;


	switch (ndx)
	{
	case ATTACK_TIME_ID:
		x = value + 0.1; //range is 0.1 to 500 ms
		x=1.0/x;
		x=0.9999992783202552+x*(-0.04795182062779634+
		x*(0.001135741853172241+x*-1.508962701294095E-05));
		set_dsp_register(_ATTACK_TIME, _dbl_to_dspword(x));
		break;
	case RELEASE_TIME_ID:
		x = (double)value; //range is 50 to 3000 ms
		x=1.0/x;
		x=0.9999999999551990+x*(-0.04797083163562625+
		x*(0.001240522577384484+x*-0.003723766234607763));
		set_dsp_register(_RELEASE_TIME, _dbl_to_dspword(x)); // writing value to level register with conversion from double to dsp's dword		
		break;
	case POST_GAIN_ID:
		x = (double)value; //range is -60 to 60 dB
		if (x>=0) //0 to 60
		{
		x=0.02346134384321507+0.9998151510352060*exp(-x/(-
		8.685689951326771));
		//gain1 = x;
		gain1 = static_cast < int > ( x ); //convert to int to truncate
		gain2 = x - gain1; //get fractional part
		set_dsp_register(_POST_GAIN_1, gain1); // writing value to level register with conversion from double to dsp's dword
		set_dsp_register(_POST_GAIN_2, _dbl_to_dspword(gain2));
		break;
		}
		x=(-7.575249529383578E-07)+0.9999997493552754*exp(-x/
		(-8.685892422025119));
		gain1 = 0;
		gain2 = x;
		set_dsp_register(_POST_GAIN_1, gain1); // writing value to level register with conversion from double to dsp's dword
		set_dsp_register(_POST_GAIN_2, _dbl_to_dspword(gain2));
		break;
	case THRESHOLD_ID:
		x = (double)value -16.0; //range is -60 to 0 dB
		x=1.000000000116500+x*0.005190512648478571;
		set_dsp_register(_THRESHOLD, _dbl_to_dspword(x)); // writing value to level register with conversion from double to dsp's dword
		break;
	case RATIO_ID:
		x = (double)value; //range is 1 to 100
		x=(-444515.6696800559+x*444516.3104954770)/
		(1.0+x*(444516.3056633568));
		set_dsp_register(_RATIO, _dbl_to_dspword(x)); // writing value to level register with conversion from double to dsp's dword
		break;
	case PREDELAY_ID:
		value = value/10;
		// reading delay start (write) address, adding predelay time to it and writing to delay read address
		// left channel predelay
		get_tram_addr(_R_PREDELAY_LW, (dword *) &t);
		set_tram_addr(_R_PREDELAY_LR, (dword)(t + 2 + value * SAMPLES_PER_MSEC));
		// right channel predelay
		get_tram_addr(_R_PREDELAY_RW, (dword *) &t);
		set_tram_addr(_R_PREDELAY_RR, (dword)(t + 2 + value * SAMPLES_PER_MSEC));
		break;
	case SIDECHAIN_ID:

		// if off write normal "read input" instructions
		if (!value)
		{
			write_instruction(0, 0x0,0x800b,0x4000,0x2040,0x2040);
			write_instruction(1, 0x0,0x800c,0x4001,0x2040,0x2040);
			write_instruction(2, 0x0,0x800e,0x800b,0x2040,0x2040);
			write_instruction(3, 0x0,0x8012,0x800c,0x2040,0x2040);
		}
		// if on write "read side chain" instructions
		else
		{
			write_instruction(0, 0x0,0x800b,0x4002,0x2040,0x2040);
			write_instruction(1, 0x0,0x800c,0x4003,0x2040,0x2040);
			write_instruction(2, 0x0,0x800e,0x4000,0x2040,0x2040);
			write_instruction(3, 0x0,0x8012,0x4001,0x2040,0x2040);
		}
	}

	// when "control panel" (cp) for plugin is loaded, this will "synchronize" ui controls to plugin parameters
	if (cp) ((iAPSExpPlusPluginDlg*) cp)->sync(ndx);

	return 0;
}
Example #10
0
    void xml_writer_impl::write_element(const variant& element)
    {
        try
        {
            if (element.is<variant::Collection>() && element.empty() && element.type() != variant::DataTable)
            {
                write_empty_element();
                return;
            }

            switch(element.type())
            {
            case variant::None:
            {
                write_empty_element();
                break;
            }
            case variant::Any:
            case variant::String:
            {
                if (element.as<std::string>().empty())
                {
                    write_empty_element();
                    break;
                }
            }
            case variant::Float:
            case variant::Double:
            case variant::Int32:
            case variant::UInt32:
            case variant::Int64:
            case variant::UInt64:
            case variant::Boolean:
            case variant::Date:
            case variant::Time:
            case variant::DateTime:
            {
                m_os << start_tag();
                write_text(element);
                m_os << end_tag();
                break;
            }
            case variant::Dictionary:
            case variant::Bag:
            {
                if ((m_mode & xml_mode::Preserve)!=0)
                {
                    if (element.has_key(xml_attributes))
                    {
                        m_stack.top().m_attributes = element[xml_attributes];

                        if (element.size()==1)
                        {
                            write_empty_element();
                            break;
                        }
                    }

                    m_os << start_tag();

                    bool prev_is_text = false;
                    variant::const_iterator it, end(element.end());
                    for (it=element.begin(); it!=end; ++it)
                    {
                        if (it.key()==xml_attributes)
                        {
                            continue;
                        }
                        else if (it.key()==xml_text)
                        {
                            write_text(it.value());
                            prev_is_text = true;
                        }
                        else if (it.key()==xml_instruction)
                        {
                            push(it.key());

                            if (!prev_is_text)
                            {
                                m_os << indent();
                            }

                            write_instruction(it.value());

                            prev_is_text = false;

                            pop();
                        }
                        else if (it.key()==xml_comment)
                        {
                            push(it.key());

                            if (!prev_is_text)
                            {
                                m_os << indent();
                            }

                            write_comment(it.value());

                            prev_is_text = false;

                            pop();
                        }
                        else
                        {
                            push(it.key());

                            if (!prev_is_text)
                            {
                                m_os << indent();
                            }

                            write_element(it.value());

                            prev_is_text = false;

                            pop();
                        }
                    }

                    if (!prev_is_text)
                    {
                        m_os << indent();
                    }

                    m_os << end_tag();
                }
                else
                {
                    m_os << start_tag();

                    variant::const_iterator it, end(element.end());
                    for (it=element.begin(); it!=end; ++it)
                    {
                        push(it.key());

                        m_os << indent();
                        write_variant(it.value());

                        pop();
                    }

                    m_os << indent() << end_tag();
                }

                break;
            }
            case variant::List:
            {
                m_os << start_tag();

                BOOST_FOREACH(const variant& item, element)
                {
                    push();
                    m_os << indent();
                    write_variant(item);
                    pop();
                }

                m_os << indent();
                m_os << end_tag();

                break;
            }
            case variant::Tuple:
            {
                m_stack.top().m_attributes.insert("size", variant(element.size()));
                m_os << start_tag();

                BOOST_FOREACH(const variant& item, element)
                {
                    push();
                    m_os << indent();
                    write_variant(item);
                    pop();
                }

                m_os << indent();
                m_os << end_tag();
                break;
            }
            case variant::TimeSeries:
            {
                m_os << start_tag();

                variant::const_iterator it, end = element.end();
                for (it=element.begin(); it!=end; ++it)
                {
                    push().insert("time", variant(it.time()));
                    m_os << indent();
                    write_variant(it.value());
                    pop();
                }

                m_os << indent();
                m_os << end_tag();
                break;
            }
            case variant::DataTable:
            {
                const data_table& dt = element.m_value.get<variant::DataTable>();

                m_stack.top().m_attributes
                    .insert("rows",    variant(dt.size()))
                    .insert("columns", variant(dt.columns().size()));
                m_os << start_tag();

                if (!dt.columns().empty())
                {
                    push("Columns");
                    m_os << indent() << start_tag();

                    for (data_table::column_container_type::const_iterator column_iter = dt.columns().begin()
                           ; column_iter != dt.columns().end()
                           ; ++column_iter)
                    {
                        push("Column")
                            .insert("name", variant(column_iter->name()))
                            .insert("type", variant(variant::enum_to_string(column_iter->type())));
                        m_os << indent();
                        write_empty_element();
                        pop();
                    }

                    m_os << indent() << end_tag();
                    pop();
                }

                for (data_table::column_container_type::const_iterator column_iter = dt.columns().begin()
                       ; column_iter != dt.columns().end()
                       ; ++column_iter)
                {
                    push("Column").insert("name", variant(column_iter->name()));
                    m_os << indent() << start_tag();

                    if (column_iter->type() & variant_base::Primitive)
                    {
                        boost::scoped_ptr<data_table_column_writer> column_writer(
                            make_data_table_column_stream_writer(*column_iter, m_os)
                        );

                        while (column_writer->has_next())
                        {
                            push("V");
                            m_os << indent() << start_tag();
                            column_writer->write();
                            m_os << end_tag();
                            pop();

                            column_writer->advance();
                        }
                    }
                    else
                    {
                        variant::const_iterator iter(column_iter->begin());
                        variant::const_iterator end(column_iter->end());
                        while (iter != end)
                        {
                            push("V");
                            m_os << indent();
                            write_variant(*(iter++));
                            pop();
                        }
                    }

                    m_os << indent() << end_tag();
                    pop();
                }

                m_os << indent();
                m_os << end_tag();

                break;
            }
            case variant::Buffer:
            {
                m_os << start_tag();
                const void *data = element.as<void*>();
                size_t size = element.size();
                if (data!=nullptr && size>0)
                {
                    unsigned int n = 0;
                    boost::scoped_ptr<char> b64(detail::b64_encode((const char*)data, (unsigned int)size, &n));
                    if (!b64.get())
                    {
                        boost::throw_exception(variant_error("Unable to base64 encode data"));
                    }
                    m_os << b64.get();
                }
                m_os << end_tag();
                break;
            }
            case variant::Object:
            {
                const object& obj(element.as<object>());

                // write class name
                m_stack.top().m_attributes
                    .insert("class", variant(obj.name()))
                    .insert("version", variant(obj.version()));

                m_os << start_tag();

                // write parameter dictionary
                variant params;
                obj.deflate(params);
                push("params");
                m_os << indent();
                write_variant(params);
                pop();

                m_os << indent();
                m_os << end_tag();

                break;
            }
            case variant::Exception:
            {
                m_os << start_tag();

                exception_data e(element.as<exception_data>());

                push("type");
                m_os << indent();
                write_element(variant(e.type()));
                pop();
                
                push("message");
                m_os << indent();
                write_element(variant(e.message()));
                pop();

                if (!e.source().empty())
                {
                    push("source");
                    m_os << indent();
                    write_element(variant(e.source()));
                    pop();
                }

                if (!e.stack().empty())
                {
                    push("stack");
                    m_os << indent();
                    write_element(variant(e.stack()));
                    pop();
                }

                m_os << indent();
                m_os << end_tag();
                break;
            }
            case variant::Array:
            {
                const typed_array& a(element.as<typed_array>());
                m_stack.top().m_attributes
                    .insert("size", variant(a.size()))
                    .insert("type", variant(variant::enum_to_string(a.type())));
                
                m_os << start_tag();

                for (size_t i=0; i<a.size(); ++i)
                {
                    push();
                    m_os << indent();
                    write_element(variant(a[i]));
                    pop();
                }

                m_os << indent();
                m_os << end_tag();
                break;
            }
            default:
                 boost::throw_exception(variant_error("Case exhaustion: " + variant::enum_to_string(element.type()))); 
            }
Example #11
0
    void xml_writer_impl::write_document(const variant& document)
    {
        try
        {
            if ((m_mode & xml_mode::NoHeader)==0)
            {
                // output the XML header
                write_header();
            }

            if ((m_mode & xml_mode::Preserve)!=0)
            {
                bool first(true);
                if (document.is<variant::Mapping>())
                {
                    std::string element_name;
                    variant::const_iterator it, end(document.end());
                    for (it=document.begin(); it!=end; ++it)
                    {
                        if (it.key()==xml_text)
                        {
                            boost::throw_exception(variant_error("Encountered text in document node"));
                        }
                        else if (it.key()==xml_attributes)
                        {
                            boost::throw_exception(variant_error("Encountered attributes in document node"));
                        }
                        else if (it.key()==xml_instruction)
                        {
                            if (!first)
                            {
                                m_os << indent();
                            }
                            write_instruction(it.value());
                        }
                        else if (it.key()==xml_comment)
                        {
                            if (!first)
                            {
                                m_os << indent();
                            }
                            write_comment(it.value());
                        }
                        else
                        {
                            if (element_name.empty())
                            {
                                element_name = it.key();
                            }
                            else
                            {
                                boost::throw_exception(variant_error((boost::format("Illegal element %s encountered in document, expecting single element %s at root") % it.key() % element_name).str()));
                            }

                            push(it.key());
                            if (!first)
                            {
                                m_os << indent();
                            }
                            write_element(it.value());
                            pop();
                        }
                        first = false;
                    }
                }
                else
                {
                    boost::throw_exception(variant_error("Invalid document structure, root node must be a Dictionary or Bag"));
                }
            }
            else
            {
                push();
                write_variant(document);
                pop();
            }
        }
        catch (const std::exception &e)
        {
            boost::throw_exception(variant_error(e.what()));
        }
        catch (...)
        {
            boost::throw_exception(variant_error("Unhandled Exception"));
        }
    }
Example #12
0
int ifuzzPlugin::set_param(int ndx, kxparam_t value)
{
	_params[ndx] = value;
	double x;
	double omega,sn,cs,alpha,scal,dumm;
	double eqfreq,eqband;
        double a0, a1, a2, b0, b1, b2;
	kxparam_t v_id;

	switch (ndx)
	{

	case LED_DC://add dc
		if(!_params[SW_OC]){
		    if(value) set_dsp_register(DC_P, _dbl_to_dspword(0.002));
		    else set_dsp_register(DC_P, 0);
		}
		break;

	case LED_BPS1://bypass BP filter
		 
		if(value) {	
			    write_instruction(1, 0x0u,0x8019u, 0x8019u, 0x2040u, 0x2040u);
				write_instruction(2, 0x0u,0x8019u, 0x8019u, 0x2040u, 0x2040u);
				write_instruction(3, 0x0u,0x8019u, 0x8019u, 0x2040u, 0x2040u);
				write_instruction(4, 0x0u,0x8019u, 0x8019u, 0x2040u, 0x2040u);
				write_instruction(5, 0x0u,0x8019u, 0x8019u, 0x2040u, 0x2040u);
				write_instruction(6, 0x0u,0x8019u, 0x8019u, 0x2040u, 0x2040u);
				write_instruction(7, 0x0u,0x8019u, 0x8019u, 0x2040u, 0x2040u);
				
			}
			
		else {
		        write_instruction(1, 0x0u ,0x2040u, 0x2040u, 0x8009u, 0x8005u);
	            write_instruction(2, 0x7u, 0x8009u, 0x8008u, 0x8008u, 0x8004u);
	            write_instruction(3, 0x7u, 0x8008u, 0x8019u, 0x800bu, 0x8007u);
	            write_instruction(4, 0x7u, 0x800bu, 0x800au, 0x800au, 0x8006u);
	            write_instruction(5, 0x0u, 0x800au, 0x2056u, 0x8019u, 0x8003u);
	            write_instruction(6, 0x6u, 0x800au, 0x2056u, 0x800au, 0x2040u);
	            write_instruction(7, 0x0u, 0x8019u, 0x800au, 0x2040u, 0x2040u);
			}
            
		break;

	case LED_BPS2://bypass LP filter
		if(value) {
			write_instruction(17, 0x0u, 0x2040u, 0x2040u, 0x2040u, 0x2040u);
			write_instruction(24, 0x0u, 0x2040u, 0x2040u, 0x2040u, 0x2040u);
		}
		else  {
			write_instruction(17, 0x0u, 0x8019u, 0x8013u, 0x2040u, 0x2040u);
			write_instruction(24, 0x0u, 0x8019u, 0x8017u, 0x2040u, 0x2040u);
		}
		break;

	case LED_X2://clean level *2
		if(_params[SW_OC]){
		  if(value) write_instr_y(25, 0x2042u);
		  else write_instr_y(25, 0x2041u);
		}
		break;

	case SW_ST://switch solid state/tube
		if(!_params[SW_OC]){	
		if(value) {//tube
			write_instruction(8, 0xcu,0x8019u,0x8019u,0x8002u,0x2040u);
			write_instruction(9, 0x0u,0x8019u,0x8019u,0x2040u,0x2040u);
			write_instruction(10, 0x0u,0x8019u,0x8019u,0x2040u,0x2040u);
			get_param(DRIVE, &v_id);
			set_dsp_register(DRIVE_P, v_id/4);

			
		}
		else {//solid state
			write_instruction(8, 0x4u,0x8019u,0x2040u,0x8019u,0x8002u);
			write_instruction(9, 0xbu,0x8019u,0x801c,0x801c,0x8019u);
			write_instruction(10, 0xau,0x8019u,0x801d,0x801d,0x8019u);
			get_param(DRIVE, &v_id);
			set_dsp_register(DRIVE_P, v_id*10);
		}
		}
		break;

	case SW_OC://overdrive/clean channel switch
		if(value) {//clean
			write_instr_r(8, 0x2040u);
			write_instr_r(9, 0x2040u);
			write_instr_r(10, 0x2040u);
		
			if(_params[LED_X2]) write_instr_y(25, 0x2042u);//if x2 led is on
			if(_params[LED_DC]) set_dsp_register(DC_P, 0);//if dc led is on, remove dc
		

            get_param(LEVEL_CLEAN, &v_id);
			x = (double)v_id;
	        set_dsp_register(MASTER_P, _dbl_to_dspword(x/FRAMES));			
		}
		else {//overdrive
			write_instr_r(8, 0x8019u);
			write_instr_r(9, 0x8019u);
			write_instr_r(10, 0x8019u);
			
		    write_instr_y(25, 0x2041u);//return gain to 1 (from x2 led)
			if(_params[LED_DC]) set_dsp_register(DC_P, _dbl_to_dspword(0.002));//if dc led is on, add dc

		    
			if(_params[SW_ST]) {//tube
		        write_instruction(8, 0xcu,0x8019u,0x8019u,0x8002u,0x2040u);
			    write_instruction(9, 0x0u,0x8019u,0x8019u,0x2040u,0x2040u);
			    write_instruction(10, 0x0u,0x8019u,0x8019u,0x2040u,0x2040u);
			    get_param(DRIVE, &v_id);
			    set_dsp_register(DRIVE_P, v_id/4);
			}
	     	else {//solid state
			    write_instruction(8, 0x4u,0x8019u,0x2040u,0x8019u,0x8002u);
			    write_instruction(9, 0xbu,0x8019u,0x801c,0x801c,0x8019u);
			    write_instruction(10, 0xau,0x8019u,0x801d,0x801d,0x8019u);
			    get_param(DRIVE, &v_id);
			    set_dsp_register(DRIVE_P, v_id*10);
			}
		    get_param(LEVEL_DRIVE, &v_id);
			x = (double)v_id;
	        set_dsp_register(MASTER_P, _dbl_to_dspword(x/FRAMES));	
	}

		break;

    case LEVEL_DRIVE:
		if(!_params[SW_OC]){
		x = (double)value;
	    set_dsp_register(MASTER_P, _dbl_to_dspword(x/FRAMES));
		}
		break;

	case LEVEL_CLEAN:
		if(_params[SW_OC]){
		x = (double)value;
	    set_dsp_register(MASTER_P, _dbl_to_dspword(x/FRAMES));
		}
		break;

	case DRIVE:
		if(_params[SW_ST]) set_dsp_register(DRIVE_P, value/4);//tube
		else set_dsp_register(DRIVE_P, value*10);//solid state
		break;

	case I_FREQ:
		eqfreq = (double)value*(10000/(FRAMES-1));
		if (eqfreq<166) eqfreq=166;
	    
	    get_param(I_WID, &v_id);
		eqband=v_id*(2000/(FRAMES-1))/800.;
		if(eqband <= 0.05) eqband=0.05;
	    //eqfreq = int(20 * exp((log(20000 / 20)/(double)(20000 - 20))*(double)(eqfreq)));
	    omega = (2.*pi)*(eqfreq/48000.);

        sn    = sin(omega);
        cs    = cos(omega);

		alpha = sn/(2*eqband);
        dumm = 2.;
				
		a0 =   1. + alpha;
		scal = dumm*a0;
		b0 =  ((1. - cs)/2.)/scal;
        b1 =  (1.-cs)/scal;
        b2 =  ((1. - cs)/2.)/scal;
        a1 =  (-2.*cs)/(scal*-1.);
        a2 =   (1.-alpha)/(scal*-1.);

		set_dsp_register(LOW_B0, _dbl_to_dspword(b0));
		set_dsp_register(LOW_B1, _dbl_to_dspword(b1));
		set_dsp_register(LOW_B2, _dbl_to_dspword(b2));
		set_dsp_register(LOW_A1, _dbl_to_dspword(a1));
		set_dsp_register(LOW_A2, _dbl_to_dspword(a2));
		break;

	case O_FREQ:
		eqfreq=(double)value*(10000/(FRAMES-1));
		if (eqfreq<166) eqfreq=166;
	    
	    get_param(O_WID, &v_id);
		eqband=v_id*(1000/(FRAMES-1))/800.;
		if(eqband <= 0.05) eqband=0.05;
	    //eqfreq = int(20 * exp((log(20000 / 20)/(double)(20000 - 20))*(double)(eqfreq)));

        omega = (2.*pi)*(eqfreq/48000.);
        sn    = sin(omega);
        cs    = cos(omega);
        alpha = sn/(2*eqband);
	    dumm = 2.;
				
		a0 =   1. + alpha;
		scal = dumm*a0;
		b0 =  alpha/scal;
		b1 =  0;
        b2 =  (-1. * alpha)/scal;
        a1 =  (-2.*cs)/(scal*-1.);
        a2 =   (1.-alpha)/(scal*-1.);

		set_dsp_register(B_B0, _dbl_to_dspword(b0));
		set_dsp_register(B_B1, _dbl_to_dspword(b1));
		set_dsp_register(B_B2, _dbl_to_dspword(b2));
		set_dsp_register(B_A1, _dbl_to_dspword(a1));
		set_dsp_register(B_A2, _dbl_to_dspword(a2));
		break;

	case I_WID:
		get_param(I_FREQ, &v_id);
		eqfreq=(double)v_id*(10000.0/(FRAMES-1));
		if (eqfreq<166) eqfreq=166;
	    
	
		eqband=value*(2000/(FRAMES-1))/800.;
		if(eqband <= 0.05) eqband=0.05;
	    //eqfreq = int(20 * exp((log(20000 / 20)/(double)(20000 - 20))*(double)(eqfreq)));
	    omega = (2.*pi)*(eqfreq/48000.);

        sn    = sin(omega);
        cs    = cos(omega);

		alpha = sn/(2*eqband);
        dumm = 2.;
				
		a0 =   1. + alpha;
		scal = dumm*a0;
		b0 =  ((1. - cs)/2.)/scal;
        b1 =  (1.-cs)/scal;
        b2 =  ((1. - cs)/2.)/scal;
        a1 =  (-2.*cs)/(scal*-1.);
        a2 =   (1.-alpha)/(scal*-1.);

		set_dsp_register(LOW_B0, _dbl_to_dspword(b0));
		set_dsp_register(LOW_B1, _dbl_to_dspword(b1));
		set_dsp_register(LOW_B2, _dbl_to_dspword(b2));
		set_dsp_register(LOW_A1, _dbl_to_dspword(a1));
		set_dsp_register(LOW_A2, _dbl_to_dspword(a2));
		break;

	case O_WID:
		get_param(O_FREQ, &v_id);
		eqfreq=(double)v_id*(10000.0/(FRAMES-1));;
		if (eqfreq<166) eqfreq=166;
	    
	
		eqband=value*(1000/(FRAMES-1))/800.;
	    if(eqband <= 0.05) eqband=0.05;
		//eqfreq = int(20 * exp((log(20000 / 20)/(double)(20000 - 20))*(double)(eqfreq)));

        omega = (2.*pi)*(eqfreq/48000.);
        sn    = sin(omega);
        cs    = cos(omega);
        alpha = sn/(2*eqband);
	    dumm = 2.;
				
		a0 =   1. + alpha;
		scal = dumm*a0;
		b0 =  alpha/scal;
		b1 =  0;
        b2 =  (-1. * alpha)/scal;
        a1 =  (-2.*cs)/(scal*-1.);
        a2 =   (1.-alpha)/(scal*-1.);

		set_dsp_register(B_B0, _dbl_to_dspword(b0));
		set_dsp_register(B_B1, _dbl_to_dspword(b1));
		set_dsp_register(B_B2, _dbl_to_dspword(b2));
		set_dsp_register(B_A1, _dbl_to_dspword(a1));
		set_dsp_register(B_A2, _dbl_to_dspword(a2));
		break;

	
	}

	// we need to synchronize the GUI part, if set_param was called by the mixer or kX Automation
	if (cp) ((ifuzzPluginDlg*) cp)->sync(ndx);

	return 0;
}
void initialize_display()
{
	//wait for a short period, maybe the voltage needs to stabilize first
	_delay_ms(50);
	
	//initialize 4 bit mode
	write_instruction(INSTRUCTION_FUNCTION_SET_INIT_0);
	write_instruction(INSTRUCTION_FUNCTION_SET_INIT_1);
	write_instruction(INSTRUCTION_FUNCTION_SET_INIT_2);
	
	//initialize everything else
	//NOTE: In case you need an other initialization-routine (blinking cursor, 
	//double line height etc.) choose the appropriate instructions from 
	//the ST7036 datasheet and adjust the C-defines at the top of this file
	write_instruction(INSTRUCTION_BIAS_SET);
	write_instruction(INSTRUCTION_POWER_CONTROL);
	write_instruction(INSTRUCTION_FOLLOWER_CONTROL);
	write_instruction(INSTRUCTION_CONTRAST_SET);
	write_instruction(INSTRUCTION_INSTRUCTION_SET_0);
	write_instruction(INSTRUCTION_DISPLAY_ON);
	write_instruction(INSTRUCTION_CLEAR_DISPLAY);
	write_instruction(INSTRUCTION_ENTRY_MODE);
}
void set_cursor(char row, char column)
{
	write_instruction(CHARACTER_BUFFER_BASE_ADDRESS + row * CHARACTERS_PER_ROW + column);
}
int main() {
		//////////////////////////////////////////////////////
    // init
    int16_t* raw_fft_input = (int16_t*) RAW_INPUT_ADDR;    // size: 512 * 16 / 32 = 200 (0x100)
    int16_t* fft_input = (int16_t*) INPUT_ADDR;            // size: 512 * 16 * 2 / 32 * 1.5 = 768 (0x300)
    int16_t* fft_output = (int16_t*) OUTPUT_ADDR;          // size: 257 * 16 * 2 / 32 * 1.5 = 386 (0x182)
    int16_t* window_parameter = (int16_t*) WINDOW_PARA_ADDR;   // size: 400 * 16 / 32 = 200 (0xC8).
    int16_t* dft_parameter_r = (int16_t*) DFT_PARA_ADDR;       // size: 2 * 2 * 16 / 32 = 2 (0x2). 14 fractional bits 
    int16_t* dft_parameter_i = (int16_t*) DFT_PARA_ADDR + DFT_SIZE * DFT_SIZE * sizeof(int16_t);
    int16_t* mfcc_input = (int16_t*) MFCC_INPUT_ADDR;          // size: 257 * 16 * 2 / 32 = 257 (0x101)
//    int16_t* dct_parameter = DCT_PARA_ADDR;
    init_input(raw_fft_input, WINDOW_SIZE);
    window_init(window_parameter, WINDOW_SIZE);
    dft_init(dft_parameter_r, dft_parameter_i, DFT_SIZE);
//    dct_init(dct_parameter);

		//////////////////////////////////////////////////////
    // PE init
		uint16_t inst_no;
		set_dnn_insts();
		set_nli_parameters();
    *REG_WAIT_BEFORE_VDD = 0xff;
      *DNN_SRAM_RSTN_0 = 0x000007ff;
      *DNN_SRAM_RSTN_1 = 0x000007ff;
      *DNN_SRAM_RSTN_2 = 0x000007ff;
      *DNN_SRAM_RSTN_3 = 0x000007ff;
      delay(3);

      *DNN_SRAM_ISOL_0 = 0x000007ff;
      *DNN_SRAM_ISOL_1 = 0x000007ff;
      *DNN_SRAM_ISOL_2 = 0x000007ff;
      *DNN_SRAM_ISOL_3 = 0x000007ff;
      delay(3);

      *DNN_PG_0 = 0x000007ff;
      *DNN_PG_1 = 0x000007ff;
      *DNN_PG_2 = 0x000007ff;
      *DNN_PG_3 = 0x000007ff;
      delay(5);

      //*DNN_PG_0 = 0x003ff800;
      //*DNN_PG_1 = 0x003ff800;
      //*DNN_PG_2 = 0x003ff800;
      //*DNN_PG_3 = 0x003ff800;
      //delay(3);

      *DNN_SRAM_RSTN_0 = 0x000007ff;
      *DNN_SRAM_RSTN_0 = 0xffffffff;
      *DNN_SRAM_RSTN_1 = 0xffffffff;
      *DNN_SRAM_RSTN_2 = 0xffffffff;
      *DNN_SRAM_RSTN_3 = 0xffffffff;
      delay(3);
//      *DNN_RAND_0 = 1;
//      *DNN_RAND_1 = 1;
//      *DNN_RAND_2 = 1;
//      *DNN_RAND_3 = 1;
//      delay(3);
      
      //*DNN_SRAM_ISOL_0 = 0x00000000;
      //*DNN_SRAM_ISOL_1 = 0x00000000;
      //*DNN_SRAM_ISOL_2 = 0x00000000;
      //*DNN_SRAM_ISOL_3 = 0x00000000;
      //delay(3);

    signal_debug(1);    // init ends; start counting runtime
		//////////////////////////////////////////////////////
    // M0 working sequence
    
    // TODO: optimize these arrays
    int16_t input_r_dft[FFT_SIZE];
    int16_t input_i_dft[FFT_SIZE];

    // prepare fft
    fft_apply_window(WINDOW_SIZE, raw_fft_input, window_parameter); 
    prepare_dft_for_fft(WINDOW_SIZE, FFT_SIZE, raw_fft_input, input_r_dft, FFT_NUM, FFT_NUM_BITS, DFT_SIZE);

    // dft
    dft(DFT_SIZE, FFT_SIZE, input_r_dft, input_i_dft, dft_parameter_r, dft_parameter_i);
 
    prepare_PE_fft_input(fft_input, input_r_dft, input_i_dft, DFT_SIZE, FFT_SIZE, FFT_PREC);
    signal_debug(2);    // M0 ends; write to PE

    // write to PE
    uint16_t fft_input_space = FFT_SIZE / 2;   // DLC memory occupied. for 16 bits only
    write_dnn_sram_16(FFT_START, fft_input, fft_input_space);
    signal_debug(0);    // start PE runtime, check if memory correct
		//////////////////////////////////////////////////////
    // PE working sequence
    inst_no = 0;
    reset_PE(0);
    write_instruction(inst_no, 0, 0);   // write FFT 0
   
    while (inst_no < FFT_INST - 1) {
      if (inst_no % 2 == 0) {
        switch_inst_buffer(0, 0);
        reset_PE(0);
			  start_pe_inst(0b0001);                    // start FFT 0, 2, 4, 6
			  inst_no++;
        write_instruction(inst_no, 0, 1);         // write FFT 1, 3, 5, 7
//        clock_gate();
      } else {
        switch_inst_buffer(0, 1);
        reset_PE(0);
			  start_pe_inst(0b0001);              // start FFT 1, 3, 5
			  inst_no++;
        write_instruction(inst_no, 0, 0);   // write FFT 2, 4, 6
//        clock_gate(); 
      }
    }

    switch_inst_buffer(0, 1);
    reset_PE(0);
		start_pe_inst(0b0001);        // start FFT 7
		inst_no++;
//    clock_gate(); 

		// finish
    wait_until_pe_finish(0b1111);
		//////////////////////////////////////////////////////

    uint16_t fft_output_space = MFCC_SIZE / 2;   // DLC memory occupied. for 16 bits only 
    read_dnn_sram_16(FFT_START, fft_output, fft_output_space); 
    extract_fft_output(fft_output, mfcc_input, MFCC_SIZE, FFT_PREC);

    // MFCC
//  run_mfcc();   // TODO: on PE

//    mfcc_to_dnn(test, test1);

    signal_done();
    delay(7000);
    return 1;
 		// done
}
Example #16
0
void write_print(michet_t *michet, char *text_to_print, size_t len)
{
  uint8_t instruction;

  // mov edx, len
  write_instruction(michet->fp, MOV+EDX);
  write_instruction(michet->fp, len);
  write_padding(michet->fp);

  // mov ecx, 0xA0
  write_instruction(michet->fp, MOV+ECX);
  write_instruction(michet->fp, 0xA0); // 0xA0 is the address where the string starts

  // Unknown bits
  write_instruction(michet->fp, 0x90);
  write_instruction(michet->fp, 0x04);
  write_instruction(michet->fp, 0x08);

  // mov ebx, 1
  write_instruction(michet->fp, MOV+EBX);
  write_instruction(michet->fp, 0x01);
  write_padding(michet->fp);

  // mov eax, 4
  write_instruction(michet->fp, MOV+EAX);
  write_instruction(michet->fp, 0x04);
  write_padding(michet->fp);

  // int 0x80
  write_instruction(michet->fp, INT);
  write_instruction(michet->fp, 0x80);

  // mov eax, 1
  write_instruction(michet->fp, MOV+EAX);
  write_instruction(michet->fp, 0x01);
  write_padding(michet->fp);

  // int 0x80
  write_instruction(michet->fp, INT);
  write_instruction(michet->fp, 0x80);
  write_padding(michet->fp);

  fwrite(text_to_print, len, 1, michet->fp);

  fflush(michet->fp);

}