Question: Operating Systems ( CS 3 3 0 ) Assignment 0 1 High - Level, Assembly and Machine Languages Submission Date: Wednesday, 7 th February 2
Operating Systems CS
Assignment
HighLevel, Assembly and Machine Languages
Submission Date: Wednesday, th February
Important instructions
Complete explanation must be handwritten, no typed assignments will be
accepted
Please upload the pdf on the LMS
Screenshots must be included in the assignment.
If the assignment is not on the LMS it will not be graded
In this assignment you will explore assembly and machine languages. You already know
that when a highlevel language program is compiled a machine language program gets
generated that can be directly executed. What does such a machine language program
look like? How can an exe file be viewed and modified?
a As a first step you will first write a simple C program to add two integers and
compile it with gcc GNU C compiler As an example, the following is the
Hello World program in C You can modify it to make it add two integers.
#include
#include
int mainint argc, char argv
printfHello World of C;
The compilation command in Linux would be: gcc o HelloWorld
HelloWorld.c assuming that this program is saved in the file
HelloWorld.c Completing a
b The compiler gcc has an option to generate the compiled code is assembly
language. Find out how such an option can be used and use it to generate
assembly language code for your highlevel program for adding two integers.
View this file and note the point where the two numbers get added in assembly.
You may also use the Linux utility: objdump d exe file name, to disassemble
the exe file into assembly and see the instruction for adding the two numbers.
Completing b if the student was able to do b and locate the instructions
for adding the two numbers
c Next, edit the executable file generated by gcc in step a to change the addition
operation to a subtraction operation. You will have to do some research here to
find out the op code for subtraction instruction and other issues. Use editors
available freely online for editing executable files and other binary files for this
purpose. One such editor is hexedit, but it would be best that you search online
for a better option. After modifying the code try to run the executable to see if
Page of
you have succeeded. If not try to explain why you failed. Completing b if the
student was able to do c
d Java compiler, javac, compiles Java language files to java byte code not the
machine language instructions which is executed by the Java Virtual Machine
JVM Try to find out how a Java byte code file can be viewed. Can source files
be generated for Java byte code?
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
