You are on page 1of 61

080290040

MICROCONTROLLER & RISC ARCHITECTURE

PART- A
Short Questions & Answers

Compiled by

PROF. N.SHANMUGASUNDARAM,
Professor & Head, ECE Department,
Vidyaa Vikas College of Engineering & Technology
Tiruchengode – 637214, Namakkal Dt., T.N.
MICROCONTROLLER AND RISC ARCHITECTURE
(2 MARKS – Q & A)

Unit – I
INTRODUCTION TO INTEL 8051 ARCHITECTURE

1. What is microcontroller?
Microcontroller is a single IC which contains the CPU with integrated
peripherals like memory, serial ports, parallel ports, timer/counter, interrupt
controller, data acquisition interfaces like ADC, DAC.

On-chip On-chip
CPU
ROM RAM
Timers I/O Ports Serial Port
Internal blocks of Microcontroller

2. Compare Microprocessor and Microcontroller.

S.No Microprocessor Microcontroller

1 The functional blocks of a The functional blocks of


microprocessor are CPU which microcontroller includes a CPU,
contains ALU, few registers, Timers, Parallel I/O ports, Serial
timing and control unit. I/O port, and internal RAM and
ROM memory.

Some microcontrollers have even


ADC and/or DAC on-chip.
2 µP operates on byte/word data. µC operates on bit/byte data.
Hence, it has LESS Hence, it has MORE
Bit manipulation instructions. Bit manipulation instructions.

3 A µP based system requires large A µC based system can be formed


no. of peripherals and hence, its without using additional peripheral
PCB will be LARGE. ICs. Hence, it’s PCB will be SMALL.

4 A µP based system is used for A µC based system is used for


General purpose computing and application specific dedicated
Data processing applications. systems.
Eg. Washing machines, Mobile
phones, Microwave oven,
Elevators, etc.
5 It involves movement of code & It involves movement of code &
data between µP and external data between internal memory &
memory. CPU inside µC.

Hence MORE instructions are Hence FEWER instructions are


made available for data transfer available for data transfer with
with external memory. external memory.
3. List the features of 8051.
Features of 8051 are:
• Data size is 8-bit
• Address lines is 16-bit (∴Memory capacity = 216 = 64 KB)
• Memory capacity of On-chip RAM is 128 Bytes
• Memory capacity of On-chip ROM is 4 KB
• Total program memory space is 64KB
• Total data memory space is 64KB
• On-chip Timers - 2 x 16-bit each
• 4 x 8-bit I/O Ports
• One full duplex Serial port (TxD & RxD)
• Six Interrupt sources (inclusive of two H/w interrupts – INT0, INT1)

4. Draw the Pin diagram of 8051.

5. List the alternate functions of Port3 in 8051.


6. Draw the program memory organization in 8051.

7. Draw the data memory organization in 8051.

8. Draw the Internal RAM memory organization in 8051.


9. What is meant by bit addressable memory?
Out of the 128 bytes of internal RAM in 8051, only 16 bytes of it are bit-
addressable. The bit addressable RAM locations are 20H to 2FH. These 16
bytes of RAM provide 128 bits (16 bytes x 8 bits) bit-addressability with the
address from 00H to 7FH.

10. What is Program Status Word?


PSW is another name for Flag register. It holds various flags, which are
useful for the programmer to test the condition of the result and make
decisions. The format of PSW of 8051 microcontroller is shown in fig below.

Program Status Word (Flag Register)

The PSW consists of four math flags and two register bank select bits. The
math flags are Carry, Auxiliary Carry, and Overflow and Parity flags.

The register bank select bits RS1 and RS0 are used to select any one of the
four register banks of the internal RAM. At any instant, the microcontroller
can work with (or access) only one register bank, which is selected by these
bits.

11. State the function of RS1 and RS0 bits in the flag register of 8051.

12. List the various registers used in 8051.


The registers used in 8051 are Accumulator (A), B-Register,
Stack Pointer (SP), Program counter (PC), Flag Register (PSW),
Data Pointer (DPTR), Timer Registers (TH0, TL0, TH1, TL1) and other SFRs
13. Define Stack Pointer.
The stack pointer is 8 bit register which points the stack top. It is
incremented before data is stored during PUSH and CALL instructions. After
reset of the processor, the SP is 07H.

14. Define Program Counter.


Program counter is a 16 bit register which holds the 16-bit address of the
program instruction currently executed by the processor. PC is automatically
incremented after every fetch of instruction byte from the memory for its
execution.

15. What is the significance of DPTR?


DPTR is a 16-bit register which is used as Data Pointer for external data
memory. It holds the 16-bit address of the data stored in the external data
memory.
This can also be used as two numbers of 8-bit data pointers namely DPH and
DPL. The 8-bit data pointers are used for accessing internal RAM and SFR.
The contents of data pointer are programmable using instructions.

16. What is the significance of pin in 8051?

is an output pin and stands for “Program Store Enable”. When


external ROM holds the code, this pin is connected to OE pin of the ROM.

17. What is the significance of pin?


EA stands for External Access. By applying LOW to this pin, makes 8051 to
omit internal 4KB on-chip ROM and use only external memory for program
storage. By applying HIGH to this pin, makes 8051 to use internal 4KB on-
chip ROM along with external memory for program storage.
18. List the Special Function Registers (SFRs).
The 21 internal registers which form SFR are listed in table below.
Each register of SFR has one byte address (between 80H and FFH). Some of
the registers are both byte and bit addressable (the registers whose address
ends with 0H or 8H are bit addressable). These registers can be accessed
either by their names or by their 8-bit address in direct addressing mode.

19. Draw the structure of a pin in port 1.

Each pin in I/O Ports of 8051 has i) Latch ii) tri-state buffers and iii) driver
transistor. Only Ports 1, 2, & 3 has internal pull-up resistor in collector
terminal of driver transistor.
20. Why all pins of a port is loaded with value “FF” before using it?
All ports of 8051 are configured by default as Output port.
Hence, to make it configured as Input Port, all pins of a port are loaded with
value “FF” i.e., 1111 1111.

20. Justify why the crystal oscillator frequency in 8051 is chosen as


11.0592Mhz.
When an 8051 microcontroller based system is connected to an external
serial communication device, the speed of the data transfer should be in
standard baud rates such as 4800, 9600, etc.

Only XTAL (Crystal Oscillator) of 11.0592 MHz can provide such standard
baud rates, after down scaling down by 12, 32 at UART and by a factor set in
timer register TH1.

21. Draw the format of TMOD register of 8051.

22. List the modes of Timer in 8051.

The modes of timer in 8051 are chosen with the help of two bits,
viz., M0 & M1 in TMOD register. The different modes of timer are as follows.

M1 M0 Mode Description of Timer mode


0 0 0 13 bit timer
0 1 1 16-bit timer
1 0 2 8-bit timer with auto reload
1 1 3 Split timer

23. What is the significance of C/T bit in TMOD register of 8051?


The C/T bit in the TMOD register is a selector bit for the type of operation we
want to perform in the timer register. HIGH in that bit indicates Counter
operation and LOW in that bit indicates Timer operation.

0 Timer operation
1 Counter operation
24. What is the significance of TRx bit in TCON register of 8051?
TRx bit in the TCON register is used to Start / Stop the timer register for
both timer and counter operation, by setting that bit with value ‘1’ or ‘0’.

25. Draw the format of TCON register of 8051.

26. Explain the Timer operation of 8051.

In this mode, the timer register is used to generate the time delay using the
clock signal applied to the processor.

An initial count is loaded in the timer register. When the timer is started, the
timer register content gets incremented after every machine cycle. When the
timer register crosses (i.e., overflows) the count FFFFH and goes to 0000H,
the timer overflow flag in TCON register becomes set.

Hence, by loading appropriate value in the timer register, a specific time


delay can be generated using timer. One machine cycle consists of 12 clock
signal periods and the delay is equal to count value loaded * time period of
one machine cycle.
27. Explain the Counter operation of 8051.

In this mode, the timer register is used to count the external events with the
help of external pulses received through the counter input (t0 & T1).

An initial count is loaded in the timer register. When the timer is started, the
timer register content gets incremented after every external pulse. When the
timer register crosses (i.e., overflows) the count FFFFH and goes to 0000H,
the timer overflow flag in TCON register becomes set. Hence, by loading
appropriate value in the timer register, counting of external event can be
performed using timer.

28. List the Interrupt sources in 8051.


The Six Interrupt sources in 8051 are
• RESET
• INT0, INT1
• TF0, TF1
• SPI (TI/RI)

29. What is the default priority of the interrupts in 8051?


30. Draw the format of IE register.

31. Draw the format of IP register.

32. What are the types of serial communication?


The serial communication can be,
• Synchronous (continuous)
• Iso-Synchronous (with regular time intervals)
• Asynchronous (with irregular time intervals)

33. Draw the Frame format of Asynchronous serial communication.


The asynchronous data frame starts with a Start bit (0), followed by data
byte (LSB first and MSB last) and a Stop bit (1).
34. Define Baud rate.
Baud Rate: It is the speed of serial data transfer, expressed in bits/sec.
The standard baud rates used for serial communication are
110, 150, 300, 600, 1200, 2400, 4800, 9600, 19200…

35. Explain the Serial Communication in 8051.


SERIAL COMMUNICATION IN 8051

The serial communication in 8051 is carried out using two SFR registers,
1. SCON
2. SBUF

SCON register is used to control and set the mode of serial communication.
SBUF register is used to dump the data before serial transmission and hold
data after serial reception.

36. Draw the format of SCON register of 8051.


37. What are the modes of asynchronous serial communication in 8051?
The mode of serial communication is decided by two bits SM0 & SM1 in
SCON register. The details of the various modes are described in the table
given below.

SM0, SM1 Mode Serial Mode Description Baud rate


00 0 8-bit Shift register FOsc / 12
01 1 8-bit UART Variable
10 2 9-bit UART FOsc / 32 or 64
11 3 9-bit UART Variable

Note: Out of all modes, Mode-1 is commonly used mode for serial data transfer in 8051.

38. Explain how baud rate is calculated for serial data transfer in mode 1?
General Expression for setting baud rates using TH1 register is given below.

39. Explain how baud rate is set in 8051 for serial data transfer using
timer register?

Based on the baud rate needed for serial communication, the timer register
TH1 is loaded with values as per the following calculation.

External XTAL oscillator frequency is chosen as 11.0592 MHz is to make the


UART output as 28800 Hz, so that the various baud rates are obtained by
dividing this frequency 28800 Hz with different values set in TH1 register.
Example
For baud rate of 9600; Divisor needed is 03H (because 28800 / 03 = 9600)
∴Value loaded in TH1 register = 00H – 03H = FDH
The sample values loaded in TH1 register for different baud rates.

Hex value loaded in


Baud rate Frequency Divisor
TH1 register
9600 03 FD
4800 06 FA
2400 12 EE
1200 24 DC
40. Draw the format of PCON register in 8051.

41. Compare the features of 8051, 8052 and 8031.


Unit II
THE 8051 INSTRUCTION SET AND PROGRAMMING

1. List the addressing modes of 8051.


The 8051 has the following types of addressing.
• Immediate Addressing
• Direct Addressing
• Register Addressing
• Register Indirect Addressing
• Implied Addressing
• Relative Addressing

2. List the various Instructions available in 8051 microcontroller.


• Data Transfer Instructions
• Arithmetic Instructions
• Logical Instructions
• Boolean variable Manipulation Instructions
• Program and Machine Control Instructions

3. List the steps to create the executable code from assembly program.
4. List the widely used assembler directives of 8051.

Assembler
S.No. Definition and usage
Directive
The ORG directive is used to indicate the origin of
1. ORG
the address of the assembly program
The DB directive is the most widely used data
directive in the assembler to define data. The
2. DB numbers can be in decimal, hex, or ASCII formats.
Regardless of which format is used, the assembler
converts the numbers into hex.
EQU stands for Equate. This directive is used to
3. EQU define a constant without occupying a memory
location.
The END directive is specified in the last line of the
4. END 8051 assembly program to indicate the assembler
the end of the source (.asm) file.

5. Draw and list the flags in PSW of 8051.

6. When is the overflow flag set?


In 8-bit signed number operations; OV is set to ‘1’ if either of the following
two conditions occurs.

i) There is a carry from D6 to D7; but NO carry out of D7 (CY=0)


ii) There is a carry out from D7 (CY=1); but NO carry from D6 to D7.
7. List the instructions that affect the flag bits.

8. List the Conditional jump instructions in 8051.

9. What are “Read-Modify-Write” instructions?


Some instructions read the I/O port and others read the latch. Since these
instructions that read a latch normally reads a value, possibly changing it
and rewrites it to the latch, these instructions are called “Read-Modify-Write”
instructions.

The instructions that read the latch are ANL, ORL, XRL, JBC, CPL, INC, DEC,
DJNZ, CLR PX.Y, SETB PX.Y, etc.
10. What is the limitation of Indirect addressing mode?
The indirect addressing mode is implemented using R0 & R1 registers which
are 8-bit wide. Hence, this mode supports accessing of internal Ram only.

11. Explain the operation of “SWAP A” instruction.


The SWAP instruction of 8051 interchanges the contents of lower nibble and
upper nibble of the Accumulator.

Eg. If the content of Acc is 56H before SWAP instruction; the content in
Acc becomes 65H after execution of SWAP instruction.

12. Explain the operation of “DIV AB” instruction.


“DIV AB” performs division operation (divide A by B) on two 8-bit data.
The Dividend is stored in Acc and Divisor is stored in B register before
division operation is performed. After division operation; the results i.e.,
quotient is stored in Acc and the remainder is stored in B register

Eg. MOV A, #95 ; Load 95 into Acc


MOV B, #10 ; Load 10 into B-register
DIV AB ; Now, Acc=09 (Quotient) & B=05 (Remainder)

13. Explain the operation of “MUL AB” instruction.


“MUL AB” performs multiplication operation on two 8-bit data. One operand
is stored in Acc and the other operand is stored in B register before
multiplication operation is performed. After multiplication operation; the
results i.e., quotient is stored in Acc and the remainder is stored in B register

Eg. MOV A, #65 ; Load 65 into Acc


MOV B, #25 ; Load 25 into B-register
MUL AB ; Now, 65 x 25 = E99
Where B=0E & A=99

14. Explain the operation of DJNZ instruction.


DJNZ stands for Decrement and Jump, if Not Zero.

This instruction decrements an 8-bit number stored in a register / memory


location, and the program control branches to a specific location if the
resultant number after decrement is not zero. The branching is done by
relative addressing.

The different formats of DJNZ instruction are


15. Explain the operation of CJNE instruction.
CJNE stands for Compare and Jump, if Not Equal.

This instruction compares two 8-bit numbers and the program control
branches to a specific location if the numbers are not equal. The branching is
done by relative addressing.

The different formats of CJNE instruction are

16. Explain the operation of Rotate instructions in 8051.


17. Explain why SJMP instruction is used in the place of HLT in 8051?
As microcontroller is used for a dedicated and repetitive application, there
will not be a situation in which the microcontroller is switched ‘ON’ and no
program is running in it. Hence, there is no necessity to have HLT
instruction in the instruction set of microcontroller.

At the same time, when we want to terminate the execution of a program in


8051, we use SJMP to make the program execution remain in the same
instruction.
18. Specify the single instruction, which clears the most significant bit of
B register of 8051, without affecting the remaining bits.
Single instruction, which clears the most significant bit of B register of 8051,
without affecting the remaining bits, is CLR B.7

19. Show how 8051 would represent -5.


The steps for representation of -5 in 8051 are as follows.
• Represent 5 in 8-bit binary - 0000 0101
• Invert each bit - 1111 1010
• Add 1 to inverted bits - 1111 1011 = FBH
The answer is FBH

20. What are the registers that are used for Timer operations?
The two 16-bit timer registers are TIMER0 & TIMER1.
The two registers that control the operation of timers are TMOD and TCON
registers.

21. What is Auto-reload feature in 8-bit mode of timer operation?


The timers in 8051 (Timer0 and Timer1) can be operated in 4 different
modes and mode-2 of it is called 8-bit Timer mode with Auto-reload
operation. When the count in timer register (TL) reaches the maximum value
(FF), the 8-bit initial count value is reloaded from TH to TL register
automatically.
This mode is used for setting up baud rate for serial communication in 8051.

22. What is role of GATE bit in TCON register?


Timer operation can be controlled either through software or hardware and
GATE bit in TCON register decides the selection of control (H/w or S/w) for
the timers.

23. List the steps in programming the Timers.


• Choose the Timer (Timer0 or Timer1)
• Decide the mode of control for timer (through GATE bit of TMOD)
• Decide the operation (Counter or Time Delay through C/T bit of TMOD)
• Select the mode of operation (through M0 & M1 bits of TMOD)
• Accordingly to above, set the Hex value in TMOD register
• Load the initial count value in Timer register (TH & TL)
• Start the Timer (by setting ‘1’ I TR bit of TCON)
• Check whether TF bit of TCON has become ‘1’
• When TF becomes ‘1’; Stop the timer (by clearing the TR bit of TCON)
24. List the sources of Interrupt in 8051.

25. What is the importance of EA bit in IE register of 8051?


EA stands for “Enable All” and it is D7 bit of IE register. Hence, before
executing a program, EA bit has to be set to ‘1’ to enable all interrupts of
8051.

26. What is interrupt polling?


The interrupts can be serviced by two methods.

I Method: Until receipt of an interrupt; the processor can execute the


instructions and the interrupt sub routines (ISR) can be invoked
upon receipt of interrupt at hardware interrupt pins.

II Method: Interrupt Polling is the second method in which the processor


periodically checks the status of the external devices for interrupt
and services them.

Interrupt polling method consumes the processor time and


hence, this scheme is not used in most of the applications.

27. List the default priority of the interrupts in 8051?


The default priority of interrupts in 8051 is listed below from highest to
lowest priority.

Interrupts Priority
IE0 – Ext. Interrupt 0
TF0 – Timer0 Flag
IE1 – Ext. Interrupt 1
TF1 – Timer1 Flag
RI / TI – Serial Comm. Interrupt
TF2 – Timer2 Flag (in 8052 only)
28. List the steps in executing an interrupt.
Upon activation of an interrupt, the microcontroller goes through the
following steps.

• It completes the execution of current instruction and saves the


address of next instruction on stack.
• It also saves the status of all interrupts internally.
• It jumps to fixed location (Interrupt vector table) in memory to find
the address of corresponding ISR program.
• It jumps to new address and starts executing ISR program. As last
instruction of ISR program is RETI, it returns back to main program.
• Microcontroller restores the original status and starts resuming the
execution of the suspended program.

29. What is the difference between RET and RETI instructions?


RET stands for ‘Return’ and it makes the program control to return to the
main program after executing a sub program.

RETI stands for “Return from Interrupt’ and it makes the program control to
return to the main program after executing an Interrupt Sub Routine
program.

30. What is the role of IE and IP registers of 8051.


Interrupt Enable (IE) register controls the enabling and disabling of all
interrupts in 8051.

Interrupt Priority (IP) register helps to change the priority assigned to all
interrupts in 8051.

31. State the formula for baud rate calculation in 8051.

The 8-bit value in the timer register TH1 and the oscillator frequency (XTAL)
decides the baud rate for the serial communication in 8051.

32. How baud rate can be doubled?


The D7 bit of PCON (i.e., SMOD bit) can be set to 1 which makes the baud
rate doubled for serial communication. (Refer above formula).
33. What is RS232 standard?
RS232 is a serial communication standard adopted by electronics industry
with -3V to -25V for level ‘1’ and +3V to +25V for level ‘0’. But, the
microcontroller and most of the peripheral ICs support only TTL / CMOS logic
which needs MAX232 IC for level conversion to make it compatible with
RS232 logic.

34. What is UART?


UART stands for Universal Asynchronous Receiver Transmitter.

8051 supports Asynchronous mode for serial communication (mode-1) and


SM0 & SM1 bits of the SCON register decides the mode of operation for
serial communication.

35. Explain the operation of IC MAX232.


MAX232 is a voltage level converter IC from Maxim Corporation. It operates
on +5V power source as 8051 and it converts the TTL voltage level at
Microcontroller to RS232 voltage level at the Computer or any external serial
communication devices.

36. List the steps in programming for Serial communication in 8051.


FOR TRANSMISSION:
• Set the baud rate for serial communication by choosing appropriate
Hex value in TMOD and Timer register (TH).
• Load the data in SBUF register
• Start the Timer (by making TR bit = 1)
• Check the status of TI flag in SCON register
• When TI flag becomes ‘1’; Stop the timer (by making TR bit = 0)
• After reloading the next data, repeat the above process from step 2.
FOR RECEPTION:
• Set the baud rate for serial communication by choosing appropriate
Hex value in TMOD and Timer register (TH).
• Start the Timer (by making TR bit = 1)
• Check the status of RI flag in SCON register
• When RI flag becomes ‘1’; Stop the timer (by making TR bit = 0)
• Copy the received data at SBUF register and repeat the above process
from step 2.
PROGRAMMING EXAMPLES
Unit III
THE 8051-REAL WORLD INTERFACING

1. Draw the interface diagram for connecting LCD with 8051.

2. List and describe the function of pins of LCD.

3. List the status of RS, R/W and E pins for data & command operations
in LCD.

Pin / Operation Command Data


