Two’s complement (negation) of 0x55 -> r9
1.Write an AVR assembly language program which performs the following operations on values 0x55 and 2310 and puts the result in the given register
- ldi r30,0x55;
- ldi r31,23;
Bitwise AND -> r16
- mov r16,r31;
- and r16,r30;
Bitwise OR -> r5
- mov r5,r31;
- or r5,r30;
Bitwise EOR -> r17
- mov r17,r31;
- eor r17,r30;
Addition -> r6
- mov r6,r31;
- add r6,r30;
Difference (subtraction) -> r7
- mov r7,r30;
- sub r7,r31;
One’s complement (inversion) of 0x55 -> r8 Two’s complement (negation) of 0x55 -> r9
- mov r9,r30;
- neg r8;
2.Write AVR assembly language code snippets to
Copy the least significant three bits of register r7 to register r8. Other bits of r8 should be 0.
- mov r8,r7;
- ldi r9,0b00000111;
- and r9,r8;
Toggle the most significant four bits of register r9. Other bits should be unchanged.
- ldi r10,ob11110000;
- eor r10,r9;
Clear the least significant four bits of register r10. Other bits should be unchanged.
- ldi r11,0b11110000;
- and r11,r10;
Set the most significant four bits of register r11 to be 1. Other bits should be unchanged.
- ldi r12,ob11110000;
- or r11,r12;