05.02.2013 Views

ARM Architecture Reference Manual ARMv7-A and ARMv7-R edition

ARM Architecture Reference Manual ARMv7-A and ARMv7-R edition

ARM Architecture Reference Manual ARMv7-A and ARMv7-R edition

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Pseudocode Definition<br />

I.5.3 Bitstring manipulation<br />

The following bitstring manipulation functions are defined:<br />

Bitstring length <strong>and</strong> most significant bit<br />

If x is a bitstring, the bitstring length function Len(x) returns its length as an integer, <strong>and</strong> TopBit(x) is the<br />

leftmost bit of x (= x using bitstring extraction).<br />

Bitstring concatenation <strong>and</strong> replication<br />

If x <strong>and</strong> y are bitstrings of lengths N <strong>and</strong> M respectively, then x:y is the bitstring of length N+M constructed by<br />

concatenating x <strong>and</strong> y in left-to-right order.<br />

If x is a bitstring <strong>and</strong> n is an integer with n > 0, Replicate(x,n) is the bitstring of length n*Len(x) consisting<br />

of n copies of x concatenated together, <strong>and</strong> Zeros(n) = Replicate(’0’,n), Ones(n) = Replicate(’1’,n).<br />

Bitstring extraction<br />

The bitstring extraction operator extracts a bitstring from either another bitstring or an integer. Its syntax is<br />

x, where x is the integer or bitstring being extracted from, <strong>and</strong> is a list of<br />

integers enclosed in angle brackets rather than the usual parentheses. The length of the resulting bitstring is<br />

equal to the number of integers in . In x, each of the integers in <br />

must be:<br />

>= 0<br />

< Len(x) if x is a bitstring.<br />

The definition of x depends on whether integer_list contains more than one integer. If it<br />

does, x is defined to be the concatenation:<br />

x : x : x : ... : x<br />

If integer_list consists of just one integer i, x is defined to be:<br />

if x is a bitstring, '0' if bit i of x is a zero <strong>and</strong> '1' if bit i of x is a one.<br />

if x is an integer, let y be the unique integer in the range 0 to 2^(i+1)-1 that is congruent to x modulo<br />

2^(i+1). Then x is '0' if y < 2^i <strong>and</strong> '1' if y >= 2^i.<br />

Loosely, this second definition treats an integer as equivalent to a sufficiently long two’s complement<br />

representation of it as a bitstring.<br />

In , the notation i:j with i >= j is shorth<strong>and</strong> for the integers in order from i down to j, both<br />

ends inclusive. For example, instr is shorth<strong>and</strong> for instr.<br />

The expression x is assignable provided x is an assignable bitstring <strong>and</strong> no integer appears<br />

more than once in . In particular, x is assignable if x is an assignable bitstring <strong>and</strong> 0

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!