Sunteți pe pagina 1din 12

Mewar University, Chittorgarh M.Tech.

CS/VLSI Design II Sem 2011 Assignment-I of Embedded System Design


1) Show the status of CY, AC, and P flags after the addition of 9Ah and 58h in the following instructions. MOV A, #9AH ADD A, # 64H Sol: MOV A, #9AH ADD A, # 64H 9A H + 64 H FE H 10011010 01100100 11111110

In this calculation, CY = 0, since there is no carry beyond D7 AC=0, since there is no carry from D3 to D7 P=1, since the accumulator has an odd number of 1s

2) Explain all conditional and non conditional jumps with examples Sol: Conditional Jumps:

3) Write a program to toggle all the bits of port1 by to it the values of 55H and AAH continuously. Put time delay between each issuing data to port 1.

4) Explain port 0 and port1 functioning. Sol: In 8051, there are four ports for I/O operations. Fig. below shows the pin diagram of 8051. It consists of 40 pins, out of which 32 pins are set aside for P0,P1, P2, P3, each using 8 pins.

8051 Pin Diagram

Dual Role of Port 0: As shown in pin diagram of 8051, port 0 is also designated as AD0-AD7, allowing it to be used for both data and address.

5) Write a program to toggle all the bits of port0 port1 and port2 every of second

6) Explain all types of addressing modes Sol:

Register Indirect Addressing Mode: In this mode, a register is used as a pointer to the data. If the data is inside the CPU, only registers R0 and R1 are used for this purpose. In other words, R2-R7 cannot be used to hold the address of an operand located in RAM when using this addressing mode. When R0 and R1 are used as pointers, that is, when they hold the address of RAM locations, they must be preceded by a @ sign, as shown below: MOV A, @R0 ; move contents of RAM location whose ; address is held by R0 into A MOV @R1, B ; move contents of B into RAM location

; whose address is held by R1

Advantage of Register Indirect Addressing Mode: One of the advantages of the register indirect addressing mode is that it makes accessing data dynamic rather than static. Indexed Addressing Mode and On-chip ROM access: Indexed addressing mode is widely used in accessing data elements of look-up table entries located in the program ROM space of the 8051. The instruction used for this purpose is MOVC A, @A + DPTR. The 16- bit register DPTR and register A are used to form the address of the data element stored in ON-chip ROM. Because the data elements are stored in the program (code) space ROM of 8051, the instruction MOVC is used instead of MOV. The C means code. In this instruction the contents of A are added to the 16-bit register of the needed data. Indexed Addressing Mode and MOVX instruction: 8051 has 64K bytes of code space under the direct control of the program counter register. In many applications, the size of program code does not leave any room to share the 64K byte code space with data. For this reason 8051 has another 64 K- byte of memory space set aside exclusively for data storage. This data memory space is referred to as external memory and it is accessed only by the MOVX instruction. In other words, 8051 has a total of 128K-bytes of memory space since 64 K-bytes of code added to 64K-bytes of data space gives 128K-bytes. One major difference between the code space and data space is that, unlike code space, the data space cannot be shared between code and data. 7)Take 10 bytes of data from RAM location 45H to 54H, add 02 to each of them and save the result in data RAM location 79H down to 70H. Solution: MOV R2, #10 MOV R0, #45H MOV R1, #79H BACK: MOV A, @R0 ADD A, # 02 MOV @R1, A INC R0 DEC R1 ; R2 is used as the counter ; R0 points to first source location ; R1 points to the first destination register ; move source byte to A ; add 2 to it ; move it to destination ; Increment the source pointer ; Decrement the destination pointer

; this is because the address of destination is in ; decreasing order. DJNZ R2, BACK ; repeat until counter value is 0.

8) write a program to save register A and B on R3 and R5 of bank 2 respectively. 9H h hx by 0mv h hx mb l hhx v B B B VB , MV B mv mv h l q h ivi B vhqbB

m mb w in, 1 nd R0 wi 0 hldg lw dgi

9) Convert hexadecimal number into decimal. Sol: Let the hexadecimal number be 9CH whose decimal equivalent is 156. To convert it to a decimal number, the method is to divide by 10 until the quotient is less than 10. In the case of a hex number between 00 and FFH, dividing by 10 twice will be enough. 9C/0A = F (quotient), 6 (remainder) this remainder will be the lowest order digit F /0A = 1 (quotient), 5 (remainder) this remainder will be the middle digit 1 (quotient which is less than 10) will be the high digit The decimal equivalent is thus 156 MOV A, #9CH ; the hex number is loaded into A

MOV B, #0AH DIV AB MOV R0, B MOV B, #0AH DIV AB MOV R1, B MOV R2, B

; move the hex divisor into B ; divide the hex number by 10 ; the remainder is in B, move it to R0 ; Reload the divisor into B ; divide the quotient by 10 ; move the remainder to R1 ; move the last quotient to R2

The decimal number is now in R2, R1 and R0 with R0 holding the lowest digit

Date of Issue ASSGN1 : 16 June 2011 Last date of submission: 10th July 2011

S-ar putea să vă placă și