IN MIPS ASSEMBLY
Macro File: Create macros to print an int, print a char, print a string, get a string from the user, open file, close file, read file, and allocate heap memory. You can use more macros than these if you like.
Main Program File:
#include<sys/types.h>
#includ<sys/stat.h>
#include <fcntl.h>
int open (const char* Path, int flags [, int mode ]);
extern int errno;
int main()
{
int fd = open("foo.txt", O_RDONLY | O_CREAT);
printf("fd = %d/n", fd);
if (fd ==-1)
{
printf("Error Number % d\n", errno);
perror("Program");
}
return 0;
}
int main()
{
int fd1 = open("foo.txt", O_RDONLY);
if (fd1 < 0)
{
perror("c1");
exit(1);
}
printf("opened the fd = % d\n", fd1);
if (close(fd1) < 0)
{
perror("c1");
exit(1);
}
printf("closed the fd.\n");
}
Get Answers For Free
Most questions answered within 1 hours.