Unit - 2: 8051 Assembly Language Programming
1. Write the instructions to move value 34H into register A and value 3FH into register B, then add them together.
2. Write the instructions to add the values 16H and CDH. Place the result in register R2.
3. True or false. No value can be moved directly into registers RO - R7.
4. What is the largest hex value that can be moved into an 8-bit register? What is the decimal equivalent of the hex value?
5. The vast majority of registers in 8051 are bits.
1. MOV A,#34H
MOVB,#3FH
ADDA,B
2. MOV A,#16H
ADDA,#OCDH
MOVR2,A
3. False
4. FF hex and 255 in decimal
5. 8
1. What is the purpose of pseudo-instructions?
2. Are translated by the assembler into machine code, whereas are not.
3. (True or False) Assembly language is a high-level language.
4. Which of the following produces opcode?
(a) ADD A,R2
(b) MOV A,#12
(c) ORG 2000H
(d) SJMP HERE
5. Pseudo-instructions are also called ______________
6. (True or False) Assembler directives are not used by the CPU itself. They are simply a guide to the assembler.
7. In question 4, which one is an assembler directive?
Answers:
1. The real work is
performed by instructions such as MOV and ADD. Pseudo-instructions, also called assembler
directives, instruct the assembler in doing its job.
2. The instruction mnemonics, pseudo-instructions
3. False
4. All except (c)
5. Assembler directive
6. True
7. (c)
SECTION 2.3: ASSEMBLING AND RUNNING AN 8051 PROGRAM
1. True or false. The DOS program EDIT produces an ASCII file.
2. True or false. Generally, the extension of the source file is "asm" or "src".
3. Which of the following files can be produced by the DOS EDIT program?
(a) myprog.asm
(b) myprog.obj
(c) myprog.exe
(d) myprog.lst
4. Which of the following files is produced by an 8051 assembler?
(a) myprog.asm
(b) myprog.obj
(c) myprog.hex
(d) myprog.lst
5. Which of the following files lists syntax errors?
(a) myprog.asm
(b) myprog.obj
(c) myprog.hex
(d) myprog.lst
Answers:
1. True
2. True
3. (a)
4. (b) and (d)
5. (d)
SECTION 2.4: THE PROGRAM COUNTER AND ROM SP ACE IN THE 8051
1. In the 8051, the program counter is bits wide.
2. True or false. Every member of the 8051 family, regardless of the maker, wakes up at memory OOOOH when it is powered up.
3. At what ROM location do we store the first opcode of an 8051 program?
4. The instruction "MOV A, #44H" is a -byte instruction.
5. What is the ROM address space for the 8052 chip?
Answers:
1. 16
2. True
3. OOOOH
4. 2
5. With 8K bytes, we have 8192 (8 x 1024 = 8192) bytes, and the ROM space is 0000 to lFFFH.
SECTION 2.5: 8051 DATA TYPES AND DIRECTIVES
1. The directive is always used for ASCII strings.
2. How many bytes are used by the following?
DATA 1: DB "AMERICA"
3. What is the advantage in using the EQU directive to define a constant value?
4. How many bytes are set aside by each of the following directives?
(a) ASC_DATA: DB "1234"
(b) MY_DATA: DB "ABC1234"
5. State the contents of memory locations 200H - 205H for the following:
ORG 200H MYDATA: DB "ABC123"
Answers:
1. DB
2. 7
3. If the value is to be changed later, it can be done once in one place instead of at every occurrence.
4. (a) 4 bytes (b) 7 bytes
5. This places the ASCII values for each character in memory locations starting at 200H. Notice that all values are in
hex.
200 = (41)
201 = (42)
202 = (43)
203 = (31)
204 = (32)
205 = (33)
SECTION 2.6: 8051 FLAG BITS AND THE PSW REGISTER
1. The flag register in the 8051 is called _
2. What is the size of the flag register in the 8051?
3. Which bits of the PSW register are user-definable?
4. Find the CY and AC flag bits for the following code.
MOVA, #OFFH
ADD A, #01
5. Find the CY and AC flag bits for the following code.
MOVA, #OC2H
ADD A, #3DH
Answers:
1. PSW (program status register)
2. 8 bits
3. 01 and 05, which are referred to as PSW.1 and PSW.5, respectively.
4.
5. Hex: FF + 1 = 100
Binary: 1111 1111 + 1 = 1 0000 0000
This leads to CY = 1 and AC = 1.
Hex C2 + 3D = FF
Binary 1100 0010 + 0011 1101 = 1111 1111
SECTION 2.7: 8051 REGISTER BANKS AND STACK
1. What is the size of the SP register?
2. With each PUSH instruction, the stack pointer register, SP, is (incremented, decremented) by 1.
3. With each POP instruction, the SP is (incremented, decremented) by 1.
4. On power-up, the 8051 uses RAM location as the first location of the stack.
5. On power-up, the 8051 uses bank for registers RO - R7.
6. On power-up, the 8051 uses RAM locations to for registers RO - R7
7. Which register bank is used if we alter RSO and RSl of the PSW by the following two instructions?
SETB PSW.3
SETB PSW.4
8. In Question 7, what RAM locations are used for register RO - R7?
Answers:
1. 8-bit
2. Incremented
3. Decremented
4. 08
5. 0
6. 0-7
7. Register bank 3
8. RAM locations 18H to lFH
No comments:
Post a Comment