In this program we will see how to find the minimum digit from a two-digit number.
Write 8085 Assembly language program to find the minimum digit from a two-digit number. The number is stored at location 8000H, store the result at 8050H.
Here we are performing this task by using masking operation. Each digit takes one nibbles. We are masking the upper nibble by ANDing with 0FH (0000 1111). Store the lower nibble into another register. After that, we are taking the upper nibble. To get it, we are shifting the number to the right four times to convert lower nibble to upper nibble. Now again performing the masking operation the upper nibble is taken. By comparing them we can find the minimum one.
|F000||3A, 00, 80|| ||LDA 8000H||Take the number from memory|
|F003||47|| ||MOV B,A||Copy the content of A to B|
|F004||E6, 0F|| ||ANI 0FH||Mask the upper nibble|
|F006||4F|| ||MOV C,A||Store the lower nibble into C|
|F007||78|| ||MOV A,B||Take number from B to A|
|F008||07|| ||RLC||Rotate A content to the left four times|
|F009||07|| ||RLC|| |
|F00A||07|| ||RLC|| |
|F00B||07|| ||RLC|| |
|F00C||E6, 0F|| ||ANI 0FH||Take the lower nibble|
|F00E||B9|| ||CMP C||Compare C with A|
|F00F||DA, 13, F0|| ||JC STORE||If CY = 1, store A to memory|
|F012||79|| ||MOV A,C||Otherwise take C into A|
|F013||32, 50, 80||STORE||STA 8050H||Store result into memory|
|F016||76|| ||HLT||Terminate the program|