ESD

mail@pastecode.io avatar
unknown
plain_text
2 years ago
4.8 kB
5
Indexable
Never
Q1)8051 Assembly Code to Move a block of data from Internal to External RAM Location Programmer(AT89C51)
 ORG 0000H
MOV R1,#05                                	
MOV R0,#30H                            	
MOV DPTR,#2000H                       
back:MOV A,@R0
            	 MOVX @DPTR,A         	
            	 INC R0                          
            	 INC DPTR                    	
            	 DJNZ R1,back
END
 
Q2)TEMPERATURE SENSOR INTERFACING
//TMP36 Pin Variables
int sensorPin = 0;
void setup()
{
  Serial.begin(9600); 
}
 void loop()                	
{
 int reading = analogRead(sensorPin); 
 // converting that reading to voltage, for 3.3v arduino use 3.3
 float voltage = reading * 5.0;
 voltage /= 1024.0;
 
 // print out the voltage
 Serial.print(voltage); Serial.println(" volts");
 
 // now print out the temperature
 float temperatureC = (voltage - 0.5) * 100 ;  //converting from 10 mv per degree wit 500 mV offset
                                        	   //to degrees ((voltage - 500mV) times 100)
 Serial.print(temperatureC); Serial.println(" degrees C");
 
 // now convert to Fahrenheit
 float temperatureF = (temperatureC * 9.0 / 5.0) + 32.0;
 Serial.print(temperatureF); Serial.println(" degrees F");
 Serial.println(temperatureC);
 Serial.println(temperatureF);
 delay(1000);                                 	//waiting a second
}
Algorithm:
Step 1 : initialize the sensor pin as 0
Step 2: then tmp36 pin variable setup
Step3: Convert that reading to voltage
Step4: then point the voltage in the output
Step 5: Calculate the temperature using the formula 
Temperature = (voltage-0.9)*100
Step6: Converting from 10mv per degree with 500mv 
Step7: Convert to Fahrenheit
Step8: print the fahrenheit in the output
Step9: END

 
Q3)Arithmetic’s operations using 8051 microcontroller
ORG 00H 
MOV A, 20H 
ADD A, 21H 
MOV R0, A 
MOV A, 20H 
SUBB A, 21H 
MOV R1, A 
MOV A, 20H 
MOV B, 21H 
MUL AB 
MOV R2, A 
MOV R3, B 
MOV A, 20H 
MOV B, 21H 
DIV AB
MOV R4, A 
MOV R5, B 
END
Q4)perform data transfer between two memory-blocks using 8051 microcontrollers.
ORG 00H
MOV R0, #20H
MOV R1, #30H
MOV R2, #0AH
L1: MOV A, @R0
	MOV @R1, A
	INC R0
	INC R1
	DJNZ R2, L1
END
Q5)WAP TO Find smallest number from memory blocks using 8051 microprocessor
MOV R3,#06H //length of the array
MOV DPTR,#4000H //starting address of array
MOVX A,@DPTR
MOV R1,A
NEXTBYTE: INC DPTR
MOVX A,@DPTR
CLR C //reset borrow flag
MOV R2,A //next number in the array
SUBB A,R1 //other Num-Prev largest no.
JNC SKIP

MOV A,R2 //update larger number in r1
MOV R1,A
SKIP: DJNZ R3,NEXTBYTE
MOV DPTR, #4062H //location of the result-4062h
MOV A,R1 //Smallest number
MOVX @DPTR,A //store at #4062H
END

Q6)Write an assembly language program to perform series addition of 10 eight bit numbers present from ML 30h onwards.

ORG 00H
MOV A, #00H
MOV R0, #30H //Mem. pointer
MOV R2, 0AH //counter
CLRC

L1:
ADDC A,@R0
INC R0
DJNZ R2, L1
END

Q7)Write an assembly language program to find out Square of a number present in ML 30h.

org 00h
mov a, 30h
mov b, a
mul ab
mov r0, a
mov r1, b
end

Q8)Write an assembly language program to count number of ones and zeros in a eight bit number
MOV R0, #00H // 0’S COUNT
MOV R1, #00H // 1’S COUNT
MOV R2, #08H // C0UNTER
MOV A, #97H
L3:
RLC A
JC L1 // IF TRUE NO. OF 1’S
INC R0 // NO. OF 0’S
SJMP L2

L1: INC R1 // NO. OF 1’S
L2:DJNZ R2, L3
END

Q9)Write an assembly language program to find whether given eight bit number is odd or even. If odd store 00h in accumulator. If even store FFh in accumulator.

MOV A, 20H
JB ACC.0, ODD
MOV A, #0FFH
SJMP L1
ODD:MOV A, #00H
L1:END

Q10)Write an assembly language program to sort numbers in ascending order in a given array
ORG 00H
MOV R7, #04H
L1: MOV R0, #40H
     MOV R6, #04H
L:MOV A, @R0
    INC R0
    MOV 50H, @R0
    CJNE A, 50H, NEXT
   SJMP DOWN
NEXT: JC DOWN
          MOV @R0, A
         DEC R0
         MOV @R0, 50H
         INC R0
DOWN: DJNZ R6, L
            DJNZ R7, L1
END

Q11)Write an assembly language program to find the largest element in a given array

MOV R3,#06H //length of the array
MOV DPTR,#4000H //starting address of array
MOVX A,@DPTR
MOV R1,A
NEXTBYTE: INC DPTR
MOVX A,@DPTR
CLR C //reset borrow flag
MOV R2,A //next number in the array
SUBB A,R1 //other Num-Prev largest no.
JC SKIP
MOV A,R2 //update larger number in r1
MOV R1,A

SKIP: DJNZ R3,NEXTBYTE
MOV DPTR, #4062H //location of the result-4062h
MOV A,R1 //largest number
MOVX @DPTR,A //store at #4062H
END

Q12)ARM7(LPC2148)
AREA        addsub,CODE,READONLY
MOV RO,#0002
MOV R1,#0004
ADD R2,,R1,R0
SUB R3,R2,R1
END