Logic and Rotate Instructions

Lab6- Logic and Rotate Instructions

Procedure:

Don't use plagiarized sources. Get Your Custom Essay on
Logic and Rotate Instructions
Just from $13/Page
Order Essay
  • Start the Code Composer Suite Software.
  • Select File è Switch Workspace è Other è E:\workspace\LAB6 è OK

This will create a workspace  (folder) for your project.

  • Select Project è New CCS Project
  • Fill in the following information
    1. Project name Lab6
    2. Target: select type:  MSP430FRxxxx       from pull-down list select MSP430FR4133
    3. Empty Project (with main.c)

Press Finish to complete

  • Press View è Project Explorer
  • Double Click Lab6 (Left mouse button double click)
  • Right Click mouse on Lab6. Select New è File, Enter Filename as “Logic.asm”.  Press Finish
  • Make sure that you are in CCS edit mode.
  • Press the “main.c” tab in the TI Resource Explorer
  • Type the DO_Logic(); as shown below

/*

* main.c

*/

void main(void) {

DO_Logic();

}

 

  • This code makes a call to the assembler file function called DO_Logic found in the Logic.asm file.
  • Press the “asm” tab and type the following program into the Logic.asm file.
  • Press Project è Build All. If you have no errors set the  breakpoints BP1 through BP12 as shown.
  • Press Run è You should notice that you are now in the “main.c” window if all went right.
  • Press the green arrow button, and run the program completing Table 1 through Table 5  at the specified breakpoints.
  • Hand-in the completed data sheets and your program printout for credit.

 

 

.global   DO_Logic

DO_Logic:            nop

mov.w  #0x2020,  R4                       ;Addition

mov.w  #0x5555,   R6

and.w    #0xAAAA,  R6

mov.w  R6,  0(R4)

BP1:                       mov.w   #0xFFFF, R6

and.w   #0x8111, R6

mov.w  R6,     2(R4)

BP2:                       and.w   #0x00FF, R6

mov.w  R6,  4(R4)

BP3:                       nop

mov.w  #0x5555,  R6                       ;exclusive-OR XOR

xor.w    # 0xAAAA,  R6

mov.w  R6,     8(R4)

BP4:                       mov.b   #0xA5,  R6

xor.b     #0xAA,                 R6

mov.b   R6,  10(R4)

BP5:                       nop

mov.w  #0x2030, R4                        ; Bit Set (OR)

mov.w  #0x0000, R6

bis.w     #0x02,  R6

mov.w  R6, 0(R4)

BP6:                       mov.w  #0x55,   R6

bis.b      #0xAA,  R6

mov.b   R6,  2(R4)

BP7:                       nop                                       

mov.w  #0xFFFF, R6                        ;Bit Clear

bic.w     #0x0008,  R6

mov.w  R6, 4(R4)

BP8:                       mov.b   #0xF5,   R6

bic.b      #0x04,  R6

mov.b   R6,  6(R4)

BP9:                       nop       

mov.w  #0x0055,   R6                      ;Rotate

clrc

rrc           R6

clrc

rrc           R6

mov.w  R6,  8(R4)

BP10:                     mov       # 0xB987, R6

rla           R6

rla           R6

rla           R6

rla           R6

mov.w   R6,   10(R4)

B11:                       nop

                                reta

 

 

 

 

 

 

 

 

 

Table 1  ADD

BP R6 (0x2020) (0x2022) (0x2024) (0x2026) N Z
1     ——- ——- ——-    
2       ——- ——-    
3         ——-    
          ——-    

 

 

 

Table 2  XOR

BP R6 (0x2028) (0x202A) N Z
4     ——-    
5          

 

 

 

Table 3  BIS

BP R6 (0x2030) (0x2032) N Z
6     ——-    
7          

 

Table 4  BIC

BP R6 (0x2034) (0x2036) N Z
8     ——-    
9          

 

 

 

Table 5  Rotate

BP R6 (0x2038) (0x203A) N Z C
10     —-      
11            

 

 

 

The left rotate instruction shifts all bits in the register or memory operand specified. The most significant bit is rotated to the carry flag, the carry flag is rotated to the least significant bit position, all other bits are shifted to the left. The result does not include the original value of the carry flag.

 

The first operand value indicates how many times the rotate takes place. The value is either the contents of the CL register or an immediate number. For a single rotate, where the first operand is one, the overflow flag (OF) is defined. For all other cases, OF is undefined. After the shift, the carry flag bit is XORed with the most significant result bit.

 

The right rotate instruction shifts all bits in the register or memory operand specified. The carry flag (CF) is included in the rotation. The least significant bit is rotated to the carry flag, the carry flag is rotated to the most significant bit position, all other bits are shifted to the right. The result includes the original value of the carry flag.

 

The first operand value indicates how many times the rotate takes place. The value is either the contents of the CL register or an immediate number. For a single rotate, where the first operand is one, the overflow flag (OF) is defined. For all other cases, OF is undefined. After the shift, the carry flag bit is XORed with the two most significant result bits.

 

 

The right rotate instruction shifts all bits in the register or memory operand specified. The least significant bit is rotated to the carry flag, the carry flag is rotated to the most significant bit position, all other bits are shifted to the right. The result does not include the original value of the carry flag. The first operand value indicates how many times the rotate takes place. The value is either the contents of the CL register or an immediate number. For a single rotate, where the first operand is one, the overflow flag (OF) is defined. For all other cases, OF is undefined. After the shift, the carry flag bit is XORed with the two most significant result

Homework Writing Bay
Calculator

Calculate the price of your paper

Total price:$26
Our features

We've got everything to become your favourite writing service

Need a better grade?
We've got you covered.

Order your paper