newbie here learning c++ code... i've written a program to translate
basic commands from a programmable HP15C calculator to its assembly
language (i.e., "ent" = "36"). i believe something is wrong
with the function that translates; on unix, it compiles but the
output file shows blocks and $ symbols rather than numbers.
Please help! I have only posted the code for the function, but i can
post the rest of the program if necessary.
Thanks!
void Assemble(fstream & in, fstream & out)
// Purpose: Assemble the HP 15C assembly language program contained in "in" into HP 15C machine language stored in "out".
// Input parameters:
// in --> the file variable for a text input file
// out --> the file variable for a binary output file
{
index bs[100];
int counter;
int x;
for (counter = 0; !in.eof(); counter++)
{
in >> bs[counter].line;
if (strlen(bs[counter].line) == 1)
{
x = strlen(bs[counter].line);
out.write((char* ) &x, 4);
}
else if (strcmp(bs[counter].line, "ent") == 0)
{
x = 36;
out.write((char *) &x, 4);
}
else if (strcmp(bs[counter].line, "sub") == 0)
{
x = 30;
out.write((char *) &x, 4); }
else if (strcmp(bs[counter].line, "mul") == 0)
{
x = 20;
out.write((char *) &x, 4);
}
else if (strcmp(bs[counter].line, "add") == 0)
{
x = 40;
out.write((char *) &x, 4);
}
else if (strcmp(bs[counter].line, "div") == 0)
{
x = 10;
out.write((char *) &x, 4);
}
else if (strcmp(bs[counter].line, "sto") == 0)
{
x = 60;
out.write((char *) &x, 4);
}
else if (strcmp(bs[counter].line, "rcl") == 0)
{
x = 70;
out.write((char *) &x, 4);
}
out.write(("\n"), 4);
}
}