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.
Input: 64H Output: output at PORT2 -->64H Input: 40H Output: output at PORT1 -->00H
- 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.
MVI A, BYTE1
MOV B, A
MOV A, B
DISPLAY:MOV A, B
Jump to DELETE, if CY=1
Jump to DISPLAY, if CY=1
[A]<–[A Exclusive OR A]
output the content of the accumulator at PORT1
output the content of the accumulator at PORT2
- 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.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Assembly language program to find largest number in an array
- Convert C/C++ code to assembly language
- Assembly program to transfer the status of switches
- 8085 program to exchange a block of bytes in memory
- 8086 program to transfer a block of 4 bytes by using string instructions
- 8086 program to transfer a block of bytes by using string instruction
- 8085 program to find the set bit of accumulator
- 8085 program to find the sum of a series
- 8086 program to find the min value in a given array
- 8085 program to find the element that appears once
- 8086 program to find GCD of two numbers and print the GCD
- C Program to find direction of growth of stack
- 8085 program to find the sum of first n natural numbers
- 8085 program to find 1’s and 2’s complement of 16-bit number
- 8086 program to find average of n numbers
- 8086 program to find sum of odd numbers in a given series
- 8085 program to find larger of two 8 bit numbers
- 8085 program to find 1's and 2's complement of 8-bit number
- 8086 program to find sum of Even numbers in a given series
- 8085 program to find square of a 8 bit number
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.