Question
C Code Can someone please help me out with what I'm doing wrong? most of the code it done so I'm not trying to ask
C Code Can someone please help me out with what I'm doing wrong? most of the code it done so I'm not trying to ask you to write it for me. I would be very very grateful if could help me out. The program is meant to take opcodes and run y86 instructions and populates memory based on the "directive" given. You will see down below
#define _GNU_SOURCE
#include
#include
#include
#include
union store{
long num;
unsigned char byte[4];
}storeLong;
//Byte will allow to store a byte into a 4 bit integer.
//The union Byte allows me to store a byte into a 4 bit integer. High and low are used to represent the higher and lower halves of the byte.
union Byte{
struct regpair{
unsigned int high:4;
unsigned int low:4;
}half;
unsigned char overbyte;
}storeByte;
bool programcontinue=true;
unsigned char opcode;
typedef struct processor{
int registers[9];
int counter;
int textAddress;
int last;
int instructionp;
char instructioncp;
}cpu;
int memsize;
bool zf,of,cf;
union converter{
unsigned int integer;
unsigned char bytes[4];
};
void clearFlags(){
zf = false;
of = false;
cf = false;
}
void NOP(unsigned char *memory, cpu *assembler){
assembler->counter+=1;
//printf("nop ran ");
}
void HALT(unsigned char *memory, cpu *assembler){
assembler->counter+=1;
printf(" Program exited with status HLT. ");
exit(0);
}
void RRMOVL(unsigned char *memory, cpu *assembler){
assembler->counter+=1;
int rregs = (int)memory[assembler->counter];
char regs[2];
sprintf(s[0], "%x", rregs);
int reg1 = (int) regs[0] - '0';
int reg2 = (int) regs[1] - '0';
assembler->registers[reg2] = assembler->registers[reg1];
assembler->counter+=1;
}
void IRMOVL(unsigned char *memory, cpu *assembler){
assembler->counter+=1;
//printf("made it into irmovl");
int rregsI = (int) memory [assembler->counter];
rregsI = rregsI - 0xf0;
int value;
assembler->counter+=1;
char bytes[12];
sprintf(bytes, "0x%.02x%.02x%.02x%.02x", memory[assembler->counter+3], memory[assembler->counter+2], memory[assembler->counter+1], memory[assembler->counter+0]);
value = (int)strtol(bytes,NULL,16);
assembler->registers[rregsI] = value;
// printf("Mving %d into registers",value);
// printf("%d ",rregsI);
assembler->counter+=4;
}
void RMMOVL(unsigned char *memory, cpu *assembler){
assembler->counter+=1;
assembler->counter+=1;
unsigned char rA = (memory[assembler->counter] & 0xf0) >> 4;
unsigned char rB = (memory[assembler->counter] & 0x0f);
int reg1 = (int) rA;
int reg2 = (int) rB;
int disp;
assembler->counter+=1;
char bytes[12];
sprintf(bytes, "0x%.02x%.02x%.02x%.02x", memory[assembler->counter+3], memory[assembler->counter+2], memory[assembler->counter+1], memory[assembler->counter+0]);
disp = (int) strtol(bytes,NULL,16);
if (disp + assembler->registers[reg2] > memsize){
printf("Encountered address outside of memory bounds. Program exited with status ADR.");
exit(0);
}
int val = assembler->registers[reg1];
memcpy(&memory[disp + assembler->registers[reg2]],&val,4);
assembler->counter+=4;
}
void MRMOVL(unsigned char *memory, cpu *assembler){
assembler->counter+=1;
unsigned char rA = (memory[assembler->counter] & 0xf0) >> 4;
unsigned char rB = (memory[assembler->counter] & 0x0f);
int reg1 = (int) rA;
int reg2 = (int) rB;
int disp;
assembler->counter+=1;
char bytes[12];
sprintf(bytes, "0x%.02x%.02x%.02x%.02x", memory[assembler->counter+3], memory[assembler->counter+2], memory[assembler->counter+1], memory[assembler->counter+0]);
disp = (int) strtol(bytes,NULL,16);
if(disp + assembler->registers[reg2] > memsize){
printf("Encountered address outside of memory bounds. Program exited with status ADR.");
exit(0);
}
memcpy(&assembler->registers[reg1], &memory[disp + assembler->registers[reg2]], 4);
assembler->counter+=4;
}
void ADDL(unsigned char *memory, cpu *assembler){
assembler->counter+=1;
clearFlags();
unsigned char rA = (memory[assembler->counter] & 0xf0) >> 4;
unsigned char rB = (memory[assembler->counter] & 0x0f);
int reg1 = (int) rA;
int reg2 = (int) rB;
int sum = assembler->registers[reg1] + assembler->registers[reg2];
assembler->registers[reg2] = sum;
of = (unsigned int) assembler->registers[reg2] < (unsigned int) assembler->registers[reg1];
if(sum == 0){
zf = true;
}
if (sum<0){
cf = true;
}
assembler->counter+=1;
}
void SUBL(unsigned char *memory, cpu *assembler){
assembler->counter+=1;
clearFlags();
unsigned char rA = (memory[assembler->counter] & 0xf0) >> 4;
unsigned char rB = (memory[assembler->counter] & 0x0f);
int reg1 = (int) rA;
int reg2 = (int) rB;
int diff = assembler->registers[reg2] - assembler->registers[reg1];
assembler->registers[reg2] = diff;
of = ((assembler->registers[reg1] < 0 && assembler->registers[reg2] > 0 && diff < 0)|| (assembler->registers[reg1] > 0 && assembler->registers[reg2] < 0 && diff > 0));
if(diff == 0){
zf = true;
}
if (diff<0){
cf = true;
}
assembler->counter+=1;
}
void ANDL(unsigned char *memory, cpu *assembler){
assembler->counter+=1;
clearFlags();
unsigned char rA = (memory[assembler->counter] & 0xf0) >> 4;
unsigned char rB = (memory[assembler->counter] & 0x0f);
int reg1 = (int) rA;
int reg2 = (int) rB;
int sum = assembler->registers[reg1] & assembler->registers[reg2];
assembler->registers[reg2] = sum;
if (sum == 0){
zf = true;
}
if (sum < 0){
cf = true;
}
assembler->counter+=1;
}
void XORL(unsigned char *memory, cpu *assembler){
assembler->counter+=1;
clearFlags();
unsigned char rA = (memory[assembler->counter] & 0xf0) >> 4;
unsigned char rB = (memory[assembler->counter] & 0x0f);
int reg1 = (int) rA;
int reg2 = (int) rB;
int sum = assembler->registers[reg1] ^ assembler->registers[reg2];
assembler->registers[reg2] = sum;
if (sum == 0){
zf = true;
}
if (sum < 0){
cf = true;
}
assembler->counter+=1;
}
void MULL(unsigned char *memory, cpu *assembler){
assembler->counter+=1;
clearFlags();
unsigned char rA = (memory[assembler->counter] & 0xf0) >> 4;
unsigned char rB = (memory[assembler->counter] & 0x0f);
int reg1 = (int) rA;
int reg2 = (int) rB;
int prod = assembler->registers[reg1] * assembler->registers[reg2];
assembler->registers[reg2] = prod;
of = (assembler->registers[reg1] > 0 && assembler->registers[reg2] > 0 && prod < 0) || (assembler->registers[reg1] < 0 && assembler->registers[reg2] < 0 && prod > 0) ||(assembler->registers[reg1] < 0 && assembler->registers[reg2] > 0 && prod > 0) ||(assembler->registers[reg1] < 0 && assembler->registers[reg2] < 0 && prod > 0) ;
if (prod == 0){
zf = true;
}
if (prod< 0){
cf = true;
}
assembler->counter+=1;
}
void CMPL(unsigned char *memory, cpu *assembler){
assembler->counter+=1;
clearFlags();
unsigned char rA = (memory[assembler->counter] & 0xf0) >> 4;
unsigned char rB = (memory[assembler->counter] & 0x0f);
int reg1 = (int) rA;
int reg2 = (int) rB;
int val = assembler->registers[reg1] - assembler->registers[reg2];
if(val==0){
zf = true;
}
if(val<0){
cf = true;
}
if((val > 0 && assembler->registers[reg1] > 0 && assembler->registers[reg2] < 0) || ( val < 0 && assembler->registers[reg1] < 0 && assembler->registers[reg2] >0)){
of = true;
}
assembler->counter+=1;
}
void JMP(unsigned char *memory, cpu *assembler){
assembler->counter+=1;
int disp;
char bytes[12];
sprintf(bytes, "0x%.02x%.02x%.02x%.02x", memory[assembler->counter+3], memory[assembler->counter+2], memory[assembler->counter+1], memory[assembler->counter+0]);
disp = (int) strtol(bytes,NULL,16);
assembler->counter = disp;
}
void JLE(unsigned char *memory, cpu *assembler){
assembler->counter+=1;
int disp;
char bytes[12];
sprintf(bytes, "0x%.02x%.02x%.02x%.02x", memory[assembler->counter+3], memory[assembler->counter+2], memory[assembler->counter+1], memory[assembler->counter+0]);
disp = (int) strtol(bytes,NULL,16);
if (zf == true || (cf ^ of))
{
assembler->counter = disp;
return;
}else{
assembler->counter+=4;
}
}
void JL(unsigned char *memory, cpu *assembler){
assembler->counter+=1;
int disp;
char bytes[12];
sprintf(bytes, "0x%.02x%.02x%.02x%.02x", memory[assembler->counter+3], memory[assembler->counter+2], memory[assembler->counter+1], memory[assembler->counter+0]);
disp = (int) strtol(bytes,NULL,16);
if(zf==false && (cf ^ of)){
assembler->counter = disp;
return;
}else{
assembler->counter+=4;
}
}
void JE(unsigned char *memory, cpu *assembler){
assembler->counter+=1;
int disp;
char bytes[12];
sprintf(bytes, "0x%.02x%.02x%.02x%.02x", memory[assembler->counter+3], memory[assembler->counter+2], memory[assembler->counter+1], memory[assembler->counter+0]);
disp = (int) strtol(bytes,NULL,16);
if (zf==true){
assembler->counter = disp;
return;
}else{
assembler->counter+=4;
}
}
void JNE(unsigned char *memory, cpu *assembler){
assembler->counter+=1;
int disp;
char bytes[12];
sprintf(bytes, "0x%.02x%.02x%.02x%.02x", memory[assembler->counter+3], memory[assembler->counter+2], memory[assembler->counter+1], memory[assembler->counter+0]);
disp = (int) strtol(bytes,NULL,16);
if (zf==false){
assembler->counter = disp;
return;
}else{
assembler->counter+=4;
}
}
void JGE(unsigned char *memory, cpu *assembler){
assembler->counter+=1;
int disp;
char bytes[12];
sprintf(bytes, "0x%.02x%.02x%.02x%.02x", memory[assembler->counter+3], memory[assembler->counter+2], memory[assembler->counter+1], memory[assembler->counter+0]);
disp = (int) strtol(bytes,NULL,16);
if (!(zf==false && (cf ^ of))){
assembler->counter = disp;
return;
}else{
assembler->counter+=4;
}
}
void JG (unsigned char *memory, cpu *assembler){
assembler->counter+=1;
int disp;
char bytes[12];
sprintf(bytes, "0x%.02x%.02x%.02x%.02x", memory[assembler->counter+3], memory[assembler->counter+2], memory[assembler->counter+1], memory[assembler->counter+0]);
disp = (int) strtol(bytes,NULL,16);
if (!(zf==true && (cf ^ of))){
assembler->counter = disp;
return;
}else{
assembler->counter+=4;
}
}
void CALL(unsigned char *memory, cpu *assembler){
assembler->counter+=1;
int disp;
char bytes[12];
sprintf(bytes, "0x%.02x%.02x%.02x%.02x", memory[assembler->counter+3], memory[assembler->counter+2], memory[assembler->counter+1], memory[assembler->counter+0]);
disp = (int) strtol(bytes,NULL,16);
assembler->registers[4] = assembler->registers[4] - 4;
union converter con;
con.integer = assembler->counter+4;
memory[assembler->registers[4] + 0] = con.bytes[0];
memory[assembler->registers[4] + 1] = con.bytes[1];
memory[assembler->registers[4] + 2] = con.bytes[2];
memory[assembler->registers[4] + 3] = con.bytes[3];
assembler->counter = disp;
}
void RET(unsigned char *memory, cpu *assembler){
assembler->counter+=1;
int value = assembler->registers[4];
union converter con;
con.bytes[0] = memory[value];
con.bytes[1] = memory[value+1];
con.bytes[2] = memory[value+2];
con.bytes[3] = memory[value+3];
// printf(" ret bytes: %x%x%x%x",memory[value],memory[value+1],memory[value+2],memory[value+3]);
// printf("ret sending me to %d",con.integer);
assembler->counter = con.integer;
assembler->registers[4] = value + 4;
}
void PUSHL(unsigned char *memory, cpu *assembler){
assembler->counter+=1;
unsigned char rA = (memory[assembler->counter] & 0xf0) >> 4;
int reg1 = (int) rA;
assembler->registers[4] = assembler->registers[4] -4;
int value = assembler->registers[reg1];
union converter con;
con.integer = value;
memory[assembler->registers[4] + 0] = con.bytes[0];
memory[assembler->registers[4] + 1] = con.bytes[1];
memory[assembler->registers[4] + 2] = con.bytes[2];
memory[assembler->registers[4] + 3] = con.bytes[3];
assembler->counter+=1;
}
void POPL(unsigned char *memory, cpu *assembler){
assembler->counter+=1;
int rregs = (int)memory[assembler->counter];
char regs[2];
sprintf(s[0], "%x", rregs);
int reg1 = (int) regs[0] - '0';
union converter con;
con.bytes[0] = memory[assembler->registers[4]];
con.bytes[1] = memory[assembler->registers[4]+1];
con.bytes[2] = memory[assembler->registers[4]+2];
con.bytes[3] = memory[assembler->registers[4]+3];
int val = con.integer;
assembler->registers[reg1] = val;
assembler->registers[4] = assembler->registers[4] + 4;
assembler->counter+=1;
}
void READB(unsigned char *memory, cpu *assembler){
assembler->counter+=1;
clearFlags();
//printf("reading...");
int rregs = (int)memory[assembler->counter];
char regs[2];
sprintf(s[0], "%x", rregs);
int reg1 = (int) regs[0] - '0';
assembler->counter+=1;
unsigned int in;
assembler->registers[2] = 30;
scanf("%x", &in);
int disp;
char bytes[12];
sprintf(bytes, "0x%.02x%.02x%.02x%.02x", memory[assembler->counter+3], memory[assembler->counter+2], memory[assembler->counter+1], memory[assembler->counter+0]);
disp = (int) strtol(bytes,NULL,16);
memory[disp+assembler->registers[reg1]] = in;
if(in==EOF){
zf = true;
}else{
zf = false;
}
//printf("Byte read to memory %x", memory[disp+registers[reg1]]);
assembler->counter+=4;
}
void READL(unsigned char *memory, cpu *assembler){
clearFlags();
assembler->counter+=1;
int rregs = (int)memory[assembler->counter];
char regs[2];
sprintf(s[0], "%x", rregs);
int reg1 = (int) regs[0] - '0';
assembler->counter+=1;
unsigned int in;
scanf("%d", &in);
int disp;
char bytes[12];
sprintf(bytes, "0x%.02x%.02x%.02x%.02x", memory[assembler->counter+3], memory[assembler->counter+2], memory[assembler->counter+1], memory[assembler->counter+0]);
disp = (int) strtol(bytes,NULL,16);
union converter con;
con.integer = in;
memory[disp+assembler->registers[reg1]] = con.bytes[0];
memory[disp+assembler->registers[reg1]+1] = con.bytes[1];
memory[disp+assembler->registers[reg1]+2] = con.bytes[2];
memory[disp+assembler->registers[reg1]+3] = con.bytes[3];
assembler->counter+=4;
}
void WRITEB(unsigned char *memory, cpu *assembler){
assembler->counter+=1;
int rregs = (int)memory[assembler->counter];
char regs[2];
sprintf(s[0], "%x", rregs);
int reg1 = (int) regs[0] - '0';
assembler->counter+=1;
int disp;
char bytes[12];
sprintf(bytes, "0x%.02x%.02x%.02x%.02x", memory[assembler->counter+3], memory[assembler->counter+2], memory[assembler->counter+1], memory[assembler->counter+0]);
disp = (int) strtol(bytes,NULL,16);
if (disp + assembler->registers[reg1] > memsize){
printf("Encountered address outside of memory bounds. Program exited with status ADR.");
exit(0);
}
printf("%c",memory[disp+assembler->registers[reg1]]);
assembler->counter+=4;
}
void WRITEL(unsigned char *memory, cpu *assembler){
assembler->counter+=1;
int rregs = (int)memory[assembler->counter];
char regs[2];
sprintf(s[0], "%x", rregs);
int reg1 = (int) regs[0] - '0';
assembler->counter+=1;
int disp;
char bytes[12];
sprintf(bytes, "0x%.02x%.02x%.02x%.02x", memory[assembler->counter+3], memory[assembler->counter+2], memory[assembler->counter+1], memory[assembler->counter+0]);
disp = (int) strtol(bytes,NULL,16);
if (disp + assembler->registers[reg1] > memsize){
printf("Encountered address outside of memory bounds. Program exited with status ADR.");
exit(0);
}
int val;
memcpy(&val,&memory[disp+assembler->registers[reg1]+0],4);
printf("%d",val);
assembler->counter+=4;
}
void MOVSBL(unsigned char *memory, cpu *assembler){
assembler->counter+=1;
unsigned char rA = (memory[assembler->counter] & 0xf0) >> 4;
unsigned char rB = (memory[assembler->counter] & 0x0f);
int reg1 = (int) rA;
int reg2 = (int) rB;
assembler->counter+=1;
int disp;
char bytes[12];
sprintf(bytes, "0x%.02x%.02x%.02x%.02x", memory[assembler->counter+3], memory[assembler->counter+2], memory[assembler->counter+1], memory[assembler->counter+0]);
disp = (int) strtol(bytes,NULL,16);
if(reg2 + disp > memsize){
printf("Encountered address outside of memory bounds. Program exited with status ADR.");
exit(0);
}
unsigned char src = memory[assembler->registers[reg2]+disp];
unsigned char dest[4];
unsigned char test = src & 0x80;
//printf("%x ",src);
//printf("%x",test);
if(test==0x80){
dest[3] = src;
dest[2] = 0xff;
dest[1] = 0xff;
dest[0] = 0xff;
}else{
dest[3] = src;
dest[2] = 0x00;
dest[1] = 0x00;
dest[0] = 0x00;
}
char destbytes[12];
// printf(" movsbling value at registers%d + + %d into registers%d",reg2,disp,reg1);
sprintf(destbytes, "0x%.02x%.02x%.02x%.02x", dest[0],dest[1],dest[2], dest[3]);
int final = (int) strtol(destbytes,NULL,16);
assembler->registers[reg1] = final;
assembler->counter+=4;
}
void runProgram(unsigned char *memory, cpu *assembler){
while(programcontinue == true){
opcode = memory[assembler->counter];
switch(opcode){
case 0x00:
assembler -> counter++;
break;
case 0x10:
programcontinue = false;
break;
case 0x20:
rrmovl(memory,assembler);
break;
case 0x30:
irmovl(memory,assembler);
break;
case 0x40:
rmmovl(memory,assembler);
break;
case 0x50:
mrmovl(memory,assembler);
break;
case 0x60:
addl(memory,assembler);
break;
case 0x61:
subl(memory,assembler);
break;
case 0x62:
andl(memory,assembler);
break;
case 0x63:
xorl(memory,assembler);
break;
case 0x64:
mull(memory,assembler);
break;
case 0x65:
cmpl(memory,assembler);
break;
case 0x70:
jmp(memory,assembler);
break;
case 0x71:
jle(memory,assembler);
break;
case 0x72:
jl(memory,assembler);
break;
case 0x73:
je(memory,assembler);
break;
case 0x74:
jne(memory,assembler);
break;
case 0x75:
jge(memory,assembler);
break;
case 0x76:
jg(memory,assembler);
break;
case 0x80:
call(memory,assembler);
break;
case 0x90:
ret(memory,assembler);
break;
case 0xa0:
pushl(memory,assembler);
break;
case 0xb0:
popl(memory,assembler);
break;
case 0xc0:
readb(memory,assembler);
break;
case 0xc1:
readl(memory,assembler);
break;
case 0xd0:
writeb(memory,assembler);
break;
case 0xd1:
writel(memory,assembler);
break;
case 0xe0:
movsbl(memory,assembler);
break;
default:
printf("error ");
programcontinue=false;
}
}
}
void storeInMemory(char *userInput){
FILE * file=fopen(userInput,"rb");
if(file == 0){ //The file could not be located.
printf("The file could not be opened because it could not be found. ");
}
unsigned char * memory;
//Allocated memory for all components of a line.
char * directive=(char*)malloc(sizeof(char)*10);
char * hexaddress=(char*)malloc(sizeof(char)*10);
char * instruction=(char*)malloc(sizeof(char)*16);
//Size will be used to convert the hex value at .size to decimal.
int size=0;
//Byte and text will be used to create a seperate bytes when reading in as specified by the spec sheet.
char * text;
char * byte=(char*)malloc(sizeof(char)*16);
cpu *assembler=malloc(sizeof(cpu));
while(fscanf(file,"%500s",directive)!=EOF){
//Checks each line's directive and stores based on directive type.
if(strcmp(directive,".size")==0){
fscanf(file,"%500s",directive);
size=strtol(directive, NULL, 16);
memory=(unsigned char*)malloc(size*sizeof(unsigned char));
}else if(strcmp(directive,".string")==0){
unsigned char character;
fscanf(file,"%500s",hexaddress);
int address= (strtol(hexaddress, NULL, 16))- 2;
while(character!= EOF){
character = fgetc (file);
if(character!='"'){
memory[address]=character;
}
if (character == ' '){
break;
}
address++;
}
}else if(strcmp(directive,".long")==0){
fscanf(file,"%500s",hexaddress);
fscanf(file,"%500s",instruction);
long instruct =atoi(instruction);
storeLong.num = instruct;
int address = strtol(hexaddress, NULL, 16);
memory[address]=storeLong.byte[0];
}else if(strcmp(directive,".byte")==0){
fscanf(file,"%500s",hexaddress);
fscanf(file,"%500s",instruction);
byte[0]=instruction[1];
byte[1]='\0';
storeByte.half.high=strtol(byte, NULL, 16);
byte[0]=instruction[0];
byte[1]='\0';
storeByte.half.low= strtol(byte, NULL, 16);
int address = strtol(hexaddress, NULL, 16);
memory[address]=storeByte.overbyte;
}else if(strcmp(directive,".text")==0){
text=( char*)malloc(size*sizeof( char));
fscanf(file,"%500s",hexaddress);
fscanf(file,"%1000s",text);
int address = strtol(hexaddress, NULL, 16);
assembler->counter=strtol(hexaddress, NULL, 16);
int index=0;
int len=strlen(text);
while(index
byte[0]=text[index+1];
byte[1]='\0';
storeByte.half.high=strtol(byte, NULL, 16);
byte[0]=text[index+0];
byte[1]='\0';
storeByte.half.low=strtol(byte, NULL, 16);;
memory[address]=storeByte.overbyte;
index+=2;
address++;
}
assembler->last=address;
}
}
runProgram(memory,assembler);
}
int main(int argc, char **argv){
//We need to grab the user input and allocate seperate each line of the file to check the directive, address, and instruciton to properly store the instruction.
char * input= argv[1];
//If the user doesn't enter an argument then an error is returned
if (argv[1] == NULL){
printf("Error: File name was not designated by name ");
}
if(strcmp(input,"-h")==0){
printf("This program takes in a .y86 file ");
exit(0);
}
storeInMemory(input);
return 0;
}
getting implicit declaration errors. they look like this
y86emul.c: In function runProgram: y86emul.c:966:17: warning: implicit declaration of function rrmovl [-Wimplicit-function-declaration] rrmovl(memory,assembler); ^ y86emul.c:970:17: warning: implicit declaration of function irmovl [-Wimplicit-function-declaration] irmovl(memory,assembler); ^ y86emul.c:973:17: warning: implicit declaration of function rmmovl [-Wimplicit-function-declaration] rmmovl(memory,assembler); ^ y86emul.c:976:17: warning: implicit declaration of function mrmovl [-Wimplicit-function-declaration] mrmovl(memory,assembler); ^ y86emul.c:980:3: warning: implicit declaration of function addl [-Wimplicit-function-declaration] addl(memory,assembler); ^ y86emul.c:984:17: warning: implicit declaration of function subl [-Wimplicit-function-declaration] subl(memory,assembler); ^ y86emul.c:988:17: warning: implicit declaration of function andl [-Wimplicit-function-declaration] andl(memory,assembler); ^ y86emul.c:992:17: warning: implicit declaration of function xorl [-Wimplicit-function-declaration] xorl(memory,assembler); ^ y86emul.c:996:17: warning: implicit declaration of function mull [-Wimplicit-function-declaration] mull(memory,assembler); ^ y86emul.c:999:17: warning: implicit declaration of function cmpl [-Wimplicit-function-declaration] cmpl(memory,assembler); ^ y86emul.c:1002:17: warning: implicit declaration of function jmp [-Wimplicit-function-declaration] jmp(memory,assembler); ^ y86emul.c:1005:17: warning: implicit declaration of function jle [-Wimplicit-function-declaration] jle(memory,assembler); ^ y86emul.c:1008:17: warning: implicit declaration of function jl [-Wimplicit-function-declaration] jl(memory,assembler); ^ y86emul.c:1011:17: warning: implicit declaration of function je [-Wimplicit-function-declaration] je(memory,assembler); ^ y86emul.c:1014:17: warning: implicit declaration of function jne [-Wimplicit-function-declaration] jne(memory,assembler); ^ y86emul.c:1017:17: warning: implicit declaration of function jge [-Wimplicit-function-declaration] jge(memory,assembler); ^ y86emul.c:1020:17: warning: implicit declaration of function jg [-Wimplicit-function-declaration] jg(memory,assembler); ^ y86emul.c:1023:17: warning: implicit declaration of function call [-Wimplicit-function-declaration] call(memory,assembler); ^ y86emul.c:1026:17: warning: implicit declaration of function ret [-Wimplicit-function-declaration] ret(memory,assembler); ^ y86emul.c:1030:17: warning: implicit declaration of function pushl [-Wimplicit-function-declaration] pushl(memory,assembler); ^ y86emul.c:1034:17: warning: implicit declaration of function popl [-Wimplicit-function-declaration] popl(memory,assembler); ^ y86emul.c:1038:17: warning: implicit declaration of function readb [-Wimplicit-function-declaration] readb(memory,assembler); ^ y86emul.c:1042:3: warning: implicit declaration of function readl [-Wimplicit-function-declaration] readl(memory,assembler); ^ y86emul.c:1045:17: warning: implicit declaration of function writeb [-Wimplicit-function-declaration] writeb(memory,assembler); ^ y86emul.c:1049:17: warning: implicit declaration of function writel [-Wimplicit-function-declaration] writel(memory,assembler); ^ y86emul.c:1053:17: warning: implicit declaration of function movsbl [-Wimplicit-function-declaration] movsbl(memory,assembler); ^ /tmp/cc4e6fbZ.o: In function `runProgram': y86emul.c:(.text+0x2188): undefined reference to `rrmovl' y86emul.c:(.text+0x21a5): undefined reference to `irmovl' y86emul.c:(.text+0x21c2): undefined reference to `rmmovl' y86emul.c:(.text+0x21df): undefined reference to `mrmovl' y86emul.c:(.text+0x21fc): undefined reference to `addl' y86emul.c:(.text+0x2219): undefined reference to `subl' y86emul.c:(.text+0x2236): undefined reference to `andl' y86emul.c:(.text+0x2253): undefined reference to `xorl' y86emul.c:(.text+0x2270): undefined reference to `mull' y86emul.c:(.text+0x228d): undefined reference to `cmpl' y86emul.c:(.text+0x22aa): undefined reference to `jmp' y86emul.c:(.text+0x22c7): undefined reference to `jle' y86emul.c:(.text+0x22e4): undefined reference to `jl' y86emul.c:(.text+0x2301): undefined reference to `je' y86emul.c:(.text+0x231e): undefined reference to `jne' y86emul.c:(.text+0x233b): undefined reference to `jge' y86emul.c:(.text+0x2358): undefined reference to `jg' y86emul.c:(.text+0x2375): undefined reference to `call' y86emul.c:(.text+0x2392): undefined reference to `ret' y86emul.c:(.text+0x23af): undefined reference to `pushl' y86emul.c:(.text+0x23cc): undefined reference to `popl' y86emul.c:(.text+0x23e9): undefined reference to `readb' y86emul.c:(.text+0x2403): undefined reference to `readl' y86emul.c:(.text+0x241d): undefined reference to `writeb' y86emul.c:(.text+0x2437): undefined reference to `writel' y86emul.c:(.text+0x2451): undefined reference to `movsbl' collect2: error: ld returned 1 exit status
__________________________________________
okay so i have to run this file from the command line. It should ask you for an integer and give you factorial back.
_________________________________________________________________
.size 1800
.string 04 "Enter an integer>>"
.long 20 0
.long 24 0
.byte 28 0a
.text 100 30f4001800002045804a0100001000a05f204530f01000000061044075fcffffff30f001000000627773450100005035fcffffff61032037800f0100005035fcffffff64302054b05f90a05f204530f30400000030f00100000030f212000000d03f0000000060036102746001000030f120000000c11f0000000073ae010000507100000000800f01000030f124000000400100000000d11f0000000030f128000000d01f00000000704e0100002054b05f90
______________________
save that as a .txt file in the directory and run it
if you could get this running for me within the the day, it would mean the world. let me know if you have any questions.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started