SourcePoint AMD Help

Table of Contents

bits

Access the contents of a bit-field within a register, MSR or debug variable.

Syntax

[[px]] bits(component, bit-offset, bit-size) [= expr]

Where:

[px]

is the viewpoint override, including punctuation ( [ ] ), specifying that the viewpoint is temporarily set to processor x of the boundary scan chain. ย The processor can be specified as px (where x is the processor ID), or an alias you have defined for a given processor ID. ย ALL cannot be used as a viewpoint override

component

is a valid register name or debug variable.

bit-offset

is a valid expression yielding the bit index where the bit field begins. This value must be less than the size of the component specified.

bit-size

is a valid expression yielding the size, in bits, of the bit field. This value must be less than the size of the component specified minus the bit offset.

expr

is a valid numeric expression which is to be assigned to the bit field. This expression, if it results in a value greater than possible in the bit field, will be truncated to the bit-size during assignment.

Discussion

Use the bits function to access the contents of a bit-field within a register, MSR or debug variable. ย Use bits and #define together to define virtual registers or register components.

Example 1

To access bit 5 of register EAX:

Command input:

bits(eax, 5, 1)

Result:

1

Example 2

To clear bit 5 of register EAX:

Command input:

bits(eax, 5, 1) = 0

Example 3

To define a debug alias for bit 5 within the EAX register:

Command input:

#define magic_bit bits(eax, 5, 1)

magic_bit ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย /*output which follows assumes bit was clear*/

Result:

0

Command input:

magic_bit = 0xffff ย ย ย ย ย ย ย ย ย ย ย ย /*value truncated to bit 0*/

magic_bit

Result:

1

Example 4

To define a virtual register mapped to the upper 16 bits of EAX:

Command input:

#define myReg ย bits(eax, 16t, 16t)

eax = 0

myReg = 1234

eax

Result:

12340000H

Example 5

To modify the upper 4 bits of a debug variable:

Command input:

define ord4 myData = 0

bits(myData, 28t, 4) = 4

myData

Result:

40000000H