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 CS Theory concepts for SDE interviews with the CS Theory 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 bytes by using string instruction
- 8086 program to transfer a block of 4 bytes by using string instructions
- Signals in C language
- chdir() in C language with Examples
- Register Transfer Language (RTL)
- C Program to find direction of growth of stack
- 8085 program to find the element that appears once
- 8085 program to find maximum and minimum of 10 numbers
- 8085 program to find maximum of two 8 bit numbers
- 8085 program to find the factorial of a number
- 8085 program to find square root of a number
- 8085 program to find 1's and 2's complement of 8-bit number
- 8085 program to find 1’s and 2’s complement of 16-bit number
- 8085 program to find sum of digits of 8 bit number
- 8085 program to find nth power of a number
- 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 firstname.lastname@example.org. 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.