Assignment # 3 CHAPTERS# 1,2,3: CH#1 Answers To Review Qestions SECTION 1.1
Assignment # 3 CHAPTERS# 1,2,3: CH#1 Answers To Review Qestions SECTION 1.1
CHAPTERS# 1,2,3
CH#1
ANSWERS TO REVIEW QESTIONS
SECTION 1.1:
1. True
2. Microcontroller
3. d
4. d
7. Having multiple sources for a given part part means you are not hostage
to one supplier. More importantly, cmpetition among supplier brings about
lower cost for that product.
SECTION 1.2:
1. 4KB on-chip program memory(ROM)
2. The major difference between these two is 8052 has 256 bytes of RAM
and a 3 Timers. It also has 8K bytes of on-chip ROM where as 8051 has
128 bytes of RAM,4K byte on-chip ROM and a 2 Timers.
4. (a) 4K bytes
(b) 8K bytes
(c) 0K bytes
5. 8
7. True
8. True
9. 16K
PROBLEMS:
SECTION 1.1
1. A general purpose microproceesor has on chip ROM. False
9. Give the name and manufacturer of some of the most widely used 8-
bit microcontroller?
8051
Power consumption.
12. In an embedded controller with on-chip ROM, why does the size of
the ROM matter?
ANSWER: (a)
SECTION 1.2
16. The 8751 has4K bytes of on-chip ROM.
17. The AT89C51 has 128 bytes of on-chip RAM.
18. The 8051 has 2 timers.
19. The AT89C51 has 256 bytes of on-chip RAM.
20. The ROM-less version of 8051 used 8031 as the part number.
21. The 8051 family has 32 pins for I/O.
22. The 8051 family has circuitry to 1 serial ports.
23. The 8751 on-chip ROM is of type UV-EPROM
27. Give the amount of RAM and ROM for the following chips.
28. Of the 8051 family, which memory type is the most effective if you
are using a million of them in an embedded product?
OTP
8031 is ROM less version of 8051. 8031 has 0k byte ROM and
8051 has 4K byte ROM.
30 Out of the 8051 microcontroller, which one of the best for the home
development environment?(you do nlt have access to a ROM burner.)
DS89C420/30.
CH#2:
ANSWERS TO REVIEW QUESTIONS
SECTION#2.1
1. MOV A,#34H
MOV B,#3FH
ADD A,B
2. MOV A,#16H
ADD A,#0CDH
MOV R2,A
3. False
5. 8
SECTION#2.2
1. The real work is performed by instructions such as MOV and ADD.
Pseudo instructions, also called assembler directives, instruct the
assembler in doing the job.
3. False
4. All except(c)
5. Assembler directive
6. True
7. (c)
SECTION#2.3
1. True
2. True
3. (a)
5. (d)
SECTION#2.4
1. 16
2. True
3. 0000H
4. 2
2. 7
5. This places the ASCII values for each character in memory location
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
1. PSW(program status register)
2. 8 bits
4. Hex binary
FF 1111 1111
+ 1 + 1
C2 1100 0010
+ 3D + 0011 1101
FF 1111 1111
SECTION#2.7
1. 8-bit
2. Incremented
3. Decremented
4. 08
5. 0
6. 0-7
7. Register bank 3
PROBLEMS:
SECTION#2.1
1. Most registers in the 8051 are 8 bits wide.
DPTR,PC
5. To load R4 with the value of 65H the pound signal is (necessary,optional)
in the instruction "MOV R4, #65H"
Necessary
MOV A, #15H
MOV R2, #13H
ADD A,R2
A=#28H, result kept in accumulator
7. Which of the following is(are) illegal?
ANSWER: (a),(d),(f),(g)
ANSWER: (a),(c),(g)
MOV R4,#25H
MOV A,#1FH
ADD A,R4
ANSWER: A=#44H, result kept in accumulator.
10. What is the result of the followin code and where it is kept?.
MOV A,#15
MOV R5,#15
ADD A,R5
C provides a higher level syntax that makes the programmer's job much
easier,allowing them to express more logic in fewer lines of code. Often
times, code generated by a compiler is equally as good(in terms of space
and efficiency).
Assembler program.
14. The source file has the extension "src" or "asm". True
lst file
17. Every source file must have ORG and END directive. True
19. Why are ORG and END directives are called pseudocode?
SECTION#2.4
21. Every 8051 family member wakes up at address 0000H when it is
powered up.
This means that it excepts the first opcode to be stored at ROM address
100H.
24. Pick up a program listing of your choice, and show the ROM
memory addresses and their contents.
25. Find the address of last location of on-chip ROM for the each of the
following:
(a) DS5000-16
(b) DS5000-8
(c) DS5000-32
(d) AT89C52
(e) 8751
(f) AT89C51
(g) DS5000-64
26. 89C51ED-2 has a program memory space of 64K, What are its first
and last memory addesses?
0000-FFFFH
27. A given 8051 has 7FFFFH as the address of its last location of on-
chip ROM. What is the size of on-chip ROM for this 8051?
32K byte
16K byte.
SECTION#2.5
29. Compile and state the contents of each ROM location for the
following data
ORG 200H
MYDAT_1: DB "EARTH"
MYDAT_2: DB "987-65"
MYDAT_3: DB "GABEH 9B"
ANSWER:
200=45; 201=61; 202=72; 203=74; 204=68; 205=39; 206=38;
30. Compile and state the contents of each ROM location for the
following data
ORG 340H
DAT_1: DB 22,56H,10011001B,32,0F6H,11111011B
ANSWER: 340=16; 342=99; 343=20; 344=F6; 345=FB;
SECTION#2.6
31. The PSW is an 8 bit register.
32. Which bits of PSW are used for the CY and AC flag bits
respectively.
PSW.7,PSW.6
33. Which bits of PSW are used for the 0V and P flag bits, respectively?
PSW.2,PSW.0
34. In the ADD instruction when is CY raised?
CLR C
CPL C
ANS: CY=1
ADD A,#0C4H
hex binary
54 0101 010 0
+ C4 +1100 010 0
118 10001 1 0 0 0
hex binary
00 0000 0000
+ FF +1111 1111
FF 1111 1111
ADD A,#05
. hex binary
+ 05 + 0101
Code:
Org 00
MOV A,#0
DJNZ R2,AGAIN
END
SECTION#2.7
39. Which bits of the PSW are responsible for selection of the register
bank?
PSW.3 , PSW.4
40. On power-up what is the location of the first stack?
08
41. In the 8051, which register bank conflicts with the stack?
bank1
42. In the 8051, what is the size of the stack pointer (SP) register?
8bit
Bank 0
44. Give the addfress location of RAM assigned to various bank.
BANK 0: 0 to 7
45. Assuming the use of bank 0 find at what RAM location each of the
following lines stored the data.
SET PSW.4
48. Show the stack and stack pointer for each line of the following
program.
ORG 00
MOV R0,#66H
MOV R3,#7FH
MOV R7,#5DH
PUSH 0
PUSH 3
PUSH 7
CLR A
MOV R3,A
MOV R7,A
POP 3
POP 7
POP 0
END
ANSWER: START SP=07
AFTER PUSH 0: AFTER PUSH 3: AFTER PUSH 7:
0A 5D
09 7F 7F
08 66 66 66
SP=08 SP=09 SP=0A
SP=0
AFTER POP 3: AFTER POP 7: AFTER POP 0:
R3=5DH R7=7FH R0=66H
SP=09 SP=08 SP=07
49. In problem 48 does the sequence of POP instruction restore the
original values of registers R0,R3, and R7? if not, show the correct
sequence of instruction.
NO.
POP 7
POP 3
POP 0
50. Show the stack and stack pointer for each line of the following
program.
ORG 0
MOV SP,#70H
MOV R5,#66H
MOV R2,#7FH
MOV R7,#5DH
PUSH 5
PUSH 2
PUSH 7
CLR A
MOV R2,A
MOV R7,A
POP 7
POP 2
POP 5
END
ANSWER: START SP=70H
CH#3
REVIEW QUESTIONS:
SECTION#3.1
1. The mnemonic DJNZ stands for decrement and jump if not zero.
2. "DJNZ R5, BACK" combines a decrement and a jump in a
single instruction. True
A
5. LJMP is a 3-byte instruction.
SECTION#3.2
1. What do the mnemonics "LCALL" and "ACALL" stand for?
Upon executing the RET instruction, the CPU pops off the
top two bytes of the stack into the PC register and starts to
execute from this new location.
5. The LCALL instruction is a 3-byte instruction.
SECTION#3.3
1. In the 8051, the machine cycle lasts 12 clock cycles of the
crystal frequency. True
11.092MHz /1=11.0592MHz;
MC=1/11.0592MHz=0.0904microsec=90.4microsec.
PROBLEM:
SECTION#3.1
1. In the 8051, looping action with the instruction "DJNZ Rx, rel
address" is limited to 256 iterations.
2. If a conditional jump is not taken, what is the next instruction to
be executed?
SECTION#3.2
17. LCALL is a 3 byte instruction.
18. ACALL is a 2 byte instruction.
2 byte.
22. When ACALL is executed, how many bytes of the stack are
used?
1 byte.
23. Why do the PUSH and POP instruction in a subroutine need to be
equal in number?
The reason is that the stack keeps track of where the CPU
should return after completing the subroutine and must be
balanced if PUSH and POP instruction.
24. Describe the action assocciated with the POP instruction.
SECTION#3.3
27. Find the system frequency if the machine cycle =1.2microsec.
8051 chips
F=18MHz/12=1.5MHz
Machine Cycle(MC)=1/F
MC=1/1.5Mhz=0.6667microseconds.
29. Find the machine cycle if the crystal frequency is 12MHz.
8051 chips
F=12MHz/12=1MHz
Machine Cycle(MC)=1/F
MC=1/1Mhz=1microseconds.
30. Find the machine cycle if the crystal frequency is 25MHz.
8051 chips
F=25MHz/12=2.08MHz
Machine Cycle(MC)=1/F
MC=1/2.08Mhz=0.48microseconds.
31. LJMP and SJMP instruction take the same amount of time
to execute even though one is a 3-byte instruction and the
other is a 2-byt instruction. True
32. Find the time delay for the delay subroutine if the system has an
8051 with frequency of 11.0592 MHz.
F=11.0592/12=921.6KHz
MC=1/F=1/921.6KHz
MC=1.085microseconds.
Machine Cycle
F=16/12=1.333MHz
MC=1/F=1/1.333MHz
MC=0.75microseconds.
Machine Cycle
DELAY: MOV R3, #200 1
HERE: NOP 1
NOP 1
NOP 1
DJNZ R3, HERE 2
RET 2
SOL:
There are two instructions outside the HERE loop
[200(1+1+1+2)+3]*0.75microsec=752.25microseconds
34. Find the time delay for the delay subroutine if the system has an
8051 with frequency of 11.0592 MHz.
F=11.0592/12=921.6KHz
MC=1/F=1/921.6KHz
MC=1.085microseconds.
Machine Cycles
Machine Cycles
SOL:
F=16/12=1.333MHz
MC=1/F=1/1.333MHz
MC=0.75microseconds.
TIME DELAY:
FOR HERE LOOP: 250*(1+1+1+2)= 1250 MCs
FOR AGAIN LOOP: 150*(1250+1+2)=187950 MCs
THE WHOLE PROGRAM: 187950+1+2=187953 MCs
RESULT: 187953*0.75micro=0.1406seconds.
36. Repeat problem 32 for DS89C420/30.
F=11.0592/1=11.0592MHz
MC=1/F=1/11.0592MHz
MC=90.4nanoseconds.
Machine cycle
Machine Cycles
Machine Cycle