Computer Science Engineering (CSE) Exam  >  Computer Science Engineering (CSE) Notes  >  8085 Program - Mask the Higher Nibble of an 8-bit Number - Notes

8085 Program - Mask the Higher Nibble of an 8-bit Number - Notes - Computer Science Engineering (CSE) PDF Download

Download, print and study this document offline
Please wait while the PDF view is loading
 Page 1


8085 Programs 
 
Gursharan Singh 
Maninder Kaur  Page 1 of 2 
Program 8: Mask the higher nibble of an 8-bit number. 
 
Flowchart: 
 
 
 
 
 
 
 
 
 
 
 
 
 
Program: 
Address Mnemonics Operand Opcode Remarks 
2000 LDA 3000H 3A Load H-L pair with data from 3000H. 
2001   00 Lower-order of 3000H. 
2002   30 Higher-order of 3000H. 
2003 ANI 0FH E6 AND Immediate 0FH with reg. A. 
2004   0F Immediate value 0FH. 
2005 STA 3001H 32 Store the result at memory location 3001H. 
2006   01 Lower-order of 3001H. 
2007   30 Higher-order of 3001H. 
2008 HLT  76 Halt. 
 
Explanation: 
? This program masks the higher nibble of an 8-bit number stored in memory location 3000H. 
? Let us assume that the operand stored at memory location 3000H is 45H. 
? The operand is moved to accumulator from memory location 3000H. 
? Then, AND operation of 0FH is performed with accumulator. This results in the masking of 
higher nibble. 
? The result is stored at memory location 3001H. 
Start 
Load accumulator with 
operand from memory. 
Perform AND operation of 
0FH with accumulator. 
Store the result from 
accumulator to memory. 
Stop 
Page 2


8085 Programs 
 
Gursharan Singh 
Maninder Kaur  Page 1 of 2 
Program 8: Mask the higher nibble of an 8-bit number. 
 
Flowchart: 
 
 
 
 
 
 
 
 
 
 
 
 
 
Program: 
Address Mnemonics Operand Opcode Remarks 
2000 LDA 3000H 3A Load H-L pair with data from 3000H. 
2001   00 Lower-order of 3000H. 
2002   30 Higher-order of 3000H. 
2003 ANI 0FH E6 AND Immediate 0FH with reg. A. 
2004   0F Immediate value 0FH. 
2005 STA 3001H 32 Store the result at memory location 3001H. 
2006   01 Lower-order of 3001H. 
2007   30 Higher-order of 3001H. 
2008 HLT  76 Halt. 
 
Explanation: 
? This program masks the higher nibble of an 8-bit number stored in memory location 3000H. 
? Let us assume that the operand stored at memory location 3000H is 45H. 
? The operand is moved to accumulator from memory location 3000H. 
? Then, AND operation of 0FH is performed with accumulator. This results in the masking of 
higher nibble. 
? The result is stored at memory location 3001H. 
Start 
Load accumulator with 
operand from memory. 
Perform AND operation of 
0FH with accumulator. 
Store the result from 
accumulator to memory. 
Stop 
8085 Programs 
 
Gursharan Singh 
Maninder Kaur  Page 2 of 2 
Output: 
Before Execution: 
3000H:  45H 
 
After Execution: 
3001H: 05H 
 
 
Read More

FAQs on 8085 Program - Mask the Higher Nibble of an 8-bit Number - Notes - Computer Science Engineering (CSE)

1. What is the purpose of masking the higher nibble of an 8-bit number?
Ans. Masking the higher nibble of an 8-bit number allows us to isolate and manipulate only the lower nibble, which can be useful in certain programming scenarios. By masking the higher nibble, we can ignore the upper 4 bits of the number and focus on the lower 4 bits.
2. How can we mask the higher nibble of an 8-bit number in an 8085 program?
Ans. To mask the higher nibble of an 8-bit number in an 8085 program, we can use the logical AND operation. We can perform the AND operation between the number and a mask value that has the lower nibble set to 0 and the higher nibble set to 1. This will result in the higher nibble being masked or set to 0, while the lower nibble remains unchanged.
3. Can masking the higher nibble of a number be used for input validation in a program?
Ans. Yes, masking the higher nibble of a number can be used for input validation in a program. For example, if we want to validate that a user input is within a certain range (0-15), we can mask the higher nibble of the input and check if the resulting value is within the desired range. If the masked value is outside the range, it indicates an invalid input.
4. Is it possible to mask the lower nibble of an 8-bit number instead of the higher nibble?
Ans. Yes, it is possible to mask the lower nibble of an 8-bit number instead of the higher nibble. The process is similar to masking the higher nibble. We can perform a logical AND operation between the number and a mask value that has the lower nibble set to 1 and the higher nibble set to 0. This will result in the lower nibble being masked or set to 0, while the higher nibble remains unchanged.
5. What are some practical applications of masking the higher nibble of an 8-bit number?
Ans. Masking the higher nibble of an 8-bit number has various practical applications. It can be used for input validation, as mentioned earlier, to ensure that user inputs are within a specified range. It can also be used for extracting and manipulating individual bits within a byte, such as setting or clearing specific bits. Additionally, masking the higher nibble can be useful in certain arithmetic operations where only the lower nibble needs to be considered.
Download as PDF

Top Courses for Computer Science Engineering (CSE)

Related Searches

Summary

,

Extra Questions

,

Semester Notes

,

8085 Program - Mask the Higher Nibble of an 8-bit Number - Notes - Computer Science Engineering (CSE)

,

study material

,

mock tests for examination

,

8085 Program - Mask the Higher Nibble of an 8-bit Number - Notes - Computer Science Engineering (CSE)

,

past year papers

,

ppt

,

8085 Program - Mask the Higher Nibble of an 8-bit Number - Notes - Computer Science Engineering (CSE)

,

shortcuts and tricks

,

Objective type Questions

,

Free

,

Viva Questions

,

Important questions

,

practice quizzes

,

Sample Paper

,

Exam

,

MCQs

,

Previous Year Questions with Solutions

,

video lectures

,

pdf

;