- Trending Categories
- Data Structure
- Operating System
- MS Excel
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Simulation of 4-bit ALU
Moreover, we write an assembly program in 8085 assembly language just to simulate a 4-bit ALU by using an interface which is based on the logic controller. The Arithmetic Logical Unit always performs an addition, subtraction, AND operation, or OR operation, which is based on the 4-bit inputs for the desired operations to be performed.
For the simulation of the Arithmetic Logical Unit all the terminal inputs and outputs are provided by the ports of 8255 as it is indicated in the figure below.
- The Pins ranging from 7-4 in the Port B are used as the inputs of X3-0;
- The pins ranging from 3-0 of Port B are used as the inputs ranging from Y3-0;
- Pins 7 and 6 of Port C used as S1 and S0 inputs;
- The port A pins of 3-0 are used as the output Z3-0;
- Pin 4 of Port A is used to provide Cy output in case of add and subtract operations.
- S1 and S0 inputs determine the operation to be performed by the ALU as per the table that follows.
|0||0||X + Y|
|0||1||X – Y|
|1||0||X AND Y|
|1||1||X OR Y|
Here S1 and S0 are the inputs and Z is the output.
Sample program code
; FILE NAME ALU_PROG1.ASM ORG C000H PA EQU D8H PB EQU D9H PC EQU DAH CTRL EQU DBH MVI A, 10001010B OUT CTRL ; Configure 8255 ports LOOP: IN PB ; Input X and Y values through Port B MOV B, A ANI 0FH MOV C, A ; C will now have Y input MOV A, B ANI F0H RRC RRC RRC RRC MOV B, A ; B will now have X input IN PC ; Read S1 and S0 values from Port ANI 11000000B RLC RLC ; LS 2 bits of A will now have S1 and S0 CPI 00H JZ ADD ; If S1 = 0 and S0 = 0 do Add operation CPI 01H JZ SUB ; If S1 = 0 and S0 = 1 do Subtract operation CPI 02H JZ AND ; If S1 = 1 and S0 = 0 do AND operation OR: MOV A, B ORA C JMP DISP ADD: MOV A, B ADD C JMP DISP SUB: MOV A, B SUB C JMP DISP AND: MOV A, B ANA C DISP: OUT PA JMP LOOP
- Related Articles
- Arithmetic Logic Unit (ALU)
- 4-bit microprocessors
- Simulation of 8 to 1 multiplexer
- Squirrel Simulation in C++
- Simulation Studies in Psychology
- Walking Robot Simulation in Python
- Dice Roll Simulation in C++
- Application of Cloud-Based Simulation in Scientific Research
- Basics of Discrete Event Simulation using SimPy in Python
- Program for simulation of throwing a die in 8085 Microprocessor
- What is Simulation Analysis in Capital Budgeting?
- Program for adding 4 hex digits of a 16-bit number in 8085 Microprocessor
- How to repeat a simulation to a fixed number of times in R?
- 1-bit and 2-bit Characters in Python
- Linux Kernel Versions 32-Bit vs 64-Bit