Instruction Set
4-212
SAL
SAL
Operation It Performs
Flag Settings After Instruction
If
count=0, flags are unaffected. Otherwise, flags are affected as shown below:
Examples
This example multiplies a 16-bit integer in memory by 8.
This example multiplies an 8-bit unsigned number in AL by 16.
while (i =
count; i != 0; i--)
/* perform shifts */
{
/* store highest bit in carry flag */
CF = mostSignificantBit(
component);
/* shift left and fill vacancy with 0 */
component = component << 1;
}
if (count == 1)
/* single shift */
if (mostSignificantBit(
component) != CF)
/* set overflow flag */
OF = 1;
else
/* clear overflow flag */
OF = 0;
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
0
Processor Status
Flags Register
reserved
OF DF
IF TF SF ZF
AF
PF
CF
? = undefined; – = unchanged
Undefined unless single-bit shift, then:
OF=1 if result larger than destination operand
OF=0 otherwise
?
–
–
–
res ? res
res 0
SF=1 if result is 0 or positive
SF=0 if result is negative
ZF=1 if result equal to 0
ZF=0 if result not equal to 0
PF=1 if low byte of result has even number of set bits
PF=0 otherwise
CF=0 unless shift lengths are less than or
equal to the size of the shifted operand,
then:
CF=1 for carry or borrow to high-order bit
CF=0 otherwise
POWER2
EQU
3
; multiply by 8
INTEGER
DW
-360
; FE98h
; signed multiplication by 8: INTEGER = INTEGER * pow(2,POWER2)
SAL
INTEGER,POWER2
; INTEGER = F4C0h = -2880
POWER2
EQU
4
; multiply by 16
UNUMBER
DB
10
; 0Ah
; unsigned multiplication by 16: AL = AL * pow(2,POWER2)
MOV
AL,UNUMBER
; AL = 0Ah = 10
SHL
AL,POWER2
; AL = A0h = 160
Содержание Am186 Series
Страница 1: ...Am186 and Am188 Family Instruction Set Manual February 1997...
Страница 10: ...Table of Contents x...
Страница 18: ...Programming 1 8...
Страница 40: ...Instruction Set Listing 3 14...