22BHI10090 Embedded Practical File
22BHI10090 Embedded Practical File
22BHI10090 Embedded Practical File
22BHI10090
Embedded system Lab Practical
Q.1.
.global _start
_start:
mov r0, #1 // Move the value 1 into register r0
mov r1, #5 // Move the value 5 into register r1
add r2, r0, r1 // Add the values in r0 and r1 and store the result in r2
mov r0, #1 // Move the value 1 into register r0 (for write syscall)
mov r1, r2 // Move the value in r2 into register r1 (for write syscall)
mov r2, #14 // Move the value 14 into register r2 (for write syscall)
swi 0 // Call the SWI instruction to perform the write syscall
mov r0, #0 // Move the value 0 into register r0 (for exit syscall)
swi 0 // Call the SWI instruction to perform the exit syscall
Q.2.
OUTPUT:
Q.3.
OUTPUT:
Q.4.
AREA CountBits, CODE, READONLY
ENTRY
MOV R0, #0x12345678 ; Load the 32-bit number into R0
MOV R1, #0 ; Initialize the count of zeros to zero
MOV R2, #0 ; Initialize the count of ones to zero
Count LSRS R3, R0, #1 ; Shift the bits of R0 to the right by one position
BCC Zero ; Branch to Zero if the carry flag is clear
ADD R2, R2, #1 ; Increment the count of ones
B Count ; Branch to Count to continue the process
Zero ADD R1, R1, #1 ; Increment the count of zeros
B Count ; Branch to Count to continue the process
SWI &11 ; Exit the program
END
OUTPUT:
Q.5.
OUTPUT:
Q.6.
void setup() {
pinMode(PWM_PIN, OUTPUT); // Set the PWM pin as output
pinMode(BUTTON_PIN, INPUT_PULLUP); // Set the button pin as input with
pull-up resistor
analogWrite(PWM_PIN, motor_speed); // Set the initial motor speed
}
void loop() {
if (digitalRead(BUTTON_PIN) == LOW) { // Check if the button is pressed
motor_speed += 10; // Increase the motor speed by 10
if (motor_speed > 255) { // Check if the motor speed is at maximum
motor_speed = 0; // Reset the motor speed to zero
}
analogWrite(PWM_PIN, motor_speed); // Set the new motor speed
delay(100); // Wait for 100 milliseconds
}
}
OUTPUT:
Q.7.
#include <SPI.h>
#include <MFRC522.h>
void loop() {
if (rfid.PICC_IsNewCardPresent()) { // Check if a new card is present
if (rfid.PICC_ReadCardSerial()) { // Check if the card data can be read
Serial.print("UID: ");
for (int i = 0; i < rfid.uid.size; i++) { // Print the UID of the card
Serial.print(rfid.uid.uidByte[i] < 0x10 ? "0" : "");
Serial.print(rfid.uid.uidByte[i], HEX);
}
Serial.println();
rfid.PICC_HaltA(); // Halt the card
rfid.PCD_StopCrypto1(); // Stop encryption on the RFID module
}
}
}
OUTPUT: