I have the follwing C code. I need to combine the put() function with the processline() function and put it in the main function. You don’t need to worry about what the program does.
processline calls put. Then main function calls processline
So integrate put() into processline(), then intergrate processline() into the main function.
C code:
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
unsigned char * mem;
int reg[9];
int pc;
int memsize;
union converter{
unsigned int integer;
unsigned char bytes[4];
};
void put(char* directive, char* address, char* data){
if (strcmp(directive,”.size”)==0){
int size = (int)strtol (address, NULL, 16);
//NEED TO FIND OUT EXACT MEANING OF size DIRECTIVE, num of chars or bytes
mem = (unsigned char *) malloc(sizeof(char)*size);
memsize = size*sizeof(char);
}
else if(strcmp(directive,”.text”)==0){
int add = (int) strtol (address,NULL,16);
pc = add;
char byte[3];
while(*data!=’