Assembly language program to find the range of bytes - GeeksforGeeks

22 Oct, 2018
Problem – Write an assembly language program that if an input number BYTE1 lies b/w 50H to 80H display it on output PORT2. If BYTE1 is less then 50H then simply print 00H at the output PORT1.
Examples:
Input:  64H
Output: output at PORT2 -->64H
Input:  40H
Output: output at PORT1 -->00H 
Algorithm –
Load the BYTE1 in accumulator A.Copy the Data from the accumulator to register B.Subtract the 50H from the accumulator(BYTE).Jump if subtraction is negative.If jump condition is true then it will simply print 00H at PORT1.If jump condition is false then BYTE1 will greater than 50H and in further instructions, it will also check the upper limit 80H of the BYTE1 so all the numbers lie b/w 50H to 80H those will print at PORT2.
Load the BYTE1 in accumulator A.
Copy the Data from the accumulator to register B.
Subtract the 50H from the accumulator(BYTE).
Jump if subtraction is negative.
If jump condition is true then it will simply print 00H at PORT1.
If jump condition is false then BYTE1 will greater than 50H and in further instructions, it will also check the upper limit 80H of the BYTE1 so all the numbers lie b/w 50H to 80H those will print at PORT2.
Program –
Explanation –
MVI A, BYTE1: load the accumulator A from BYTE1.MOV B, A: copy the content of accumulator to register B.<SUI 50H:> subtract the 50H from the content of the accumulator(BYTE1) and load it into accumulator.JC DELETE: here JC is jump instruction with carry flag check condition, carry flag will 1 if the subtraction is negative if the subtraction is positive then carry flag will be 0. SUI 50H will be positive if Accumulator content (BYTE1) will be greater or equal to 50H. if CY=0 result is positive and no jump will be performed.MOV A, B: copy the content of register B (BYTE1) to accumulator.SUI 80H: subtract the 80H from the accumulator. If the accumulator content will be less than 80H then result will be positive and it will jump to DISPLAY label and display the BYTE at PORT2 if the number will be in range 50H to 7FH.If in step-4, JC DELETE true means the subtraction result will positive then it will jump to delete and clear the content of accumulator and display 00H at output PORT1.
MVI A, BYTE1: load the accumulator A from BYTE1.
MOV B, A: copy the content of accumulator to register B.
<SUI 50H:> subtract the 50H from the content of the accumulator(BYTE1) and load it into accumulator.
JC DELETE: here JC is jump instruction with carry flag check condition, carry flag will 1 if the subtraction is negative if the subtraction is positive then carry flag will be 0. SUI 50H will be positive if Accumulator content (BYTE1) will be greater or equal to 50H. if CY=0 result is positive and no jump will be performed.
MOV A, B: copy the content of register B (BYTE1) to accumulator.
SUI 80H: subtract the 80H from the accumulator. If the accumulator content will be less than 80H then result will be positive and it will jump to DISPLAY label and display the BYTE at PORT2 if the number will be in range 50H to 7FH.
If in step-4, JC DELETE true means the subtraction result will positive then it will jump to delete and clear the content of accumulator and display 00H at output PORT1.
microprocessor
system-programming
Computer Organization & Architecture
microprocessor
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Architecture of 8085 microprocessor
Computer Organization and Architecture | Pipelining | Set 2 (Dependencies and Data Hazard)
Direct Access Media (DMA) Controller in Computer Architecture
Pin diagram of 8086 microprocessor
General purpose registers in 8086 microprocessor
8085 program to add two 16 bit numbers
I2C Communication Protocol
Difference between SRAM and DRAM
Difference between RISC and CISC processor | Set 2
Computer Organization | Different Instruction Cycles