8 string instructions – Texas Instruments MSP50C6xx User Manual

Page 141

Advertising
background image

String Instructions

4-55

Assembly Language Instructions

4.8

String Instructions

Class 1, 2, 3, and 6 instructions can have string modes. During the execution
of string instruction, STR register value plus 2 is assumed as string length. An
accumulator string is a group of consecutive accumulators spanning from An
to the next N consecutive accumulators (N

is the length of the string). The STR

register should be loaded with N–2 to define a string length, N. A value of zero
in the STR register defines a string length of 2 (string length 1 means the
instruction is not in string mode). Arithmetic string instructions treat the string
as an N word arithmetic value. The result is also an arithmetic value of the
same length. Conditionals are set as they would be set without string mode.
Comparing two strings is equivalent to comparing each bit of the string. The
accumulator status is modified representing the outcome of the entire
operation. Examine the following examples.

Table 4–43. Initial Processor State for String Instructions

Registers (register# = value)

AP0 = 2

AP1 = 21 (0x15)

AP2 = 11 (0x0B)

AP3 = 29 (0x1D)

AC0 =

AC1 =

AC2 =

AC3 =

AC4 =

AC5 =

AC6 =

AC7 =

AC8 =

AC9 =

AC10 =

AC11 = 0xAAAA

AC12 = 0xAAAA

AC13 = 0xAAAA

AC14 = 0xAAAA

AC15 = 0xAAAA

AC16 =

AC17 =

AC18 =

AC19 =

AC20 =

AC21 = 0x1223

AC22 = 0xFBCA

AC23 = 0x233E

data memory (*address = data)

*0x0200 = 0x12AC

*0x0201 = 0xEE34

*0x0202 = 0x9086

*0x0203 = 0xCDE5

program memory (*address = data)

*0x1400 = 0x0123

*0x1401 = 0x4567

*0x1402 = 0x89AB

*0x1403 = 0xCDEF

*0x1404 = 0xFEDC

*0x1405 = 0xBA98

*0x1404 = 0x7654

*0x1405 = 0x3210

Example 4.8.1

MOV STR, 4–2; string length = 2

MOVS A0, 0x1400

Refer to initial the processor state in Table 4–43. A0 points to AC2. Consider
a program memory location string of length 4 at 0x1400 =
0xCDEF89AB45670123. STR equal to 4–2=2, defines a string length of 4.
Final result, AC2=0x0123, AC3=0x4567, AC4=0x89AB, and AC5=0xCDEF,

Example 4.8.2

MOV STR, 3–2; string length = 3

ADDS A1~, A1, *0x0200

Refer to the initial processor state in Table 4–43. A1 is AC21, A1~ is AC5, the

Advertising