The sign of the number in the control byte identifies whether the byte or bytes that follow represent a literal pattern or byte to be repeated. A positive number (1 to 127) indicates that the bytes are literal. A negative number
As mentioned, for a byte to be repeated, the control byte must be a negative value as represented by the twos complement. For example, to repeat a pattern three times would require the twos complement of the number 3. The twos complement is computed as follows. The binary of 3 is 00000011. Complement each bit to get 11111100, then add one to this value to produce 11111101, the twos complement. The decimal value of this number, 253, used in the control byte, produces a repetition of 3 bytes for a total of 4 occurrences of the pattern.
The range of numbers for the control byte is shown below.
Literal Pattern Values |
|
| |
# of Bytes | Binary value | Decimal value | |
| 1 | 0000 0000 | 1 |
| to | to | to |
127 | 0111 1111 | 127 | |
No Operation Value |
|
| |
NOP value | Binary value | Decimal value | |
128 | 1000 0000 | 128 | |
Repeated Pattern |
|
| |
Values |
|
| |
# of Repetitions | Binary value* | Decimal value | |
1 | 1111 1111 | 255 | |
| to | to | to |
127 | 1000 0001 | 129 |
*These negative values are represented by taking the twos complement of the value of the number.
EN |