• Keine Ergebnisse gefunden

Byte Manipulation2”

Im Dokument UPDATE NOTICE (Seite 143-149)

User Operations

2.11 Byte Manipulation2”

This set of six instructions allows the programmer to pack or unpack bytes of any length anywhere within a word. Movement of a byte is always be- tween AC and a memory location: a deposit instruction takes a byte from the right end of AC and inserts it at any desired position in the memory location; a load instruction takes a byte from any position in the memory location and places it right justified in AC.

The byte manipulation instructions have the standard memory refer- ence format, but the effective address E is used to retrieve a pointer, which is used in turn to locate the byte or the place that will receive it. A pointer restricted only to local addressing is always one word and has the format

P s lO]ll x 1 Y

0 56 II I2 13 14 I7 111 3s

where S is the size of the byte as a number of bits (with zero S specifying a null byte), and P is its position as the number of bits remaining at the right of the byte in the word (e.g. ifP is 3 the rightmost bit of the byte is bit 32 of the word). The rest of the pointer is interpreted in the same way as in an instruction: I, X and Y are used to calculate the address of the location that is the source or destination of the byte; the address calculation begins in the section containing the pointer,

In section 0 the pointer is always of the above type - local and one word - and P must be < 36. In a nonzero section the pointer can be local in the above format, but it can also be global in either a one or two-word

28 In a KAlO without byte manipulation hardware, all of the instructions presented in this section are trapped as unassigned codes.

June 1982 User Operations 2-85

format. The one-word global pointer is available only with TOPS-20 micro- code version 271 or greater, cannot use indirection, and provides for only

the most common byte sizes via this format: -

P&S

I

30-BIT ADDRESS

0 5 6 35

where the address can point to any section, and the left six bits specify both byte position and size by a number > 36 as follows.

P&S P S P&S P

s

37 36 6 49 36 7

38 30 6 50 29 7

39 24 6 51 22 7

40 28 6 52 15 7

41 12 6 53 8 7

42 6 6 54 1 7

43 0 6

55 36 9

44 36 8 56 27 9

45 28 8 57 18 9

46 20 8 58 9 9

47 12 8 59 0 9

48 4 8

60 36 18

61 18 18

62 0 18

For unrestricted use in a nonzero section, the pointer can be a doubleword in location E_E+ 1 with this format:

P s 1 RESERVED AVAILABLE TO USER

O]Il x Y

0 1 2 5 6 11 12 13 17 I8 35 I

which allows unlimited pointing, as P and S are independent, and the second word can be local or global, direct or indirect (see the discussion of indirect words in 31.6). The processor determines the number of words in a pointer with independent P and S by the state of bit 12 in the first word (in section 0 bit 12 is ignored and should be 0). Any type of pointer aims at a word whose format is

I 0

P BITS

I

35-p-s+ I 35-P 35-p+ I 35

where the shaded area is the byte.

Bytes are always contiguous within a word, and the forward order is left to right in words and from low to high addresses. The position of the byte area in a word is called the “byte alignment.” Let P be the position of a specified byte; 36 - P is then the number of bits in the left part of the word including the given byte and all byte positions at the left of it. Dividing

User Operations June 1982

36 - P

by S gives the number of byte positions in this left part, and the calculation is complete, the incremented X is used when the instruction is repeated.

June 1982 User Operations 2437

LDB Load Byte

I 135 1 A 111 X 1 Y I

0 a9 I2 1314 I1 I.8 35

Retrieve a byte of S bits from the location and position specified by the pointer at location E, load it into the right end of AC, and clear the remain- ing AC bits. The location containing the byte is unaffected, the original contents of AC are lost.

DPB Deposit Byte

I 137 A II X Y I

0 89 I2 I3 14 1718 35

Deposit the right S bits of AC into the location and position specified by the pointer at location E. The original contents of the bits that receive the byte are lost, AC and the remaining bits of the deposit location are unaffected.

IBP Increment Byte Pointer

133 1 00 ]I1 X 1 Y Bits 9- 12 = 0.

0 89 12 1314 1718 35

Increment the byte pointer at location E, setting the byte alignment to zero if the incrementing crosses a word boundary, as explained above.

Notes. Giving this instruction code with bits 9-12 nonzero produces the ADJBP instruction described at the end of the section. In the KIlO and KAlO, only the IBP form is available and bits 9-12 are ignored (but should be zero).

ILDB Increment Pointer and Load Byte

I u

134 I39 A 12 1314 I X 1718 Y 3s

1

Increment the byte pointer at location E, setting the byte alignment to zero if the incrementing crosses a word boundary, as explained above. Then retrieve a byte of S bits from the location and position specified by the newly incremented pointer, load it into the right end of AC, and clear the remaining AC bits. The location containing the byte is unaffected, the orig- inal contents of AC are lost.

