Professional Documents
Culture Documents
Main unprivileged
commands
Data transfer
Command: MOV receiver, source
Purpose: Data transfer
Command: PUSHA
PUSHAD
Purpose: Place all registers of general purpose in a
stack
Command: POPA
POPAD
Purpose: Load all registers of general purpose from a
stack
Command: CWD
Purpose: Word converting in the double word
Command: CDQ
Purpose: Double word converting in the quadruple word
Command: CBW
Purpose: Byte converting in the word
Command: CWDE
Purpose: Word converting in the double word
Lecture 2-3. Main unprivileged
commands
Command: DAS
If this command is executed right after SUB (SBB or DEC) and in the register AL there is a
difference of two packed binary-decimal numbers, as a result in AL the packed binary-
decimal number which had to be result of subtraction registers. For example, if AL contains
number 20h, sequence of commands
dec al
das
will lead to that in AL will appear 19h (instead of 1Fh as would be after DEC).
Lecture 2-3. Main unprivileged
commands
Command: AAA
Purpose: Correction after addition
Corrects the sum of two unpacked binary-decimal numbers of AL. If correction leads to decimal
carryover, AN increases on 1. This command makes sense right after command of addition of two such
numbers. For example, if at addition 05 and 06 in AX there is a number 000Bh, command AAA will
correct it in 0101h (unpacked decimal 11). Flags of CF and OF are set in 1 if there was a carryover from
AL in AH, differently they are equal to zero. Values of flags of OF, SF, ZF and PF aren't defined.
Command: AAS
Purpose: Correction after subtraction
Corrects a difference of two unpacked binary-decimal numbers in AL right after the SUB or SBB
command. If correction leads to borrow, AH decreases on 1. Flags of CF and OF are set in 1 if there was
borrow from AL in AH, and in zero — otherwise. Values of flags of OF, SF, ZF and PF aren't defined.
Lecture 2-3. Main unprivileged
commands
Command: AAM
Purpose: Correction after multiplication
Corrects result of multiplication of the unpacked binary-decimal numbers, being in AX after execution of
the command of MUL, transforming the received result to couple of unpacked binary-decimal numbers
(in AH and AL). For example:
mov al,5
mov bl,5 ; multiple 5 by 5
mul bl ; result in АХ - 0019h
aam ; now АХ contains 0205h
Command: AAD
Purpose: Correction before division
Executes correction of the unpacked binary-decimal number being in the register AX so that the
subsequent division led to correct decimal result. For example, we will divide decimal 25 on 5:
mov ax,0205h ; 25 in unpacked format
mov bl,5
aad ; now АХ contains 19h
div bl ; АХ = 0005
Lecture 2-3. Main unprivileged
commands
Logical operations
Command: AND receiver, source
Purpose: Logical AND
Shift operations
Command: SAR receiver, counter
Purpose: Arithmetic right shift