...1.Find the CY and AC flags for each of the following: (a)MOV A, #3FHCY=0 No carry out from D7 ADD A, #45HAC=1 carry from D3 to D4 00111111 +01000101 10000100 (b)MOV A, #99HCY=0 No carry out from D7 ADD A, #58HAC=1 carry from D3 to D4 10011001 +01011000 11110001 (c)MOV A, #0FFHCY=1 SETB CAC=0 ADDC A, #00 SETB C-> CY=1 11111111 +CY 1 100000000 +00000000 100000000 (d)MOV A, #OFFHCY=1 ADD A, #1AC=1 11111111 + 1 100000000 (e)MOV A, #OFEHCY=1 SETB CAC=1 ADDC A, #01 11111110 + 1 11111111 + 1 100000000 (f)CLR CCY=1 MOV A, #0FFHAC=1 ADDC A, #01 ADDC A, #0 11111111 +00000001 100000000 +00000000 100000000 2. Write a program to add all the digits of your ID number and save the result in R3. The result must be in BCD. 3. Write a program to add the following numbers and save the result in R2, R3. The data is stored in on-chip ROM. ORG 250H MYDATA: DB 53, 94, 56, 92, 74, 65, 43, 23, 83 4. Modify Problem 3 to make the result in BCD. 6. State the steps that the SUBB instruction will go through for each of the following: 1. Take the 2’s complement of the subtrahend 2. Add it to the minuend 3. Invert the carry (a) 23H-12H 23H -> 00100011 00100011 12H -> 00010010 – 2’s complement+11101110 100010001 Step 3: CY=1 -> CF=0 Positive number 11H (b) 43H-53H 43H -> 01000011 01000011 53H -> 01010011 – 2’s complement+10101101 11110000 Step 3: CY=0 -> CF=1 Negative number -F0H (c) 99-99 99 -> 10011001 10011001 99 ->...
Words: 547 - Pages: 3
...Keypad System By: Julian Garcia and Christian White ET2640 Microcontrollers and Microprocessors Mr. Wysuph List of Components I. Breadboard II. 8051 microcontroller III. 4x4 Hex keypad IV. 7 – segment display V. Keil program software VI. 5 volt power supply VII. 330 ohm resistor pack VIII. 1 resistor (8.2K ohm) Progress Update Although our circuit is not built, we have made progress. We have to order a part in order for the project to work. We have to order the 4x4 hex keypad. Once the keypad arrives, we can wire it to our breadboard or the trainer. In order for this project to work, we must make sure that our circuit chips have power (VCC) and are grounded. After that is done, we will take our 33pF capacitors and connect them to our 11.0592MHz oscillator, which is connected to XTAL1 and XTAL2 on the 8051 trainer. We will then tie R1 – R4 and C1 – C4 on our hex keypad to ports 1.0 through 1.7 together on the 8051. Ports 0.0 – 0.7 on the 8051 will have a 330 ohm resistor pack connected to the 7 segment display. We will then have our 10uF capacitor tied together with the 8.2k ohm resistor, which should be connected to our reset. Test Plan To troubleshoot the circuit, we first must know how it is supposed to work. If the keypad is not working, we must check all connections and we can use a logic probe to see if we are getting an output at certain pins. We can also use the logic probe if our 7 – segment display is not lighting up or not...
Words: 310 - Pages: 2
...ET2640 Microprocessors and Microcontrollers Exercise 2.1 Muhammad Abdul Hafiz Answers of questions: 1. It is an ADD operation : 15H+13H = 28H , this result is kept in A 2. Sure, Assembly Language is more efficient in terms of code generation. 3. A compiler produces object code, which is an “obj” file. The assembler will produce an object file and a list file. 4. The List file provides a listing of error. Programming errors fall into two categories. Simple typing/syntax error will be flagged by the TExaS assembler as an error when the assembler tries to translate source code into machine code. The more difficult programming errors to find and remove are functional bugs that can be identified during execution, when the program does not perform as expected. Error messages are meant to be self-explanatory. 5. MOV A,#55H ADD A,#55H ADD A,#55H ADD A,#55H ADD A,#55H 6. The size of stack pointer in 8051 is 8 bit. 7. When 8051 is power up it use register bank 0. 8. Line program | Stack | Stack pointer | ORG 0 | | | MOV R0,#66H | 00 | 07 | MOV R3,#7H | 00 | 07 | MOV R7,#5DH | 00 | 07 | PUSH 0 | 66 | 08 | PUSH 3 | 7F | 09 | PUSH 7 | 5D | 0A | CLR A | 5D | 0A | MOV R3, A | 5D | OA | MOV R7, A | 5D | 0A | OP 3 | | | POP 7 | 5D | 09 | POP 0 | 66 | | 9. The times of loop is: 100x200=20,000 times. 10. The reason is that the stack keeps track of where the CPU should return after completing the subroutine...
Words: 348 - Pages: 2