Hardware Support on StarCore

2 Integer and Fractional Arithmetic Exercise

One of the strengths of both the StarCore architecture and the StarCore compiler is the ability to perform both fractional and integer arithmetic. This exercise presents a reminder about integer and fractional arithmetic representation and then shows how to use the StarCore compiler fractional intrinsics. Values stored in memory or registers are interpreted differently depending on the operation performed. For integers, the binary point is considered to be immediately to the right of the LSB. For the fractional case, the binary point is considered to be immediately to the right of the MSB. Table 1 illustrates this for 16-bit data values.

Table 1. Interpretation of 16-bit Integer and Fractional Data Values

Binary Representation

Hexadecimal

Integer Value

Fractional value

Representation

(decimal)

(decimal)

 

 

 

 

 

 

 

 

 

0100 0000 0000 0000

0x4000

16384

0.5

 

 

 

 

0001 0000 0000 0000

0x1000

4096

0.125

 

 

 

 

0000 0000 0000 0000

0x0000

0

0.0

 

 

 

 

1100 0000 0000 0000

0xC000

-16384

-0.5

 

 

 

 

1111 0000 0000 0000

0xF000

-4096

-0.125

 

 

 

 

2.1 Hardware Support on StarCore

StarCore has a dual instruction set for operations that produce different results depending on whether fractional or integer arithmetic is used. The instruction set is complementary when an integer or a fractional operation leads to the same result, regardless of the operation type: for example, an addition.

The instruction set is dual (as shown in Table 2) in two cases, which automatically take care of data alignment, zero filling, and sign extension:

when an integer or a fractional operation leads to a different result depending on the operation type: for example, a multiplication.

when data is transferred from/to memory.

Table 2. Fractional and Integer Assembly Language Instructions

Operation

Integer

Fractional

 

 

 

 

 

 

Multiply

impy

mpy

 

 

 

Multiply accumulate

imac

mac

 

 

 

Move

move.b, move.w,

move.f, move.2f, move.4f

 

move.2w, move.4w

 

 

 

 

Introduction to the SC140 Tools

5

Page 5
Image 5
Motorola SC140 Integer and Fractional Arithmetic Exercise, Interpretation of 16-bit Integer and Fractional Data Values