RS (Register Select) 0 1
0 – Write 0 – Write
R/W (Read/Write)
1 – Read 1 – Read
E (Enable) H-to-L Pulse H-to-L Pulse
4. List and describe the LCD command codes.

5. List the two methods for sending data / command to LCD.


I Method: Send the data / command to LCD after a predefined time delay.

II Method: Send the data / command to LCD after checking the busy flag
(D7 bit of Status register) in LCD.

6. Draw the structure of stator windings & Rotor of Stepper motor.


7. List the normal steps sequence for stepper motor.

8. List the other steps sequence for stepper motor.


The other step sequences for stepper motor are

9. What is a Step angle?

Step angle is the minimum angle of rotation made by the rotor of the
stepper motor. Based on the step angle, the no. of steps to make one
complete revolution varies accordingly.
9. How the speed of stepper motor can be controlled?
The speed of stepper motor can be controlled by introducing a time delay in
between the steps sequence.

10. Draw the connection of stepper motor with 8051.

11. What is the role of ULN2003IC in stepper motor interface with 8051?
As 8051 has limited capacity; ULN2003 driver IC is used to deliver the
required current to the coil windings and drive the stepper motor.

12. Draw the signal flow diagram of 8255 and describe its operation.

The 8255 is a Programmable Peripheral


Interface (PPI) IC, which supports parallel
data transfer between microcontroller and
external devices.

It has three ports (Port A, Port B and Port C).


These three ports can be programmed to
operate either in I/O or BSR mode.
In I/O mode, it can be programmed to
operate in Mode_0 (simple I/O), Mode_1
(Hand shake I/O) and Mode_2 (Bi-directional
I/O) modes.

Address lines A0 & A1 are used to select the


ports (A, B or C) and Control register for read
/ write operations.
13. Draw the control word format for I/O mode operation in 8255.

13. Draw the control word format for BSR mode operation in 8255.

14. Draw the 8255 interface diagram with ADC and 8051.
15. Programming example for 8255.
16. Draw the pin diagram of SRAM and DRAM.
The pin diagram of SRAM and DRAM is shown below.

17. Draw the two methods of address decoding logic used for external
memory.

I Method: Logic gates as Address Decoder

II Method: 3x8 Decoder as Address Decoder


18. What is meant by demultiplexing of address and data lines in 8051?
Due to shortage of pins in 8051, the address lines (A0-A7) and data lines
(D0-D7) are combined as (AD0-AD7). The process of separating the address
and data lines with the help of ALE signal and Latch (74LS373) is called
Demultiplexing.

19. Draw the interface diagram for external program memory with 8051.

Fig. Interfacing External Program Memory


20. Draw the interface diagram for external data memory with 8051.

Fig. Interfacing External Data Memory

21. Draw the interface diagram for external data & program memory
with 8051.
22. Find the address range of the given memory design?

The address lines used in memory is A0-A13 (14 lines) and the memory
capacity is 16KB (214 = 16KB).

As per the given address decoding logic, the address lines A14=1 and
A15=0. Therefore, the address range is as follows.

A15 A14 A13 ~ A0 Hex Addr


0 1 00 0000 0000 0000 4000
0 1 11 1111 1111 1111 7FFF

23. What is checksum byte?


In order to detect errors, the last byte in a block of data is calculated
through a procedure to detect errors and it is called as Checksum Byte.

Each data byte in a block of data is sequentially added and the carry is
ignored in each addition. The final value obtained in such addition is called
Checksum byte.

24. What is memory refreshing in DRAM and why is it needed?


The information (one-bit) stored in DRAM is in the form of electric charge in
junction capacitance of a MOS transistor. This charge slowly decays over a
period of time and it has to be restored back before it gets completely
decayed. Thus, the process of restoring the stored information in the MOS
transistor is called memory refreshing.

25. Compare MOVC and MOVX instructions.


MOVC: MOVC is a data transfer instruction which is used for transfer of
program code between external program memory and the
internal registers of 8051 microcontroller.
Eg. MOVC A, @A+PC

MOVX: MOVC is a data transfer instruction which is used for transfer of


data byte between external data memory and the internal
registers of 8051 microcontroller.
Eg. MOVX A, @A+DPTR
26. What is Signal conditioning?
The process of removing the unwanted signal, amplifying and converting the
output of sensor into voltage form is called Signal Conditioning.

27. Explain linear and non-linear sensors with an example.


If the relationship between the output and input of a sensor is linear; the sensor
would be called as Linear sensor and otherwise it is called as Non-linear Sensor.

Eg. Linear Sensor - LM34, LM35 (Temperature sensors)


Non-linear Sensor - LDC (Light Dependent Resistor)

28. With Vref/2=0.64V in ADC804,


Find the Vin for the output D0-7=’11111111’?

Since Vref / 2 = 0.64 V; the full scale reference voltage Vref is 1.28 V.
Therefore, the output for Vin = ‘1111 1111’ is 1.28 V (i.e., Vref value).

29. In ADC804, what is the VRef/2 value for step size of 20mV?
The resolution of ADC804 is 8-bits and hence it can have 28 = 256 input
combinations.

If the step size is 20mV; then the full scale value for 256 combinations is
256 x 20mV = 5.12 V

Therefore; the Vref / 2 = Full scale value / 2 = 5.12 V / 2 = 2.56 V (ans).

30. Which pin of ADC804 indicates the end-of-conversion?


INTR pin of ADC804 indicates the end-of-conversion to the microcontroller.

31. What is the conversion time of an ADC?


It is the time taken to completely convert the analog signal into a digital
signal in the A/D converter and the minimum conversion time in ADC804 is
110µS.
32. What is the use of LM336 IC in DAC0808 interface?
The DAC requires a constant and regulated reference signal. LM336 is a IC
which provides the regulated signal for reference with the help of Zener
diode in it.

33. What is the use of LM336 IC in DAC0808 interface?


The DAC requires a constant and regulated reference signal. LM336 is a IC
which provides the regulated signal for reference with the help of Zener
diode in it.

35. Draw the interface diagram of DAC0808 with 8051.

36. Write a program for saw-tooth wave generation using DAC0808.


ARM PROCESSOR

Unit IV:

1. Define Pipelining.
Starting the execution of next instruction before the current instruction
execution is finished with the available hardware resources is called
pipelining. This is achieved by splitting the execution of each instruction for
more than one stage and allocating appropriate hardware for each stage. To
improve the utilization of hardware resources, and also the processor
throughput, pipelining organization is implemented.

2. What are the sequences of steps in pipelining?


A typical pipelining sequence may be as follows:
• Fetch – fetch instruction from memory.
• Decode – generating control signals for that instruction.
• Register – accessing any operands from register.
• ALU – combine the operands to produce results or memory address.
• Memory – access memory for a data operand.
• Result – write the result back to the register bank.

3. What are the hazards occur in pipelining?


Read-after-write pipeline hazard – occurs when an instruction waits for an
operand which is the result of the previous instruction.
Branching hazards – since branch instructions modify the flow of program,
it flush and refill the pipeline.

4. List the features of RISC architecture.


• Fixed 32-bit instruction size with predefined formats.
• Load - store architecture.
• Large register bank of 32–bit registers.

5. List the features of RISC processor.


• Hardwired decode logic.
• Pipelined execution.
• Single cycle execution.

6. Mention the advantages and drawbacks of RISC.


Advantages:
• Smaller die size.
• Shorter development time.
• Higher performance.
• Higher clock rate with single cycle execution.
Drawbacks:
• RISCs generally have poor code density.
• RISCs don’t execute x86 code.
7. How higher clock rates are achieved in RISC?
Higher clock rates is achieved by,
• Single cycle execution.
• High memory access rate.

8. What are the factors to be considered for low power circuit design?
• Minimize the power supply voltage, Vdd.
• Minimize the circuit activity, A.
• Minimize the number of gates.
• Minimize the clock frequency.

9. Mention the features of RISC which are used and rejected in ARM
processors.
Features used: 1. Load store architecture
2. Fixed-length 32-bit instructions
3. 3-address instruction formats.

Features rejected: 1. Register windows


2. Delayed branches
3. Single cycle execution of all instructions.

10. Explain the ARM CPSR format.


CPSR–Current Program Status Register is used to store the status bits.
31 28 27 8 7 6 5 4 0
N Z C V unused I F T mode

• Mode [4:0] (lower 5 bits) – represents the processor operating mode.


• T – 5th bit: represents currently ARM or Thumb instruction is executed.
• I, F – 6th, 7th bits: interrupt flag and fast interrupt flag.
• N, Z, C, V – Negative, Zero, Carry, overflow flags.

11. How data items are arranged in memory system?


Memory may be viewed as a linear array of bytes numbered from zero up to
2^32-l. Data items may be 8-bit bytes, 16-bit half-words or 32-bit words. A
word-sized data item must occupy a group of four byte locations starting at
a byte address which is a multiple of four. Half-words occupy two byte
locations starting at an even byte address.
12. Define Load-store architecture.
This means that the instruction set will only process (add, subtract, and so
on) values which are in registers (or specified directly within the instruction
itself), and will always place the results of such processing into a register.
The only operations which apply to memory state are ones which copy
memory values into registers (Load instructions) or copy register values into
memory (store instructions).

13. List the types of ARM instructions.


All ARM instructions fall into one of the following three categories:
1. Data processing instructions.
2. Data transfer instructions
3. Control flow instructions

14. Define supervisor mode.


The ARM processor supports a protected supervisor mode. The protection
mechanism ensures that user code cannot gain supervisor privileges without
appropriate checks being carried out to ensure that the code is not
attempting illegal operations. These functions generally include any accesses
to hardware peripheral registers, and to widely used operations such as
character input and output.

15. List the features of ARM instruction set.


The most notable features of the ARM instruction set are:
• The load-store architecture;
• 3-address data processing
• Conditional execution of every instruction;
• load and store multiple register instructions;
• Single instruction that executes in a single clock cycle;
• Open instruction set extension through the coprocessor instruction set
• Highly dense 16-bit compressed representation of the instruction set
in the Thumb architecture.

16. How I/O systems are handled in ARM?


The ARM handles I/O (input/output) peripherals (such as disk controllers,
network interfaces, and so on) as memory-mapped devices with interrupt
support.
The internal registers in these devices appear as addressable locations within
the ARM's memory map and may be read and written using the same (load-
store) instructions as any other memory locations.
17. Mention the development tools available for ARM.
• ARM C compiler.
• ARM assembler.
• The linker.
• ARM symbolic debugger.
• ARMulator.
.

18. Define ARMulator. Give its various levels of accuracy.


The ARMulator (ARM emulator) is a suite of programs that models the
behavior of various ARM processor cores in software on a host system. It can
operate at various levels of accuracy:
Instruction-accurate modeling gives the exact behavior of the system state
without regard to the precise timing characteristics of the processor.
Cycle-accurate modeling gives the exact behavior of the processor on a cycle
by- cycle basis, allowing the exact number of clock cycles that a program
requires to be established.
Timing-accurate modeling presents signals at the correct time within a cycle,
allowing logic delays to be accounted for.

19. Give the steps in exception handling.


The current state is saved by copying the PC into rl4_exc and the CPSR into
SPSR_exc (where exc stands for the exception type). The processor
operating mode is changed to the appropriate exception mode. The PC is
forced to a value between 0016 and 1C16, the particular value depending on
the type of exception.

20. Define Jump-start tools.


The Jumpstart tools from VLSI Technology, Inc., include the same basic set
of development tools but present a full X-windows interface on a suitable
workstation rather than the command-line interface of the standard ARM
toolkit. There are many other suppliers of tools that support ARM
development.

21. What are the principal components in 3-stage pipelining?


The principal components in 3-stage pipelining are:
• The register bank
• The barrel shifter
• The ALU
• The address register and incrementer
• The data registers
• The instruction decoder and associated control logic.
22. What are the factors considered to view breaks in ARM pipeline.
The simplest way to view breaks in the ARM pipeline is to observe that:
• All instructions occupy the data-path for one or more adjacent cycles.
• For each cycle that an instruction occupies the data-path, it occupies the
decode logic in the immediately preceding cycle.
• During the first data-path cycle each instruction issues a fetch for the
next instruction but one.
• Branch instructions flush and refill the instruction pipeline.

23. How performance of a processor can be increased?


There are only two ways to increase performance:
• Increase the clock rate, fclk. - This requires the logic in each pipeline
stage to be simplified and, therefore, the number of pipeline stages to be
increased.
• Reduce the average number of clock cycles per instruction, CPI .- This
requires either that instructions which occupy more than one pipeline slot
in a 3-stage pipeline ARM are re-implemented to occupy fewer slots, or
that pipeline stalls caused by dependencies between instructions are
reduced, or a combination of both.

24. What is meant by Von-Neumann bottleneck?


• Any stored-program computer with a single instruction and data memory
will have its performance limited by the available memory bandwidth.
• The fundamental problem with reducing the CPI relative to a 3-stage core
is related to the von Neumann bottleneck.
• To get a significantly better CPI the memory system must deliver more
than one value in each clock cycle.

25. What is Data forwarding?


The only way to resolve data dependencies without stalling the pipeline is to
introduce forwarding paths.
Forwarding paths allow results to be passed between stages as soon as they
are available, and the 5-stage ARM pipeline requires each of the three source
operands to be forwarded from any of three intermediate result registers.

26. How clocking scheme is implemented in ARM?


The design is based around 2-phase non-overlapping clocks, which are
generated internally from a single input clock signal. This scheme allows the
use of level-sensitive transparent latches. Data movement is controlled by
passing the data alternately through latches which are open during phase 1
and latches which are open during phase 2. The non-overlapping property of
the phase 1 and phase 2 clocks ensures that there are no race conditions in
the circuit.
27. Mention the delays to be considered for minimum data path cycle time.
The minimum data-path cycle time depends on:
• The register read time;
• The shifter delay;
• The ALU delay;
• The register write set-up time;
• The phase 2 to phase 1 non-overlap time.

28. Explain the types of multiplier used in ARM processors.


Two styles of multiplier have been used:
• Older ARM cores include low-cost multiplication hardware that supports
only the 32-bit result multiply and multiply-accumulate instructions.
• Recent ARM cores have high-performance multiplication hardware and
support the 64-bit result multiply and multiply-accumulate instructions.

29. Mention the structural components of ARM control logic.


