0% found this document useful (0 votes)
6 views32 pages

Chapter # 6

The document discusses assembly language programming, focusing on machine code as the elemental language of computers, which consists of binary instructions executed by the CPU. It explains the structure of machine code instructions, the purpose of assembly language as a more manageable alternative for programmers, and the features that assembly language offers, such as macros and directives. Additionally, it covers the role of assemblers in translating assembly code into machine code and provides examples of assembly instructions and addressing modes.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views32 pages

Chapter # 6

The document discusses assembly language programming, focusing on machine code as the elemental language of computers, which consists of binary instructions executed by the CPU. It explains the structure of machine code instructions, the purpose of assembly language as a more manageable alternative for programmers, and the features that assembly language offers, such as macros and directives. Additionally, it covers the role of assemblers in translating assembly code into machine code and provides examples of assembly instructions and addressing modes.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 32

Assembly language

programming

C H A P T E R N O. 6
AS – LEVEL 9608
Machine code:

 Machine code, also known as machine language, is the elemental


language of computers, comprising a long sequence of binary digital
zeros and ones (bits).
 Simple instructions that are executed directly by the CPU. Each
instruction performs a very specific task, such as a load, a jump, or
an ALU operation on a unit of data in a CPU register or memory.
 Every program directly executed by a CPU is made up of a series of
such instructions.
 Machine code may be regarded as the lowest-level representation of
a compiled or assembled computer program or as a primitive and
hardware dependent programming language.
 Different processors have different instruction sets associated with
them. Even if two different processors have the same instruction,
the machine codes for them will be different but the structure of the
code for an instruction will be similar for different processors
Machine code instruction:

A binary code with a defined number of bits that


comprises a Machine code instruction: opcode and,
most often, one operand.
For a particular processor, the following components
are defined for an individual machine code instruction:
1.The total number of bits or bytes for the whole
instruction.
2.The number of bits that define the opcode
3.The number of operands that are defined in the
remaining bits
4.Whether the opcode occupies the most significant or
the least significant bits.
Assembly language

 A programmer might wish to write a program where the


actions taken by the processor are directly controlled. It is
argued that this can produce optimum efficiency in a program.
 However, writing a program as a sequence of machine code
instructions would be a very time-consuming and error-prone
process. The solution for this type of programming is to
use assembly language. As well as having a uniquely defined
machine code language each processor has its own assembly
language.
 The essence of assembly language is that for each machine
code instruction there is an equivalent assembly language
instruction which comprises:
 a mnemonic (a symbolic abbreviation) for the opcode
 a character representation for the operand.
Features of Assembly Language

The fact that an assembler is to be used allows a


programmer to include some special features in
an assembly language program. Examples of
these are:
Comments
symbolic names for constants
labels for addresses
Macros
Subroutines
Directives
System calls.
Macros & Directives

A macro or a subroutine contains a sequence


of instructions that is to be used more than
once in a program.
Directives: and system calls are instructions
to the assembler as to how it should construct
the final executable machine code. They can
involve directing how memory should be used
or defining files or procedures that will be
used. They do not have to be converted into
binary code
Assembly Language instructions

 LDD -Loads the contents of the memory address or integer


into the accumulator
 ADD -Adds the contents of the memory address or integer to
the accumulator
 STO -Stores the contents of the accumulator into the
addressed lo
 Let's take a look at a quick coding example using assembly
code.
 LDM #23: Loads the number 23 into the accumulator.
 ADD #42: Adds the number 42 to the contents of the
accumulator = 65.
 STO 34: Saves the accumulator result to the memory address
34.The code above is the equivalent of saying x = 23 + 42 in
VB language
Addressing modes
Registers(Assembly instructions)
Instructions

All questions will assume there is only one


general purpose register available
(Accumulator)
# ACC denotes Accumulator
IX denotes Index Register
#denotes immediate addressing
B denotes a binary number, e.g.
B01001010&denotes a hexadecimal number,
e.g. &4A
Data movement:
Arithmetic operation:

 Comparisons and jumps:


Assemblers

 A computer program that translates programming code


written in Assembly language to machine code is known
as assemblers. Assemblers can be One-Pass Assembler
or Two-Pass Assembler
1stPass
1.Data items are converted to their binary equivalent
2.Any directives are acted upon
3.Any symbolic addresses are added to the symbolic
address table
2ndPass
1.Forward references are resolved
2.Any symbolic address is replaced by an absolute address.
Example
Example (2)
Solution
Registers
Solution
Example
Solution
Trace Tables (Registers)
Continue…….
Continue….
Continue….
Past Paper Examples

You might also like