Skip to Main Content Skip to Search
Product Documentation

regread - Values from processor registers

Syntax

reg=IDE_Obj.regread('regname','represent',timeout)
reg=IDE_Obj.regread('regname','represent')
reg=IDE_Obj.regread('regname')

IDEs

This function supports the following IDEs:

Description

reg=IDE_Obj.regread('regname','represent',timeout) reads the data value in the regname register of the target processor and returns the value in reg as a double-precision value. For convenience, regread converts each return value to the MATLAB double datatype. Making this conversion lets you manipulate the data in MATLAB. String regname specifies the name of the source register on the target. The IDE handle, IDE_Obj, defines the target to read from. Valid entries for regname depend on your target processor.

Register names are not case-sensitive — a0 is the same as A0.

For example, MPC5500 processors provide the following register names that are valid entries for regname.

Register NamesRegister Contents
'acc'Accumulator A register
sprg0 through sprg7SPR registers

For example, TMS320C6xxx processors provide the following register names that are valid entries for regname.

Register NamesRegister Contents

A0, A1, A2,..., A15

General purpose A registers

B0, B1, B2,..., B15

General purpose B registers

PC, ISTP, IFR, IRP, NRP, AMR, CSR

Other general purpose 32-bit registers

A1:A0, A2:A1,..., B15:B14

64-bit general purpose register pairs

The represent input argument defines the format of the data stored in regname. Input argument represent takes one of three input strings.

represent StringDescription

'2scomp'

Source register contains a signed integer value in two's complement format. This is the default setting when you omit the represent argument.

'binary'

Source register contains an unsigned binary integer.

'ieee'

Source register contains a floating point 32-bit or 64-bit value in IEEE floating-point format. Use this only when you are reading from 32 and 64 bit registers on the target.

To limit the time that regread spends transferring data from the target processor, the optional argument timeout tells the data transfer process to stop after timeout seconds. timeout is defined as the number of seconds allowed to complete the read operation. You might find this useful for limiting prolonged data transfer operations. If you omit the timeout argument, regread defaults to the global time-out defined in IDE_Obj.

reg = IDE_Obj.regread('regname','represent') does not set the global time-out value. The time-out value in IDE_Obj applies.

reg = IDE_Obj.regread('regname') does not define the format of the data in regname.

Reading and Writing Register Values

Register variables can be difficult to read and write because the registers which hold their value are not dedicated to storing just the variable values.

Registers are used as temporary storage locations at any time during execution. When this temporary storage process occurs, the value of the variable is temporarily stored somewhere on the stack and returned later. Therefore, getting the values of register variables during program execution may return unexpected answers.

Values that you write to register variables and local variables during intermediate times in program operation may not get reflected in the register.

To see if the result is consisten, write a line of code that uses the variable. For example:

register int a = 100;
int b;
 ...
b = a + 2;

Reading the register assigned to a may return an incorrect value for a but if b returns the expected 102 result, nothing is wrong with the code or the software.

Examples

For MULTI IDE

For the MPC5554 processor, most registers are memory-mapped and consequently are available using read and write. However, use regread to read the PC register. The following command demonstrates how to read the PC register. To identify the target, IDE_Obj is the IDE handle.

IDE_Obj.regread('PC','binary')

To tell MATLAB what data type you are reading, the string binary indicates that the PC register contains a value stored as an unsigned binary integer.

In response, MATLAB displays

ans =

       33824

For processors in the Blackfin family, regread lets you access processor registers directly. To read the value in general purpose register cycles, type the following function.

treg = IDE_Obj.regread('cycles','2scomp');

treg now contains the two's complement representation of the value in A0.

For CCS IDE

For the C5xxx processor family, most registers are memory-mapped and consequently are available using read and write. However, use regread to read the PC register. The following command demonstrates how to read the PC register. To identify the processor, IDE_Obj is a link for CCS IDE.

IDE_Obj.regread('PC','binary')

To tell MATLAB software what datatype you are reading, the string binary indicates that the PC register contains a value stored as an unsigned binary integer.

In response, MATLAB software displays

ans =

       33824

For processors in the C6xxx family, regread lets you access processor registers directly. To read the value in general purpose register A0, type the following function.

treg = IDE_Obj.regread('A0','2scomp');

treg now contains the two's complement representation of the value in A0.

Now read the value stored in register B2 as an unsigned binary integer, by typing

IDE_Obj.regread('B2','binary');

See Also

read | regwrite | write

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS