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.
|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.
; 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