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 330)
Assignment 01
High-Level, Assembly and Machine Languages
Submission Date: Wednesday, 7th February 2024
Important instructions
1) Complete explanation must be handwritten, no typed assignments will be
accepted
2) Please upload the pdf on the LMS
3) Screenshots must be included in the assignment.
4) 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 high-level 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 main(int argc, char **argv){
printf("Hello 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)4/10
(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 high-level 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 7/10
(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 2 of 2
you have succeeded. If not try to explain why you failed. Completing (b) if the
student was able to do (c)10/10
(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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!