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

COA Lab

COA Lab

Uploaded by

sevenhills4u
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)
23 views32 pages

COA Lab

COA Lab

Uploaded by

sevenhills4u
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

Computer Organization and Architecture-LAB

By: Dr. Edukondalu


Syllabus
Assembly Programming
ALU design
CU design
Pipelining
Memory Architecture
I/O Operation
Assembly Level Programming 8086

• The assembly programming language is a low-level language which is


developed by using mnemonics.
• The microcontroller or microprocessor can understand only the binary
language like 0’s or 1’s.
• Therefore the assembler like NASM, MASM etc., convert the
assembly language to binary language and store it the memory to
perform the tasks.
• Before writing the program the embedded designers must have
sufficient knowledge on particular hardware of the controller or
processor,
• so first we required to know hardware of 8086 processor.
Assembly Level Programming 8086
• Assembly level programming is very important to low-level
embedded system design is used to access the processor instructions
to manipulate hardware.
• It is a most primitive machine level language is used to make efficient
code that consumes less number of clock cycles and takes less
memory as compared to the high-level programming language.
• It is a complete hardware oriented programing language to write a
program the programmer must be aware of hardware.
Assembly Level Programming
8086
• Processor understands only machine language instructions which are
strings of 1s and 0s.
• However machine language is too obscure and complex for using in
software development.
• So the low level assembly language is designed for a specific family of
processors that represents various instructions in symbolic code and a
more understandable form.
Advantages of Assembly Language
• Interface of programs with OS, processor and BIOS
• Representation of data in memory and other external devices
• How processor accesses and executes instruction
• How instructions accesses and process data
• How a program access external devices.
• It requires less memory and execution time
• It allows hardware-specific complex jobs in an easier way
• It is suitable for time-critical jobs
Basic Features of Computer
Hardware
• The main internal hardware of a PC consists of the processor, memory
and the registers.
• The registers are processor components that hold data and address.
• To execute a program the system copies it from the external device
into the internal memory.
• The processor executes the program instructions.
• The fundamental unit of computer storage is a bit; it could be on (1)
or off (0).
• A group of eight bits makes a byte.
Basic Features of Computer
Hardware
• Eight bits are used for data and the last one is used for parity.
According to the rule of parity, number of bits that are on (1) in each
byte should always be odd.
• So the parity bit is used to make the number of bits in a byte odd.
• If the parity is even, the system assumes that there had been a parity
error (though rare) which might have caused due to hardware fault or
electrical disturbance.
Basic Features of Computer
Hardware
• The processor supports the following data sizes:
• Word: a 2-byte data item =16 bits
• Doubleword: a 4-byte (32 bit) data item
• Quadword: an 8-byte (64 bit) data item
• Paragraph: a 16-byte (128 bit) area
• Kilobyte: 1024 bytes =2^10=1kb
• Megabyte: 1,048,576 bytes=2^20=1mb
The Binary Number System
• The positional values for an 8-bit binary number, where all bits are set
on.

The value of a binary number is based on the presence of 1 bits and their
positional value.
So the value of the given binary number is: 1 + 2 + 4 + 8 +16 + 32 + 64 +
128 = 255, which is same as 2^8 - 1.
The Hexadecimal Number System
• Hexadecimal number system uses base 16.
• The digits range from 0 to 15.
• By convention, the letters A through F is used to represent the
hexadecimal digits corresponding to decimal values 10 through 15.
• Main use of hexadecimal numbers in computing is for abbreviating
lengthy binary representations.
• Basically hexadecimal number system represents a binary data by
dividing each byte in half and expressing the value of each half-byte.

The Hexadecimal Number System
• To convert a binary number to its hexadecimal equivalent, break it into
groups of 4 consecutive groups each, starting from the right, and write
those groups over the corresponding digits of the hexadecimal number.
Example: Binary number 1000 1100 1101 0001 is equivalent to
hexadecimal is 8CD1

• To convert a hexadecimal number to binary just write each hexadecimal


digit into its 4-digit binary equivalent.
Example: Hexadecimal number FAD8 is equivalent to binary is
1111 1010 1101 1000
Negative of a Number
• A negative binary value is expressed in two's complement notation.
According to this rule, to convert a binary number to its negative value
is to reverse its bit values and add 1.
For example: Negative of 53
Number 53 00110101
Reverse the bits 11001010
Add 1 1
Number -53 11001011
Subtraction by using Negative of a
Number
Example: Subtract 42 from 53
Number 53 00110101
Number 42 00101010
Reverse the bits of 42 11010101
Add 1 1
Number -42 11010110
53 - 42 = 11 00001011

Overflow of the last 1 bit is lost


Assembly Language Programming-Basic Requirement

• To make programs in assembly language, you must know some