The control logic on the simpler ARM cores has three structural components:
1. An instruction decoder PLA (programmable logic array).
2. Distributed secondary control - to select other instruction bits and/or
processor state information to control the datapath.
3. Decentralized control units for specific instructions that take a variable
number of cycles to complete (load and store multiple, multiply and
coprocessor operations).

30. Define the mechanisms used to implement processor core.


There are two principal mechanisms used to implement an ARM processor
core (or any other core, for than matter) on a particular process:
• A hard macrocell is delivered as physical layout ready to be incorporated
into the final design;
• A soft macrocell is delivered as a synthesizable design expressed in a
hardware description language such as VHDL.

31. List the features of co-processor architecture.


The coprocessor’s most important features are:
• Support for up to 16 logical coprocessors.
• Each coprocessor can have up to 16 private registers of any reasonable
size; they are not limited to 32 bits.
• Coprocessors use load-store architecture, with instructions to perform
internal operations on registers, instructions to load and save registers
from and to memory, and instructions to move data to or from an ARM
register.
32. What is a co-processor?
• The ARM architecture supports a general mechanism for extending the
instruction set through the addition of coprocessors. The most common
use of a coprocessor is the system coprocessor used to control on-chip
functions such as the cache and memory management unit on the
ARM720.
• A floating-point ARM coprocessor has also been developed, and
application-specific coprocessors are a possibility.
• Coprocessor data operations are completely internal to the coprocessor
and cause a state change in the coprocessor registers.
• ARM coprocessors have their own private register sets and their state is
controlled by instructions that mirror the instructions that control ARM
registers.

33. Define the handshaking signals used for coprocessor interfacing.


The handshake uses three signals:
1. cpi (from ARM to all coprocessors).
This signal, which stands for 'Coprocessor Instruction', indicates that the
ARM has identified a coprocessor instruction and wishes to execute it.

2. cpa (from the coprocessors to ARM).


This is the 'Coprocessor Absent' signal which tells the ARM that there is no
coprocessor present that is able to execute the current instruction.

3. cpb (from the coprocessors to ARM).


This is the 'Coprocessor Busy' signal which tells the ARM that the
coprocessor cannot begin executing the instruction yet.

34. What are the signals used in ARM bus transactions?


The memory bus interface signals include the following:
• A 32-bit address bus, A [31:0], which gives the byte address of the data
to be accessed.
• A 32-bit bidirectional data bus, D [31:0], along which the data is
transferred.
• Signals that specify whether the memory is needed (mreq) and whether
the address is sequential (seq); these are issued in the previous cycle so
that the memory control logic can prepare appropriately.
• Signals that specify the direction (r/w) and size (b/w on earlier
processors; mas[1:0] on later processors) of the transfer.
• Bus timing and control signals (abe, ale, ape, dbe, lock, bl[3:0]).
35. List the functions of control logic in memory interfacing.
The control logic performs the following functions:
• It decides when to activate the RAM and when to activate the ROM.
• It controls the byte write enables during a write operation.
• It ensures that the data is ready before the processor continues.

36. Define the buses specified in AMBA.


Three buses are denned within the AMBA specification:
• The Advanced High-performance Bus (AHB) is used to connect high-
performance system modules. It supports burst mode data transfers and
split transactions, and all timing is reference to a single clock edge.
• The Advanced System Bus (ASB) is used to connect high-performance
system modules. It supports burst mode data transfers.
• The Advanced Peripheral Bus (APB) offers a simpler interface for low-
performance peripherals.

37. Define AMBA.


• ARM processor cores have bus interfaces that are optimized for high-
speed cache interfacing and required to allow the ARM to communicate
with other on-chip macrocells.
• ARM Limited specified the Advanced Microcontroller Bus Architecture,
AMBA, to standardize the on-chip connection of different macrocells.

38. What are the signals used by bus master?


The bus master which holds the grant; then proceeds with the bus
transaction using the following signals:

• Bus transaction, BTRAN [1:0], indicates whether the next bus cycle will be
address-only, sequential or non-sequential.
• The address bus, BA[31:O]
• Bus transfer direction, BWRITE.
• Bus protection signals, BPROT[1:0], which indicate instruction or data
fetches and supervisor or user access.
• The transfer size, BSIZE[1:0], specifies a byte, half-word or word
transfer.
• Bus lock, BLOK, allows a master to retain the bus to complete an atomic
read-modify-write transaction.
• The data bus, BD[31:0], used to transmit write data and to receive read
data.
39. What are the signals used by bus slave unit?
A slave unit may process the requested transaction immediately, accepting
write data or issuing read data on BD [31:0], or signals one of the following
responses:

• Bus wait, BWAIT, allows a slave module to insert wait states when it
cannot complete the transaction in the current cycle.
• Bus last, BLAST, allows a slave to terminate a sequential burst to force
the bus master to issue a new bus transaction request to continue.
• Bus error, BERROR, indicates a transaction that cannot be completed.
If the master is a processor it should abort the transfer.

40. Why bus reset signal is required?


• It takes some time for a clock oscillator to stabilize after power-up, so
there may be no reliable clock available to sequence all the modules into
a known state.
• In any case, if two or more modules power-up trying to drive bus lines in
opposite directions, the output drive clashes may cause power supply
crow-bar problems which may prevent the chip from powering up
properly at all.
• Correct ASB power-up is ensured by imposing an asynchronous reset
mode that forces all drivers off the bus independently of the clock.

41. Define APB?


• The ASB offers a relatively high-performance on-chip interconnects which
suits processor, memory and peripheral macrocells with some built-in
interface sophistication.
• For very simple, low-performance peripherals, the overhead of the
interface is too high. The Advanced Peripheral Bus is a simple, static
bus which operates as a stub on an ASB to offer a minimalist interface to
very simple peripheral macrocells.

42. Why AHB is replaced for ASB in high performance systems?


The following features differentiate the AHB from the ASB:
• It supports split transactions, where a slave with long response latency
can free up the bus for other transfers while it prepares its data for
transmission.
• It uses a single clock edge to control all of its operations, aiding synthesis
and design verification (through the use of static timing analysis and
similar tools).
• It uses a centrally multiplexed bus scheme rather than a bidirectional bus
with tri-state drivers.
• It supports wider data bus configurations of 64 or 128 bits.
43. Mention the protocol followed to initiate a bus transfer.
The ASB specifies the protocol which must be followed:
• The master, x, issues a request (AREQx) to the central arbiter.
• When the bus is available, the arbiter issues a grant (AGNTx) to master.

44. List the components of ARMulator.


It is made up of four components:
• The processor core model, which can emulate any current ARM core
• A memory interface which allows the characteristics of the target
memory system to be modelled.
• A coprocessor interface that supports custom coprocessor models.
• An operating system interface that allows individual system calls to be
handled by the host or emulated on the ARM model.

45. Mention the test signals used by JTAG.


The interface works with five dedicated signals which must be provided on
each chip that supports the test standard:
• TRST is a test reset input which initializes the test interface.
• TCK is the test clock which controls the timing of the test interface
independently from any system clocks.
• TMS is the test mode select which controls the operation of the test
interface state machine.
• TDI is the test data input line which supplies the data to the boundary
scan or instruction registers.
• TDO is the test data output line which carries the sampled values from
the boundary scan chain and propagates data to the next chip in the
serial test circuit.

46. Define TAP controller.


