In: Computer Science
Provide Atmel AVR assembly language statements to implement the
following
pseudocodes. You can assume that all the variables A, B, C, D
correspond to CPU general purpose
registers as follows: A →R0, B→R1, C→R2, D→R3. You can also use
additional registers from R4-
R31 as needed. You must not use any variant of the multiplication
instructions. Your assembly code
segments should be properly commented.
(a) if D < 0
C = A+B
else
C = A-B
(b) if D < 3
C = A+B
elseif D < 5
C = A - B
else
C = A + 8*B
a.)
MOV R3,D    //moves the value from D to R3
MOV R0,A    //moves the value from A to R0
MOV R1,B    //moves the value from B to R1
MOV R2,C    //moves the value from C to R2
CMP R3,00   //compares R3 with 0
JMP less    // if less then go to "less" section
SUB R0,R1   //else R0=R0-R1
MOV R2,R0   //move the value from R0 to R2
less: ADD R0,R1        //add R0=R0+R1
        MOV R2,R0      //move the value from R0 to R2
b.)
MOV R3,D      //moves the value from D to R3
MOV R0,A      //moves the value from A to R0
MOV R1,B      //moves the value from B to R1
MOV R2,C      //moves the value from C to R2
CMP R3,3     // compare R3 with 3
JMP less3    //jump to "less3" if R3<3
 
CMP R3,5     //compare R3 with 5
JMP less5    //jump to "less3" if R3<5
MOV AX,8     //else move 8 into accumulator to perform multiplication
MUL R1       //multiply R1 with accumulator AX=AX*R1
MOV R1,AX    //move the value from AX to R1
ADD R0,R1     //add R0and R1 and store thr result in R0
MOV R2,R0     //finally move the value from R0 to R2
less3: ADD R0,R1
       MOV R2,R0
less5: SUB R0,R1
       MOV R2,R0