Machine Language
Machine language is the lowest level of programming language, consisting of
binary code directly understood by a computer's hardware. It's the language of 0s
and 1s that represents instructions and data for the CPU. Understanding machine
language is fundamental for grasping how computers execute instructions.
1. Definition and Characteristics:
Lowest Level:
Machine language is the most basic form of programming language, directly
understood by the CPU.
Binary Representation:
Instructions and data are represented using binary digits (0s and 1s).
Hardware Dependent:
Machine language is specific to the architecture of a particular computer
processor.
No Translation Needed:
Unlike higher-level languages, machine code doesn't require translation for
execution.
2. Instructions:
Operation Code (Opcode): Specifies the operation to be performed (e.g., add,
subtract, load).
Operand(s): Indicate the data or memory locations involved in the operation.
Instruction Formats: Vary depending on the architecture and the type of
operation.
Examples: Instructions like "load register with a value," "add the contents of two
registers," or "jump to a specific memory address".
3. Relation to Assembly Language:
Assembly Language: A symbolic representation of machine language, using
mnemonics (short, easy-to-remember names) for instructions and symbols for
addresses.
Assembler: A program that translates assembly language code into machine
code.
Lower Level Than Assembly: Machine language is considered lower level than
assembly language.
4. Examples of MCQs:
Here are some sample multiple-choice questions that could appear on a NET
exam concerning machine language:
1. Which of the following is the lowest level programming language?
a) High-level language b) Assembly language
c) Machine language d) None of the above
2. In a machine language instruction, what does the "opcode" field specify?
a) Data to be used b) Memory location
c) Operation to be performed d) Address of the next instruction
3. What is the role of an assembler?
a) Translates high-level code into machine code
b) Translates assembly code into machine code
c) Executes machine code instructions
d) None of the above
4. Machine language is:
a) Machine-dependent b) Machine-independent
c) Both a and b d) None of the above
5. What is the binary representation of data and instructions called?
a) Assembly language b) Machine code
c) High-level language d) None of the above
5. Key Concepts for MCQs:
Understanding the relationship between machine language, assembly language,
and higher-level languages.
Knowing the components of a machine language instruction (opcode, operands).
Being familiar with the concept of machine code being hardware-specific.
Recognizing the role of assemblers in translating assembly code.
ANSWER
1. c) Machine language 2. c) Operation to be performed
3. b) Translates assembly code into machine code
4. a) Machine-dependent 5. b) Machine code
Machine Dependent MCQ Objective Questions - TestBook
Machine Dependent Question 1:
Which of the following is a Pass 1 task in a typical assembler?
1. Generate data 2. Generate instructions
3. Look up value of symbols 4. Determine length of machine
instructions
Machine Dependent Question 2:
Assembler takes ____ as input and produces ____ as output.
1. assembly language, relocatable machine code
2. source program, modified source code
3. relocatable machine code, target machine code
4. modified source program, assembly language
Machine Dependent Question 3:
Which of the following is a Pass 1 task in a typical assembler?
1. Generate data 2. Generate instructions
3 Look up value of symbols 4. Determine length of machine
instructions
4. Machine Level Language is a/an
1. Assembly Language 2. Low Level language
3. High level Language 4. Translating Language
Machine Language and Assembly Language.
PREMIUM
1.__________ converts the programs written in assembly language into
machine
1. instructions. 2. Machine compiler
3. Interpreter 4. Assembler Converter
2. Which of the following is called low level languages?
1. Assembly Language 2. Machine Language
3. Both of the above 4. None of the above
3. What is the only thing that computers understand?
1. Low Level Language 2. Machine Code
3. High Level Languages 4.Algorithms
4. Before a computer can understand a program it must be _____
1. Translated into a high level language.
2. Translated into its machine code.
3. Translated into a low level language.
5. Which of the following is not a high level programming language?
1. C++ 2. Java 3. Python 4. Assembly
6.Machine code uses the binary number system.
1. True 2. False
7. Machine code is easy to understand by a human.
1. True 2. False
8._____ language uses mnemonics
1. C language 2. Machine Language
3. Assembly Language 4. C++ Language
9.______ is needed to convert a high level language to machine language
1. Assembler 2. Editor 3. Compiler 4. Interpreter
10.A _______ is a set of instructions, that tells the computer what to do.
1. Compiler 2. Program 3. Assembler 4. Translator
Microprocessors Questions and Answers – Machine Language
Instruction Formats
1. Operation code field is present in :
a) programming language instruction b) assembly language instruction
c) machine language instruction d) none of the mentioned
2. A machine language instruction format consists of
a) Operand field b) Operation code field
c) Operation code field & operand field d) none of the mentioned
3. The length of the one-byte instruction is
a) 2 bytes b) 1 byte c) 3 bytes d) 4 bytes
4. The instruction format ‘register to register’ has a length of
a) 2 bytes b) 1 byte c) 3 bytes d) 4 bytes
5. The R/M field in a machine instruction format specifies
a) another register b) another memory location
c) other operands d) all of the mentioned
6. In a machine instruction format, S-bit is the
a) status bit b) sign bit
7. c) sign extension bit d) none of the mentioned
8. The bit which is used by the ‘REP’ instruction is
a) W-bit b) S-bit c) V-bit d) Z-bit
9. If a W-bit value is ‘1’ then the operand is of
a) 8 bits b) 4 bits c) 16 bits d) 2 bit
10. The instructions which after execution transfer control to the next
instruction in the sequence are called
a) Sequential control flow instructions b) control transfer instructions
c) Sequential control flow & control transfer instructions
d) none of the mentioned
11. The instructions that transfer the control to some predefined
address or the address specified in the instruction are called as
a) sequential control flow instructions b) control transfer instructions
c) sequential control flow & control transfer instructions
d) none of the mentioned
12. The instruction “JUMP” belongs to
a) sequential control flow instructions b) control transfer instructions
c) branch instructions d) control transfer & branch instructions
MCQs
1. What is machine language?
a) A high-level programming language
b) A low-level programming language that a computer's processor can
understand directly
c) A scripting language
d) A markup language
2. What is the format of machine language instructions?
a) Binary format b) Assembly language format
c) High-level language format d) Scripting language format
3. Is machine language machine-independent?
a) Yes b) No c) Sometimes d) Depends on the program
4. What is a major disadvantage of using machine language?
a) It is difficult to write and debug b) It is slow in execution
c) It is not portable d) All of the above
5. Where is machine language commonly used?
a) Application development b) Embedded systems and firmware
c) Web development d) Database management
Q.1: Consider the sequence of machine instructions given below: [GATE
CSE 2015]
MUL R5, R0, R1
DIV R6, R2, R3
ADD R7, R5, R6
SUB R8, R7, R4
In the above sequence, R0 to R8 are general purpose registers. In the
instructions shown, the first register stores the result of the operation
performed on the second and the third registers. This sequence of
instructions is to be executed in a pipelined instruction processor with the
following 4 stages: (1) Instruction Fetch and Decode (IF), (2) Operand
Fetch (OF), (3) Perform Operation (PO) and (4) Write back the Result (WB).
The IF, OF and WB stages take 1 clock cycle each for any instruction. The
PO stage takes 1 clock cycle for ADD or SUB instruction, 3 clock cycles
for MUL instruction and 5 clock cycles for DIV instruction. The pipelined
processor uses operand forwarding from the PO stage to the OF stage.
The number of clock cycles taken for the execution of the above sequence
of instructions is ___________
(A) 11
(B) 12
(C) 13
(D)14
Solution: Correct Answer is (C).
Explanation:
1 2 3 4 5 6 7 8 9 10 11 12 13
IF OF PO PO PO WB
IF OF PO PO PO PO PO WB
IF OF PO WB
IF OF PO WB
Machine Dependent MCQ Objective Questions - TestBook
1. Answer (Detailed Solution Below)
Option 4 : Determine length of machine instructions
Machine Dependent Question 1 Detailed Solution
Assembler is a program for converting assembly language to
machine level code. Assembler works in two passes.
Pass 1:
Generates the symbol table.
Intermediate representation of the source program
Keep track of location counter
Determine length of machine instructions
Pass 2:
Generate data values for literals and look for value of symbols
Generates the machine code
Use the first pass information to achieve the target
Generate the object code.
2. Answer (Detailed Solution Below)
Option 1 : assembly language, relocatable machine code
Machine Dependent Question 2 Detailed Solution
The Assembler is used to translate the program written in Assembly
language into machine code
Assembly language (input) → Assembler → relocatable machine code
(output)
Source program (input) → preprocessor → modified source program
(output)
Relocatable machine code (input) → linker/loader → target machine
code (output)
Modified source program (input) → compiler → assembly language
(output)
3. Answer (Detailed Solution Below)
Option 3 : Determine length of machine instructions
4. Answer (Detailed Solution Below)
Option 2 : Low Level language
Detailed Solution
The correct answer is Low Level language
Key Points
1. Low-Level Language: Low-level languages are closely related to the
hardware of a computer system. They operate and behave on the
computer's hardware directly, making them more efficient but less
portable. Machine language and assembly are both examples of low-level
languages. Low-level languages are harder to read and write since they
require detailed knowledge of the hardware's internal workings.
2. Assembly Language: This is a low-level programming language where there
is a strong correspondence between its instructions and the architecture's
machine code instructions. It's one step away from machine language
which is directly interpreted into the hardware. Each assembly language is
specific to a particular computer architecture.
3. High-Level Language: High-level languages are coding languages designed
to be easy for humans to read, write, and maintain. Examples of high-level
language include Python, Java, C++, and more. These languages do not
require the programmer to understand the hardware's inner workings and
are designed to be more user-friendly, abstracting away the complexities
and details of the hardware.
4. Machine Language and Assembly Language.
5. PREMIUM
1. 3 2. 3 3. 2 4. 2 5. 4
6. 1 7. 2 8. 3 9. 3 10. 2
Microprocessors Questions and Answers – Machine Language ANSWERS:
1. Answer: c
Explanation: Machine language instruction format has one or more fields.
The first one is the operation code field.
2. Answer: c
Explanation: Machine language instruction format has both the fields.
3. Answer: b
Explanation: This format is only one byte long.
4. Answer: a
Explanation: This format is 2 bytes long.
5. Answer: d
Explanation: The LSBs(least significant bits) from 0 to 3 represent R/M field
that specifies another register or memory location i.e. the other operand.
6. Answer: c
Explanation: The S-bit known as sign extension bit is used along with W-bit
to show the type of operation.
7. Answer: d
Explanation: The Z-bit is used by the REP instruction to control the loop.
8. Answer: c
Explanation: If W-bit is ‘1’ then the operand is of 16-bits, and if it is ‘0’ then
the operand is of 8-bits.
9. Answer: a
Explanation: The sequential control flow instructions follow sequence order
in their execution.
10. Answer: b
Explanation: The control transfer instructions transfer control to the specified
address.
11. Answer: d
Explanation: The JUMP instruction transfers the control to the address
located in the instruction.
MCQ ANSWER
1b) A low-level programming language that a computer's processor can
understand directly 2. Answer: a) Binary format 3. b) No
4. d) All of the above 5. b) Embedded systems and firmware