Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Microcomputers questions

4,867 views

Published on

8085 microprocessor

Published in: Engineering, Technology, Business
  • Be the first to comment

Microcomputers questions

  1. 1. Reference : Microprocessor Architecture, Programming, and Applications with the 8085 Fifth Edition Ramesh S.Gaonkar INTRODUCTION to MICROCOMPUTERS in ESOGU Sample Questions with Soutions Solved by Ahmet ÖZDEMİR Chapter-6/Q-30 What is the output at PORT1 when the following instructions are executed? CODE SOLUTION MVI A,8FH ADI 72H JC DSPLAY OUT PORT1 HLT DSPLAY: XRA A OUT PORT1 HLT A 8F : 1000 1111 +72: 0111 0010 A 01 : 0000 0001 CY=1 XOR: 0000 0001 A 00 : 0000 0000 CY=0 * OUTPUT: 0000 0000 (00) (Z=1,S=0,CY=0) *After the logical operations AND, OR and XOR, the cary flag will be reset.
  2. 2. Reference : Microprocessor Architecture, Programming, and Applications with the 8085 Fifth Edition Ramesh S.Gaonkar Chapter-7/Q-45 The following program reads one data byte at a time . Identify the data bytes from the following set that will transfer the program to location ACCEPT. DATA(H) 19,20,64,8F,D8,F2 MNEMONICS SOLUTION REJECT : IN MVI CMP JC JM STA JMP JMP PORT1 B,20H B REJECT REJECT 2070H ACCEPT INVALID ADATA B20 (A)<=>(B) , IF < CY=1 OTHERS CY=0 CY=1  GO REJECT LINE S=1 GO REJECT LINE DATA IN ACCUMULATOR STORED TO ADDRESS 2070H GO TO ACCEPT LINE (DATA IS ACCEPTED) DATA IS REJECTED All data bytes compare with the data in register B what it is 20. Data bytes 20 and 64 are accepted. The other data bytes are rejected because of the data bytes 19 is smaller than 20 therefore CY is set 1 and other data bytes has negative sign flag (S=1) . Means that only data bytes 20 and 64 are stored in memory starting at 2070H.
  3. 3. Reference : Microprocessor Architecture, Programming, and Applications with the 8085 Fifth Edition Ramesh S.Gaonkar Chapter-7/Q-27 The temperatures of two furnaces are being monitored by a microcomputer. A set of five readings of the first furnace, recorded by five thermal sensors, is stored at the memory location starting at XX50H. A corresponding set of five readings from the second furnace is stored at the memory location starting at XX60H. Each reading from the first set is expected to be higher than the corresponding reading from the second set. For example, the temperature reading at the location 54H( ) is expected to be higher than the temperature reading at the location 64H( ). Write a program to check whether each reading from the first set is higher than the corresponding reading from the second set. If all readings from the fisrt set are higher than the corresponding readings from the second set , turn on the bit of the output PORT1. If any one of the readings of the first set is lower than the corresponing reading of the second set, stop the process and output FF as an emergency signal to the output PORT1. DATA(H) First Set : 82, 89, 78, 8A, 8F Second Set : 71, 74, 79, 82, 7F LXI H,XX50H LXI B,XX60H MVI C,05H READ : LDAX B CMP M JNC EMGNY INX H INX B DCR C JNZ READ MVI A,01H OUT PORT1 HLT EMGNY: MVI A,FFH OUT PORT1 HLT Get Data from SET2 Start Set up memory pointer for Set1 Set up memory pointer for Set2 Set up counter Set1 pointer ++ Set2 pointer ++ Counter -- Turn on STOP Emergency Signal On Yes No Yes No S1>S2 Count 0? is 0
  4. 4. Reference : Microprocessor Architecture, Programming, and Applications with the 8085 Fifth Edition Ramesh S.Gaonkar Chapter-9/Q-8 Write a program to meet the following specifications: a) Initialize the stack pointer register at XX99H. b) Clear the memory locations starting from XX90H to XX9FH. c) Load register pairs B,D and H with data 0237H,1242H and 4087H, respectively. d) Push the contents of the register pairs B,D and H on the stack. e) After execution the program ; verify the memory locations from XX90H to XX9FH. MNEMONICS SOLUTION CLEAR: LXI MVI LXI MVI INX DCR JNC LXI LXI LXI PUSH PUSH PUSH HLT SP,0099H A,0FH H,XX90H M,00H H A CLEAR B,0237H D,1242H H,4087H B D H After the program is executed , memory locations XX90H to XX9FH are filled with 00H, but some address contents changed later: XX92 00H XX94 40H XX96 12H XX98 02H XX93 87H XX95 42H XX97 97H XX99 00H START Initialize StackPointer Initialize Counter Clear Memory Count=Count-1 Count is 0 Load contents of B,D,H Send to stack from B,D,H No Yes END
  5. 5. Reference : Microprocessor Architecture, Programming, and Applications with the 8085 Fifth Edition Ramesh S.Gaonkar Chapter-9/Q-11 Write a program to control a railway crossing signal that has two alternately flashing red lights, with a 1-second delay on time each light. MNEMONICS SOLUTION ROTATE: DELAY: LXI MVI MOV RLC MOV ANI OUT PUSH LXI DCX MOV ORA JNZ POP JMP SP,XX90H D,AAH A,D D,A 03H PORT1 PSW H,COUNT H (6T) A,L (4T) H (4T) DELAY (10/7T) PSW ROTATE We can illustrate light1 and light2 what are and bits of output. Only one bit set at the same time. And the other bits must be reset what they are colored grey. Pattern of 0/1 bits can be provided by loading the accumulator with the number of AAH (10101010) and rotating the pattern each delay loop. I used number 03H(00000011) for masking the unused bits. Therefore only and bits are displayed at output port. I push the PSW to stack because of I used the H register pair with accumulator for OR operation in delay loop. We can calculate delay loop time with 1-second delay:
  6. 6. Reference : Microprocessor Architecture, Programming, and Applications with the 8085 Fifth Edition Ramesh S.Gaonkar Chapter-10/Q-7 Rewrite the program to convert a given number of binary data bytes into their BCD equivalents, and store them as unpacked BCDs in the Output Buffer. The number of data bytes is specified in register D in the main program. The converted numbers should be stored in groups of three consecutive memory locations. If the number is not large enough to occupy all three locations, zeros should be loaded in those locations. MNEMONICS SOLUTION START: CONVERT: STEP1: STEP2: STEP3: LXI LXI MOV MOV CALL HLT LXI PUSH LXI CMI JC SUI INR JMP CMI JC SUI INR JMP INX STAX MOV INX STAX MOV INX STAX POP RET SP,StackAddress H,BinaryNumAddress A,M D,A CONVERT H,OUTBUF B B,0000H 64H STEP2 64H C STEP1 0AH STEP3 0AH B STEP2 H H A,B H H A,C H H B Codes of convert loop are stored unpacked BCDs in the output buffer and initialize B register pair for 3 bit of decimal equivalent after the pushing. Codes of step1 loop find and stored first bit of decimal equivalent the number, if it exists. Codes of step2 loop find and stored second bit of decimal equivalent the number, if it exists Also codes of step2 loop find and stored last bit of decimal equivalent the number at the same time. BCD EQUIVALENT: First bit Second bit Third bit Codes of step3 loop, the converted numbers are stored in groups of three consecutive memory locations.
  7. 7. Reference : Microprocessor Architecture, Programming, and Applications with the 8085 Fifth Edition Ramesh S.Gaonkar Chapter-10/Q-17 Design a down-counter to count from 99 to 0 in BCD with 500 ms delay between each count. Display the count at an output port. Hint: Check for the low-order digit; when it reaches zero, adjust the next digit to nine. MNEMONICS SOLUTION START: DSPLAY: DELAY: MVI OUT PUSH CALL POP ADI DAA JMP HLT LXI DCX MOV ORA JNZ RET A,99H PORT1 PSW DELAY PSW 99H DSPLAY H,COUNT H A,L H DELAY Every counting, I display the number at PORT1. After the displaying, program will wait 500ms therefore we used call and ret operations every counting. I push the PSW to stack because of I used the H register pair with accumulator for OR operation in delay loop. Reaches the counting register 00H program will be end. I calculated delay loop time with 1-second delay : If there are any error you can contact me ozahmetdemir@gmail.com

×