• The operation of the test interface is controlled by the Test Access Port
(TAP) controller. This is a state machine whose state transitions are
controlled by TMS.
• All the states have two exits so the transitions can be controlled by one
signal, TMS.
• The two main paths in the state transition diagram control the operation
of a data register (DR) and the instruction register (IR).
47. What are the public instructions supported by compliant devices?
The minimum set of public instructions that all compliant devices must
support is:
• BYPASS: here the device connects TD Ito TDO though a single clock delay.
• EXTEST: here the boundary scan register is connected between TDI and
TOO and the pin states are captured and controlled by the register.
• IDCODE: here the ID register is connected between TDI and TDO. In the
Capture DR state the device ID is copied into the register which is then
shifted out in the Shift DR state.
• INTEST: here the boundary scan register is connected between TDI and
TDO and the core logic input and output states are captured and
controlled by the register.

48. What is an Embedded-ICE?


• The Embedded-lCE module consists of two watch-point registers and
control and status registers. The watch-point registers can halt the ARM
core when the address, data and control signals match the value
programmed into the watch-point register.
• Since the comparison is performed under a mask, either watch-point
register can be configured to operate as a breakpoint register capable of
halting the processor when an instruction in either ROM or RAM is
executed.
• The breakpoint and watch-point registers which are accessed as
additional data registers using special JTAG instructions and a trace
buffer which is similarly accessed.
• In addition to the breakpoint and watch-point events, it may also be
desirable to halt the processor when a system-level event occurs. The
debug architecture includes external inputs for this purpose.
• The on-chip cell containing these facilities is called the Embedded-lCE
module.

49. List the types of debugging.


There are two basic approaches to debugging are
• Desktop debugging - watching a system from the outside, using the test
equipment such as logic analyzer.
• Embedded debugging - on viewing a system from the inside with tools
that support single stepping, he setting of breakpoints, and so on.

50. What are the types of ARM7TDMI cycle/memory access?


Cycle Use
N Non-sequential memory access
S Sequential memory access
I Internal cycle - bus and memory inactive
C Coprocessor registers transfer – memory inactive
51. Specify the features of ARM7 TDMI.
The ARM7, is a 3-volt compatible rework of the ARM6 32-bit integer core,
with:
• The Thumb 16-bit compressed instruction set;
• On-chip Debug support, enabling the processor to halt in response to a
debug request;
• An enhanced Multiplier, with higher performance than its predecessors
and yielding a full 64-bit result.
• Embedded-lCE hardware to give on-chip breakpoint and watch-point support.

52. How ARM7TDMI is modified for synthesis?


The ARM7TDMI-S is a synthesizable version of the ARM7TDMI, delivered as a
high-level language module which can be synthesized using any suitable cell
library in the target technology. It is therefore easier to port to a new
process technology than is the hard macro-cell.

The synthesis process supports a number of optional variations on the


processor core functionality. These include:
• omitting the Embedded-lCE cell;
• replacing the full 64-bit result multiplier with a smaller and simpler
multiplier that supports only the ARM multiply instructions that produce a
32-bit result.

53. How Double memory bandwidth is achieved in ARM8?


• It assumes that the memory connected to processor can deliver one word
in a clock cycle and deliver the next sequential word half a cycle later
concurrently with starting the next access.
• A 64-bit wide memory has the required characteristics, but delaying the
arrival of the second word by half a clock cycle allows a 32-bit bus to be
used and can save area since routing a 32-bit bus requires less area than
routing a 64-bit bus.

54. Compare thumb decoding in ARM7& ARM9.


• The ARM7TDMI implements the Thumb instruction set by 'decompressing'
Thumb instructions into ARM instructions using slack time in the ARM7
pipeline.
• The ARM9TDMI pipeline is much tighter and does not have sufficient slack
time to allow Thumb instructions to be first translated into ARM
instructions and then decoded; instead it has hardware to decode both
ARM and Thumb instructions directly.
55. Specify the features of on chip debug of ARM9.
The Embedded-lCE functionality in the ARM9TDMI core gives the same
system-level debug features as that on the ARM7TDMI core with the
following additional features:
• Hardware single-stepping is supported.
• Breakpoints can be set on exceptions in addition to the
address/data/control conditions supported by ARM7TDMI.

56. Define ARM9E-S.


• The ARM9E-S is a synthesizable version of the ARM9TDMI core. It
implements an extended version of the ARM instruction set compared
with the 'hard' core.
• In addition to the ARM architecture v4T instructions supported by the
ARM9TDMI, the ARM9E-S supports the full ARM architecture version v5TE
including the signal processing instruction set extensions.
UNIT- V
ARM INSTRUCTION SET

1. Define Thumb instruction set.


The Thumb instruction set addresses the issue of code density. It may be
viewed as a compressed form of a subset of the ARM instruction set. Thumb
instructions map onto ARM instructions, and the Thumb programmer's model
maps onto the ARM programmer's model.
Implementations of Thumb use dynamic decompression in an ARM
instruction pipeline and then instructions execute as standard ARM
instructions within the processor.

2. How thumb entry and exits are made?


Thumb entry
• The normal way they switch to execute Thumb instructions is by
executing a Branch and Exchange instruction. This instruction sets the T
bit if the bottom bit of the specified register was set, and switches the
program counter to the address given in the remainder of the register.
• Other instructions which change from ARM to Thumb code include
exception returns, either using a special form of data processing
instruction or a special form of load multiple register instruction

Thumb exit
• An explicit switch back to an ARM instruction stream can be caused by
executing a Thumb BX instruction.
• An implicit return to an ARM instruction stream takes place whenever an
exception is taken, since exception entry is always handled in ARM code.

3. How ARM registers are modified for thumb instructions.


• R13 is used as a stack pointer.
• R14 is used as the link register.
• R15 is the program counter (PC).

4. Mention the uses of thumb branch instructions.


Typical uses of branch instructions include:
1. Short conditional branches to control loop exit;
2. Medium-range unconditional branches to 'go to' sections of code;
3. Long-range subroutine calls.
5. State the similarities & differences between Thumb & ARM instructions.
Similarities
• The load-store architecture with data processing, data transfer and
control flow instructions.
• Support for 8-bit byte, 16-bit half-word and 32-bit word data types where
half-words are aligned on 2-byte boundaries and words are aligned on 4-
byte boundaries.
• A 32-bit un-segmented memory.

Differences
• Most Thumb instructions are executed unconditionally.
All ARM instructions are executed conditionally.
• Many Thumb data processing instructions use a 2-address format - the
destination register is the same as one of the source registers. ARM data
processing instructions, with the exception of the 64-bit multiplies, use a
3-address format.)
• Thumb instruction formats are less regular than ARM instruction formats,
as a result of the dense encoding.

6. How SWI instruction is encoded in Thumb?


This instruction causes the following actions:
• The address of the next Thumb instruction is saved in r14_svc.
• The CPSR is saved in SPSR_svc.
• The processor disables IRQ, clears the Thumb bit and enters supervisor
mode by modifying the relevant bits in the CPSR.
• The PC is forced to address 0x08.

7. Explain about Thumb break point instruction.


This instruction causes the processor to take a prefetch abort when the
debug hardware unit is configured appropriately. Breakpoint instructions are
used for software debugging purposes; they cause the processor to break
from normal instruction execution and enter appropriate debugging
procedures.