-

User Operations June 1982

IDPB Increment Pointer and Deposit Byte

/

\

Increment the byte pointer at location E, setting the byte alignment to zero if the incrementing crosses a word boundary, as explained above. Then deposit the right S bits

of

AC into the location and position specified by the newly incremented pointer. The original contents of the bits that receive the byte are lost, AC and the remaining bits of the deposit location are unaffected.

Note that in the pair of instructions that both increment the pointer and process a byte, it is the modified pointer that determines the byte location and position. Hence to unpack bytes from a block of memory, the program should set up the pointer to point to a byte just before the first desired, and then load them with a loop containing an ILDB. If the first byte is at the left end of a word, this is most easily done by initializing the pointer with a P of 36 (448). Incrementing then replaces the 36 with 36 - S to point to the first byte. For the convenience of the programmer, MACRO has a pseudoinstruction for setting up such a pointer: in assembly

POINT S,Y

is replaced by a pointer that points to a byte of size S at position 36 in location Y. At any time that the program might inspect the pointer during execution of a series of ILDBs or IDPBs, it points to the last byte processed (this may not be true when the pointer is tested from an interrupt routine).

ADJBP Adjust Byte Pointer

I 133 A / x Y A f 0.

0 n9 12 1314 I7 IX 3s

Take one of these three courses of action depending on the value of S in the pointer at location E.

If S is 0, place an unmodified copy of the pointer in AC or AC,AC + 1.

If S is greater than 36 minus the byte alignment given by the pointer - so not even one byte will fit in a word - set Trap 1, Overflow and No Divide, and go on to the next instruction without affecting the ACs or memory.

If S is greater than 0 but less than 36 minus the byte alignment, make a copy of the pointer from location E or E,E+ 1, and “adjust” the copy, forward or back, by the number of byte positions specified by AC, pre- serving the byte alignment across wprd boundaries: if AC contains a posi- tive number N, adjust the copy by N bytes forward; if AC contains a

June 1982 User Operations 2-89

negative number -N, adjust the copy by N bytes back. Place the revised pointer copy in AC or AC,AC + 1 as appropriate. The original pointer is unaffected; the original contents of AC or AC,AC + 1 are lost.

Notes. The adjustment always produces a pointer that specifies an actual byte; e.g. adjusting a pointer with a P of 36 by zero bytes results in a pointer that specifies the rightmost byte in the preceding word. Note that if the pointer specifies a byte alignment of zero, there is no difference between

“adjusting” it by N and “incrementing” it N times (except that the latter actually modifies the pointer). Since the result goes to AC, it is not gener- ally useful to adjust a local pointer that is in a different section from the instruction.

Giving this instruction code with a zero A field or in a KIlO or KAlO produces the IBP instruction described above. Note that if S = 0, this instruction is equivalent to MOVE.

This last instruction facilitates selection of individual bytes at arbi- trary positions in an array whose format differs from the linear format used by the incrementing instructions in that’the adjustment preserves the byte alignment across word boundaries. As an example of this format, let us again use &-bit bytes where the pointer specifies one in the same position as byte 0 in our linear example at the beginning of the section. Such an array would look like this.

. . .

Y-2 3 BYTE -10 BYTE -9 BYTE -8 BYTE -7 1

Y-l 3 BYTE -6 BYTE -5 BYTE -4 BYTE -3 1

Y 3 BYTE -2 BYTE -I BYTE 0 BYTE I 1

Y+1 3 BYTE 2 BYTE 3 BYTE 4 BYTE 5 I

Y+2 3 BYTE 6 BYTE 7 BYTE 8 BYTE 9 I

Here the bytes are ordered in either direction from the zero position, and the byte alignment determined by the pointer is preserved throughout all words in the block. Bytes are packed as many as will fit in all words (except perhaps at either end of the block), but within the restriction that the alignment be preserved. For example, with lo-bit bytes there are always three per interior word in the linear format, but in the array format with an alignment of 8, there are only two, occupying bits 8-17 and 18-27.

Specification of an arbitrary byte anywhere in the array is accomplished by using an ADJBP. The microcode makes the adjustment by changing Y to the location containing the byte and then setting up a new P for the specific byte.

Suppose we have bytes packed five to a word, a pointer at location E now points to the third byte in a given location, and we wish to retrieve the thirty-first (the fourth byte from the sixth location) beyond that. This rou- tine loads the desired byte into AC.

z-90 User Operations June 1982

MOVE1 AC,37

ADJBP AC,E ;Adjust by 31io

LDB AC,AC

Im Dokument UPDATE NOTICE (Seite 143-149)