o g r a m m i n ga n d H a r d u a r e
Interfacing:
Progr
that a string ofbytes to
3.8 roprocessor and indicale
is used
used to
t indicate
specifically m n e m o n i c
is
to the
is used "W" in
Multiply signed byte by byte signed
IMUL or A acted upon.
to be
upon.
be acted words is
word by word. of An instruction prefix,
that a string
AAM ASCII adjust after multiplication. Repeat following
Division instructions: REP
instruction until
Divide unsigned word by byte
or
DIV
CX = 0.
unsigned double word by word. An instruction prefix.
IDIV Divide signed word by byte or signed
double word by word. REPE/REPZ Repeat instruction until
AAD ASCIl adjust before division. CX = 0 or zero flag ZF
CBW ill upper byte of word with copies of
1.
sign bit of lower byte. An instruction prefix.
CWD ill upper word of double word with REPNE/REPNZ Repeat until CX = 0 or
sign bit of lower word.
ZF = 1.
BIT MANIPULATION INSTRUCTIONS Move byte or word from
MOVS/MOVSB/MOVSW
one string to another.
Logical instructions:
COMPS/COMPSB/COMPSW
Compare two string bytes
NOT Invert each bit of a byte or word. or two string words.
AND AND each bit in a byte or word with
the corresponding bit in another INS/INSB/INSW (80186/80188) 1nput
byte string byte or word
or word.
OR OR each bit in a from pot
byte or word with the
corresponding bit in another byte or OUTS/OUTSB/OUTSW (80186/80188) Output
word. string byte or word to
XOR Exclusive OR each bit in a byte or port.
word with the SCAS/SCASB/SCASW Scan a string. Compare a
corresponding bit in
another byte or word.
TEST string byte with a byte
AND operands to
update flags, but
don't change operands.
in AL or a string word
Shift instructions with a word in AX.
SHL/SAL Shift bits of word or
LODS/LODSB/LODSVw Load string byte into AL
byte left, put zerols)
SHR
in LSB(s).
STOS/STOSB/STOSWv
or
string word into AX.
Shift bits of word or Store byte from AL or
zerols) in MSB(s).
byte right, put
word from AX into
SAR Shift bits of word or
byte right, copy
old MSB into new MSB.
string.
Rotate istructions PROGRAM EXECUTION TRANSFER
ROL Rotate bits of byte or word
left, MSB
INSTRUCTIONS
to LSB and to CF. These instructions are
ROR used to tell the
Rotate bits of byte or word
to MSB and to CF. right, LSB instructions from some new
8086 to start
fetching
RCL continuing in sequence. address, rather
Rotate bits of byte or word
Unconditional transfer instructions: than
to CF and CF to
left, MSB
RCR LSB. CALL
Rotate bits of byte or word Call a
to CF and CF to
MSB.
right, LSB procedure (subprogram), save
RET return
STRING INSTRUCTIONS
address
Return from on
stack.
A string is a series of bytes
JMP
Goprogram.
procedure to calling
sequential memory locations. A stringseries
or a
of words in to
ASCII character codes. In the list, a often consists of Conditional iransfer specified address to
instructions:
instructioon.
"/" is used to A/ is get next
different mnemonics for the same separate used to
mnemonic which most clearly describes instruction. Use the thesame separate two
instruction.
the instruction in a the
specific application. A "B" in afunction of
mnemonics which
describes the decisionUse the mnemonic
mnemonic These
instructions condition which mostrepresent
nt
instruction. are in a clearly
below and used specific
The terms often
after program.
above refer toa compare
unsigned
nteceul
Rounite
ion
CS0s6Family Assenbly LanguageProgramming -Introxduction 3.9
binary numbers. Above means IS not clcar to you hecause we will explain these instruC
larger in magnitude. The
terms greater than or less tihan
refer to signed binary tions in detail in later chaplers.
numbers. Grater than means more
positive. Interrupt instructions:
JA/INBE Jump if above/Jump if not below or INT Interrupt program exerution, c all
equal. service procedure.
JAINB Jump if above or equal/Jump il not INTO Interrupt program exer ution if
below OF = 1
JB/INAE Jump if below/jumpif not above or IRET Return from interrupt service
equal procedure to main program.
JBE/INA Jump if below or equal/Jump if not High-level lunguage interface instructions:
above. ENTER (80186/80188 only) Enter pro-
Jump if carry flag CF = 1. cedure.
JE/Z Jump if equal/Jump if zero flag LEAVE (80186/80188 only) Leave pro-
ZF = 1. cedure.
JG/JNLE Jump if greater/jump if not less BOUNDD (80186/80188 only) Check if
than or equal. effective address within spec-
IGE/NL Jump if greater than or equal/ Junmp ified array bounds.
if not less than.
JL/JNGE Jump if less than/Jump if not PROCESSOR CONTROL INSTRUCTIONS
greater than or equal.
JLE/ING Jump if less than or equal/Jump if Flag settclear instructions:
not greater than. STC Set carry flag CF to 1.
JNC Jump if no carry (CF = 0). CLC Clear carry flag CF to 0.
INE/JNZ Jump if not equal/Jump if not CMC Complement the state of the carry
zero (ZF = 0). flag CF.
NO Jump if no overflow (overflow STD Set direction flag DF to 1 (decre-
flag OF = 0). ment string pointers).
INP/JPO Jump if not parity/Jump if parity CLD Clear direction flag DF to 0.
odd (PF = 0). STI Set interrupt enable flag to 1
JNS Jump if not sign (sign flag SF = 0). (enable INTR input).
JO Jump if overflow flag OF = 1. CLI Clear interrupt enable flag to 0
P/JPE Jump if parity//ump if parity even (disable lNTR input).
(PF 1). External hardware synchronization instructions:
JS Jump if sign (SF = 1) HLT Halt (do nothing) until interrupt or
Iteration control instructions: reset. Ha // h DAUJoR
These insttuctions can be used to execute a series of WAIT Wait (do nothing) until signal on
instructions some number of times. Here mnemonics the TEST pin is low.
cluruj lik
separated by a "/" represent the same instruction. Use the ESC Escape to external coprocessor
one that best fits the specific application. such as 8087 or 8089.
LOOP Loop through a sequence of
LOC An instruction prefix, Prevents
instructions until CX = 0. another processor from taking
LOOPE/LOOPZ Loop through a sequence of the bus while the, adjacente
instructions while ZF = 1 and 1nstruction exeútes" C
CX 0 . No operation instruction:
LOOPNE/LOOPNZ Loop through a sequence of NOP No action except fetch and
instructions while ZF = 0 and decode.
CX 0 . Now that you have skimmed through an overview of the
JCXZ Jump to specified address if 8086 instruction set, let's see whether you found the
CX = 0.
instructions needed to implement the "read sensor, add
If you aren't tired of instructions, continue skimming +7. and store result in memory" example program. The
through the rest of the list. Don't wory if the explanation IN instruction can be used to read the temperature value