information about the 8086 microprocessor.
• The 8086 contains 14 registers. Each register is 16 bits.
• The 8086 has four groups of the user accessible internal registers.
They are
General purpose registers
Segment registers.
Pointer and Index registers
Flag register
1.General Purpose Registers:
AX : Accumulator register consists of two 8-bit registers AL and AH,
which can be combined together and used as a 16- bit register AX.
AL in this case contains the low-order byte of the word, and AH contains
the high-order byte. Accumulator can be used for I/O operations and
string manipulation.
It is generally used for arithmetical and logical instructions
in 8086 microprocessor.
1.General Purpose Registers:
BX: Base register consists of two 8-bit registers BL and BH, which can be
combined together and used as a 16-bit register BX.
BL in this case contains the low-order byte of the word, and BH
contains the high-order byte. BX register usually contains a data pointer
used for based, based indexed or register indirect addressing.
It is used to store the starting base address/offset of the memory area
within the data segment.
1.General Purpose Registers:
CX: Count register consists of two 8-bit registers CL and CH, which can be combined
together and used as a 16-bit register CX.
When combined, CL register contains the low- order byte of the word, and CH contains the
high order byte.
Count register can be used in Loop, shift/rotate instructions and as a counter in string
manipulation,.
It is referred to as counter. It is used in loop instruction to store the loop counter.
DX: Data register consists of two 8-bit registers DL and DH, which can be combined together
and used as a 16-bit register DX.
When combined, DL register contains the low- order byte of the word, and DH contains the
high order byte.
Data register can be used as a port number in I/O operations. In integer 32-bit multiply and
divide instruction the DX register contains high-order word of the initial or resulting number.
This register is used to hold I/O port address for I/O instruction.
2. Segment Registers:
• Segmentation is the process in which the main memory of the
computer is logically divided into different segments and each
segment has its own base address.
• It is basically used to enhance the speed of execution of the computer
system, so that the processor is able to fetch and execute the data
from the memory easily and fast.
2. Segment Registers:
Segmentation is the process in which the main memory of the computer is logically
divided into different segments and each segment has its own base address. It is
basically used to enhance the speed of execution of the computer system, so that
the processor is able to fetch and execute the data from the memory easily and fast.
• Code segment (CS) is a 16-bit register containing address of 64 KB segment with
processor instructions.
The processor uses CS segment for all accesses to instructions referenced by
instruction pointer (IP) register.
CS register cannot be changed directly.
The CS register is automatically updated during far jump, far call and far return
instructions.
• Stack segment (SS) is a 16-bit register containing address of 64KB segment with
program stack.
By default, the processor assumes that all data referenced by the stack pointer (SP)
and base pointer (BP) registers is located in the stack segment.
2. Segment Registers:
• Data segment (DS) is a 16-bit register containing address of 64KB
segment with program data.
• By default, the processor assumes that all data referenced by general
registers (AX,BX, CX, DX) and index register (SI, DI) is located in the
data segment.
• Extra segment (ES) is a 16-bit register containing address of 64KB
segment, usually with program data.
• By default, the processor assumes that the DI register references the
ES segment in string manipulation instructions. ES register can be
changed directly using POP and LES instructions
3. Pointer and Index Registers::
• Instruction Pointer (IP) is a 16-bit register that contains the offset
address. IP is combined with the CS to generate the address of the next
instruction to be executed.
• Stack Pointer (SP) is a 16-bit register pointing to program stack.
–Always points to top item on the stack
• Base Pointer (BP) is a 16-bit register pointing to data in stack segment.
BP register is usually used for based, based indexed or register indirect
addressing.
• Source Index (SI) is a 16-bit register. SI is used for indexed, based
indexed and register indirect addressing, as well as a source data
address in string manipulation instructions.
• Destination Index (DI) is a 16-bit register. DI is used for indexed, based
indexed and register indirect addressing, as well as a destination data
address in string manipulation instructions.
3. Flag Registers:
Status Flags
1. Carry flag (CY): It is set whenever there is a carry {or borrow} out of the MSB
of a the result (D7 bit for an 8-bit operation and D15 bit for a 16-bit operation).
2. Parity Flag (PF): It is set if the result has even parity.
3. Auxiliary Carry Flag (AC): It is set if a carry is generated out of the Lower
Nibble.
4. Zero Flag (ZF): It is set if the result is zero.
5. Sign Flag (SF): It is set if the MSB of the result is 1. For signed operations, such
a number is treated as –ve.
6. Overflow Flag (OF): It will be set if the result of a signed operation is too large
to fit in the number of bits available to represent it.
Control Flags
1. Trap Flag (TF): It is used to set the Trace Mode i.e. start Single Stepping
Mode. Here the µP is interrupted after every instruction so that, the
program can be debugged.
2. Interrupt Enable Flag (IF): It is used to mask (disable) or unmask
(enable) the INTR interrupt.
3. Direction Flag (DF): If this flag is set, SI and DI are in auto-decrementing
mode in String Operations.
3. Flag Registers:
Flags is a 16-bit register containing nine 1-bit flags. 06 flags are status flags
and 3 are Control Flags.
• Overflow Flag (OF) - set if the result is too large positive number, or is too
small negative number to fit into destination operand. This flag will be set
(1) if the result of a signed operation is too large to fit in the number of
bits available to represent it otherwise reset (0).
• Direction Flag (DF) - if set then string manipulation instructions will auto-
decrement index registers. If cleared then the index registers will be auto-
incremented.
This flag is specifically used in string instructions. If directional flag is set
(1), then access the string data from higher memory location towards lower
memory location: If directional flag is reset (0), then access the string data
from lower memory location towards higher memory location.
• Interrupt-enable Flag (IF) - setting this bit enables maskable interrupts.
3. Flag Registers::
• Sign Flag (SF) - set if the most significant bit of the result is set. If the
result after performing any arithmetic or logic operation in the given
instruction is negative, then the sign flag is set to 1.
• Zero Flag (ZF) - set if the result is zero.
• Auxiliary carry Flag (AF) - set if there was a carry from or borrow to
bits in the AL register.
• Parity Flag (PF) - set if parity (the number of "1" bits) in the low-order
byte of the result is even. This flag is set to 1 when there is even
number of one bits in result, and to 0 when there is odd number of
one bits.
• Carry Flag (CF) - set if there was a carry from or borrow to the most
significant bit during last result calculation.
emu8086
• https://qpdownload.com/8086-microprocessor-emulator/
• https://deeprajbhujel.blogspot.com/2014/01/emu8086-license-key.ht
ml

You might also like