CH3 + CH 4 Updated UNit 2 Addressing Methods and
CH3 + CH 4 Updated UNit 2 Addressing Methods and
CH3 + CH 4 Updated UNit 2 Addressing Methods and
and Programs
Hari K.C.
Programming view of a Processor
• It refers to the programming model of a processor.
• Viewing a processor from a programming perspective involves
understanding how the processor executes instructions, manages memory,
and handles data.
• It includes Instruction Set, Registers, Memory Management, Control Flow,
Arithmetic and Logic Unit (ALU), Data Movement.
• Understanding the programming view of a processor is crucial for
optimizing code, designing efficient algorithms, and developing software
that takes advantage of the underlying hardware capabilities.
• Different processor architectures (e.g.,8085, 8086, ARM, MIPS) have their
own unique programming models.
8085 microprocessor programming model
• The Intel 8085 microprocessor is a popular 8-bit microprocessor
introduced in the mid-1970s.
• It has a simple programming model that involves various registers
and instructions to perform operations.
• Here's an overview of the programming model of the 8085
microprocessor:
1. Registers
• The 8085 has six general purpose registers to store 8 bit data; these are
identifies as B, C, D, E, H, L.
• They can be combined as register pairs - BC, DE and HL to perform some
16-bit operations.
• The programmer can use these registers to store or copy data into the
registers by using data copy instructions.
2. Accumulator
• The accumulator is an 8-bit register that is a part of arithmetic/logic
unit(ALU).
• This register is used to store 8-bit data and to perform arithmetic and
logical operations.
• The result of an operation is stored in the accumulator.
• The accumulator is also identified as register A.
3. Flags
- Zero Flag (Z): Sets or Resets based on the result stored in the accumulator.
If the result stored is zero the flag is set else it is reset.
- Parity Flag (P): This flag is set if there is even parity else it resets.
- Carry Flag (CY): This flag is set if there is a carry bit else it resets.
4. Program Counter (PC)
• This 16-bit register deals with sequencing the execution of instructions this
register is a memory pointer.
• Memory locations have 16-bit addresses and that is why this is a 16 bit
register.
• The function of the PC is to point to the memory address from which the
next byte is to be fetched.
• When a byte(machine code) is being fetched, the program counter is
incremented by one to point to the next memory location.
• 1's complement
• The 1's complement of a number is found by changing all 1's to 0's
and all 0's to 1’s.
• This is called as taking complement or 1's complement. Example of 1's
Complement is as follows:
2's complement
100101
101011 – 111001
Solution:
1’s complement of 111001 is 000110. Hence
Minued - 101011
1’s complement - 000110
110001
1 10110 Minuend
1 01010 2’s complement of subtrahend
Carry over 1 1 00000 Result of addition
After dropping the carry over we get the result of subtraction to be 100000.
10110 – 11010
Solution:
2’s complement of 11010 is (00101 + 1) i.e. 00110. Hence
Minued - 10110
2’s complement of subtrahend - 00110
Result of addition - 11100
Applications
• used in digital voltmeter
• used in digital clock
• used in traditional computer
Gray code
• The reflected binary code or Gray code is an ordering of the binary numeral
system such that two successive values differ in only one bit (binary digit).
• Gray codes are very useful in the normal sequence of binary numbers
generated by the hardware that may cause an error or ambiguity during
the transition from one number to the next.
• So, the Gray code can eliminate this problem easily since only one bit
changes its value during any transition between two numbers.
• Gray code is not weighted that means it does not depends on positional
value of digit.
• This cyclic variable code that means every transition from one value to the
next value involves only one bit change.
For n = 1 bit For n = 2 bit For n = 3 bit
0 0 00 00 000 000
1 1 01 01 001 001
10 11 010 011
11 10 011 010
100 110
101 111
110 101
111 100
Decimal Binary Gray Code
0 000 000
1 001 001
2 010 011
3 011 010
4 100 110
5 101 111
6 110 101
7 111 100
• Gray codes are widely used to prevent spurious output
from electromechanical switches and to facilitate error correction in digital
communications such as digital terrestrial television and some cable
TV systems.
• It is also used for asynchronous FIF0 pointer.
• Used for high speed decode circuit.
• When Gray code are used in computers to address program memory , the
computer uses less power because fever address line change as the
program counter advances.
• Gray code also play a vital role in error correction.
Alphanumeric code, 8421,2421 and Hamming
code
• ASCII, stands for American Standard Code for Information
Interchange.
• It's a 7-bit character code where every single bit represents a unique
character.
2421 BCD Code
• This code also a 4 bit application code where the binary weights carry
2, 4, 2, 1 from left to right.
Hamming Code
• Hamming code is a block code that is capable of detecting up to two
simultaneous bit errors and correcting single-bit errors.
• It was developed by R.W. Hamming for error correction.
• In this coding method, the source encodes the message by inserting
redundant bits within the message.
• These redundant bits are extra bits that are generated and inserted at
specific positions in the message itself to enable error detection and
correction.
• When the destination receives this message, it performs
recalculations to detect errors and find the bit position that has error.
Example of Hamming code
• Suppose the data to be transmitted is 1011001, the bits will be placed
as follows:
To find the redundant bit R1, we check for even parity. Since
the total number of 1’s in all the bit positions corresponding to
R1 is an even number the value of R1 (parity bit’s value) = 0
• R2 bit is calculated using parity check at all the bits positions whose
binary representation includes a 1 in the second position from the
least significant bit. R2: bits 2,3,6,7,10,11
To find the redundant bit R2, we check for even parity. Since the total number of 1’s in all the
bit positions corresponding to R2 is odd the value of R2(parity bit’s value)=1
• R4 bit is calculated using parity check at all the bits positions whose
binary representation includes a 1 in the third position from the least
significant bit. R4: bits 4, 5, 6, 7
To find the redundant bit R4, we check for even parity. Since
the total number of 1’s in all the bit positions corresponding to
R4 is odd the value of R4(parity bit’s value) = 1
• R8 bit is calculated using parity check at all the bits positions whose binary representation
includes a 1 in the fourth position from the least significant bit. R8: bit 8,9,10,11
To find the redundant bit R8, we check for even parity. Since
the total number of 1’s in all the bit positions corresponding to
R8 is an even number the value of R8(parity bit’s value)=0.
Thus, the data transferred is:
Error Detection code
• The parity generating technique is one of the most widely used error detection
techniques for the data transmission.
• In digital systems, when binary data is transmitted and processed , data may be
subjected to noise so that such noise can alter 0s (of data bits) to 1s and 1s to 0s.
• Hence, parity bit is added to the word containing data in order to make number
of 1s either even or odd.
• Thus it is used to detect errors , during the transmission of binary data .
• The message containing the data bits along with parity bit is transmitted from
transmitter node to receiver node.
• At the receiving end, the number of 1s in the message is counted and if it doesn’t
match with the transmitted one, then it means there is an error in the data.
Parity generator and checker
• A parity generator is a combinational logic circuit that generates the
parity bit in the transmitter.
• On the other hand, a circuit that checks the parity in the receiver is
called parity checker.
• A combined circuit or devices of parity generators and parity
checkers are commonly used in digital systems to detect the single bit
errors in the transmitted data word.
• The sum of the data bits and parity bits can be even or odd . In even
parity, the added parity bit will make the total number of 1s an even
amount whereas in odd parity the added parity bit will make the total
number of 1s odd amount.
• The basic principle involved in the implementation of parity circuits is
that sum of odd number of 1s is always 1 and sum of even number of
1s is always zero.
• Such error detecting and correction can be implemented by using Ex-
OR gates (since Ex-OR gate produce zero output when there are even
number of inputs).
• To produce two bits sum, one Ex-OR gate is sufficient whereas for
adding three bits two Ex-OR gates are required as shown in below
figure.
Parity Generator
• It is combinational circuit that accepts an n-1 bit stream data and generates
the additional bit that is to be transmitted with the bit stream.
• This additional or extra bit is termed as a parity bit.
• In even parity bit scheme, the parity bit is ‘0’ if there are even number of
1s in the data stream and the parity bit is ‘1’ if there are odd number of
1s in the data stream.
• In odd parity bit scheme, the parity bit is ‘1’ if there are even number of 1s
in the data stream and the parity bit is ‘0’ if there are odd number of 1s in
the data stream. Let us discuss both even and odd parity generators.
Even Parity Generator
• Let us assume that a 3-bit message is to be transmitted with an even
parity bit.
• Let the three inputs A, B and C are applied to the circuits and output
bit is the parity bit P.
• The total number of 1s must be even, to generate the even parity bit
P.
• The figure below shows the truth table of even parity generator in
which 1 is placed as parity bit in order to make all 1s as even when
the number of 1s in the truth table is odd.
• The K-map simplification for 3-bit message even parity generator is
• From the above truth table, the simplified expression of the parity bit
can be written as:
• The above expression can be implemented by using two Ex-OR gates.
• The logic diagram of even parity generator with two Ex – OR gates is
shown below.
• The three bit message along with the parity generated by this circuit
which is transmitted to the receiving end where parity checker circuit
checks whether any error is present or not.
• To generate the even parity bit for a 4-bit data, three Ex-OR gates are
required to add the 4-bits and their sum will be the parity bit.
Odd Parity Generator
1. Memory to processor
2. Processor to memory
3. I/O to processor
4. Processor to I/O
:
• Instruction address calculation (iac):
Determine the address of the next instruction to be executed. Usually, this involves adding a fixed
number to the address of the previous instruction. For example, if each instruction is 16 bits long
and memory is organized into 16-bit words, then add 1 to the previous address. If, instead, memory
is organized as individually addressable 8-bit bytes, then add 2 to the previous address.
• Instruction fetch (if):
Read instruction from its memory location into the processor.
• Instruction operation decoding (iod):
Analyze instruction to determine type of operation to he performed and operand(s) to be used.
• Operand address calculation (oac):
If the operation involves reference to an operand in memory or available via I/O. then determine
the address of the operand.
• Operand fetch (of):
Fetch the operand from memory or read it in from I/O,
• Data operation (do):
Perform the operation indicated in the instruction.
• Operand store (os):
Write the result into memory or out to I/O
Machine Cycle
The time required by the microprocessor to complete an
operation of accessing memory or input/output devices is
called machine cycle.
Q X D Q Y D
Creating a Bus(bus transfer)
• Using a Bus , data are transferred from one register to other registers.
D X Q
D Y Q
• RTL uses a compact notation
Condition : Microoperation
Q X D Q Y D
LD
CLK α CLK
Use direct connection to show the data
transfer:
1) α : X ß Y ß Z
2) α : Xß Y , Z ßY
Arithmetic and logic micro operations
• ADDITION : Xß X+ Y
• SUBTRACTION : X ß X – Y OR X ß X + Y’ + 1
• INCREMENT: X ßX +1
• DECREMENT : X ß X -1
• AND’ING : X ß X ^ Y
• OR’ING : X ß X ∨ 𝑌
• XOR : X ß X ⨁ Y
• NOT : X ß X’
Shift operations
4 TYPES OF SHIFT
1) LINEAR SHIFT
2) CIRCULAR SHIFT
3) ARITHMETIC SHIFT
4) DECIMAL SHIFT
LINEAR SHIFT
• Linear shift left:
if X = 1011, then performing linear shift left.
shl(X) = 0110