8. State the thumb properties.


• The Thumb code requires 70% of the space of the ARM code.
• The Thumb code uses 40% more instructions than the ARM code.
• With 32-bit memory, the ARM code is 40% faster than the Thumb code.
• With 16-bit memory, the Thumb code is 45% faster than the ARM code.
• Thumb code uses 30% less external memory power than ARM code.
9. Write about Thumb systems.
• A high-end 32-bit ARM system may use Thumb code for certain non-
critical routines to save power or memory requirements.
• A low-end 16-bit system may have a small amount of on-chip 32-bit RAM
for critical routines running ARM code, but use off-chip Thumb code for all
non-critical routines.

10. Mention the data types supported by ARM processors.


ARM processors support six data types:
• 8-bit signed and unsigned bytes.
• 16-bit signed and unsigned half-words; these are aligned on 2-byte
boundaries.
• 32-bit signed and unsigned words; these are aligned on 4-byte boundaries.

11. Explain the types of memory organization in ARM.


• little-endian
• big-endian

Most ARM chips remain strictly neutral in the dispute and can be configured
to work with either memory arrangement, though they default to little-
endian.

12. List the operating modes of ARM processor.


i) Normal user mode.
ii) Software interrupt mode.
iii) Fast interrupt mode.
iv) Abort mode.
v) System mode.
vi) Standard interrupt mode.
vii) Undefined trap mode.

13. Define SPSR.


Each privileged mode (except system mode) has associated with it a
Saved Program Status Register, or SPSR.This register is used to save the
state of the CPSR (Current Program Status Register) when the privileged
mode is entered in order that the user state can be fully restored when the
user process is resumed.
Often the SPSR may be untouched from the time the privileged mode is
entered to the time it is used to restore the CPSR, but if the privileged
software is to be re-entrant (for example, if supervisor code makes
supervisor calls to itself) then the SPSR must be copied into a general
register and saved.
14. What are the types of ARM exceptions?
ARM exceptions may be considered in three groups:
• Exceptions generated as the direct effect of executing an instruction.
- Software interrupts undefined instructions and pre-fetch aborts.
• Exceptions generated as a side-effect of an instruction. - Data aborts
(a memory fault during a load or store data access) are in this class.
• Exceptions generated externally, unrelated to the instruction flow.
- Reset, IRQ and FIQ fall into this category.

15. List the exception vector addresses.

16. Write the steps followed in exception entry and exit.


Steps followed in exception entry:
• It changes to the operating mode corresponding to the particular
exception.
• It saves the address of the instruction following the exception entry
instruction in r14 of the new mode.
• It saves the old value of the CPSR in the SPSR of the new mode.
• It disables IRQs by setting bit 7 of the CPSR and, if the exception is a fast
interrupt, disables further fast interrupts by setting bit 6 of the CPSR.
• It forces the PC to begin executing at the relevant vector address given

Steps followed in exception exits:


• Any modified user registers must be restored from the handler's stack.
• The CPSR must be restored from the appropriate SPSR.
• The PC must be changed back to the relevant instruction address in the
user instruction stream.
17. Mention the priority followed in exception handling.
Since multiple exceptions can arise at the same time it is necessary to define
a priority order to determine the order in which the exceptions are handled.

On ARM this is:


1. Reset (highest priority);
2. Data abort;
3. FIQ;
4. IRQ;
5. Pre-fetch abort;
6. SWI, undefined instruction (including absent coprocessor).

These are mutually exclusive instruction encodings and therefore cannot


occur simultaneously

18. State the sequence of steps done during a software interrupt arises.
In detail, the processor actions are:
1. Save the address of the instruction after the SWI in r14_svc.
2. Save the CPSR in SPSR_svc.
3. Enter supervisor mode and disable IRQs (but not FIQs) by setting
CPSR[4:0] to 100112andCPSR[7]tol.
4. Set the PC to (08)H and begin executing the instructions there.

19. Mention the flags used in ARM.


• The N flag is set if the result is negative, otherwise it is cleared (that is, N
equals bit 31 of the result).
• The Z flag is set if the result is zero, otherwise it is cleared.
• The C flag is set to the carry-out from the ALU when the operation is
arithmetic (ADD, ADC, SUB, SBC, RSB, RSC, CMP, and CMN) or to the
carry-out from the shifter otherwise. If no shift is required, C is
preserved.
• The V flag is preserved in non-arithmetic operations. It is set in an
arithmetic operation if there is an overflow from bit 30 to bit 31 and
cleared if no overflow occurs.

20. State the use of r15 in programming.


• The PC value is stored in r15 and is updated for each clock cycle.
• The r15 may be used as a source operand. The value supplied is the
address of the instruction plus eight bytes.
• The r15 may also be specified as the destination for the result, in which
case the instruction is a form of branch. This is exploited as a standard
way to return from a subroutine.
21. Define SWP instruction.
Swap instructions combine a load and a store of a word or an unsigned byte
in a single instruction. Normally the two transfers are combined into an
atomic memory operation that cannot be split by an external memory access
(for instance from a DMA controller), and therefore the instruction can be
used as the basis of a semaphore mechanism to give mutually exclusive
access to data structures that are shared between multiple processes,
processors, or a processor and a DMA controller. These instructions are little
used outside their role in the construction of semaphores.

22. State the types of ARM architecture variants/versions.


The ARM architecture has undergone a number of revisions in the course of
its development. The various architecture versions are described below.
• Version 1 – These are the first ARM chips supported only26-bit
addressing and had no multiply or coprocessor support.
• Version 2 - It was still a 26-bit address machine, but included the 32-bit
result multiply instructions and coprocessor support.
• Version 2a - but added the atomic load and store (SWP) instruction and
introduced the use of coprocessor
• Version 3 – The ARM6 introduced ARM architecture version 3, which had
32-bit addressing, separate CPSR and SPSRs, and added the undefined
and abort modes to allow coprocessor emulation and virtual memory
support in supervisor mode.
• Version 3G - ARM architecture version 3G is version 3 without
backwards compatibility to version2a.
• Version 3M - ARM architecture version 3M introduces the signed and
unsigned multiply and multiply-accumulate instructions that generate the
full 64-bit result.
• Version 4 - adds the signed and unsigned half-word and signed byte
load and store instructions and reserves some of the SWI space for
architecturally defined operations. The system is introduced, and several
unused corners of the instruction space are trapped as undefined
instructions.
• Version 4T - The 16-bit Thumb compressed form of the instruction set is
introduced in version4T of the architecture.
• Version5T - the ARM architecture has been introduced recently, and at
the time of writing is supported only by ARM10 processors (and these will
soon support v5TE). It is a superset of architecture version 4T, adding
the BLX, CLZ and BRK instructions.
• Version 5TE - adds the signal processing instruction set extensions.
23. What is the state of ARM after a data abort?
The state of the ARM after a data abort depends on the particular processor
and, with some processors, on the early/late abort configuration:
• In all cases the PC is preserved (so on data abort exception entry
r14_abt contains the address of the faulting instruction plus eight bytes).
• The base register will either be unmodified, or will contain a value
modified by auto-indexing (it will not be overwritten by a loaded value).
• Other load destination registers may have been overwritten, but the
correct value will be loaded when the instruction is retried.

You might also like