版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
Chapter
6
Program
Control
Instruction1¨
Direct
the
flow
of
a
program
and
allow
the
flow
tchange¨
Jumps,
calls,
returns,
interrupts,
and
machinecontrol
instructions¨
.If,
.ELSE,
.ELSEIF,
.ENDIF,
.WHILE,
.ENDW,REPEAT,
and
.UNTIL
relational
assemblylanguage¨
MASM
6.*
and
TASM
5.*The
Jump
Group2¨
JMP
instruction
allows
the
programmer
to
skipsections
of
a
program
and
branch
to
any
of
thememory
for
the
next
instruction¨
A
conditional
jump
instruction
allows
theprogrammer
to
make
decisions
baseduponnumerical
tests.¨
The
results
of
numerical
tests
are
held
in
the
fbits,
which
are
then
tested
by
conditional
jumpinstructions¨
The
conditional
setJMP
(Unconditional
Jump)3¨
Short
jump,
near
jump,
and
far
jump¨
Short
jump:
a
two-byte
instruction
that
allowsjumps
or
branches
to
memory
location
within
+12and
–128
bytes
from
the
address
following
thejump¨
Near
jump:
a
three-byte
instruction
that
allowjumps
or
branches
to
memory
location
within
+/-32K
bytes
from
the
address
following
the
jump,
oanywhere
in
the
current
real
mode
code
segment¨
Short
jump,
near
jump,
and
far
jump¨
In
the
80386
and
above
processors,
the
displaceis32
bits
and
the
Near
jump
is
five
bytes
long¨
In
the
80386
and
above
processors,
the
protectemode
code
segment
can
be
4G
bytes
long,
so
the
32bit
displacement
allows
a
near
jump
to
any
locatwithin
+/-2G
bytes4JMP
(Unconditional
Jump)JMP
(Unconditional
Jump)5¨
Short
jump,
near
jump,
and
far
jump¨
Far
jump:
a
five-byte
instruction
that
allows
jto
any
memory
location
within
the
real
memorysystem¨
A
new
segment
and
offset
address
is
obtained
toaccomplish
the
jump¨
If
the
microprocessor
(80286
through
Pentium
4operated
in
the
protected
mode,
the
segmentaddress
accesses
a
descriptor
that
contains
theaddress
and
the
offset
location
within
the
new
csegmentJMP
(Unconditional
Jump)6¨
Short
jump,
near
jump,
and
far
jump¨
The
short
and
near
jumps
are
often
calledintrasegment
jumps,
and
the
far
jumps
are
oftencalled
intersegment
jumps78¨
Example
1¨
Show
how
short
jump
instructions
passcontrol
from
one
section
of
the
program
toanother
andillustrate
the
use
of
a
label
(asymbolic
name
for
a
memory
address)910¨
Example
211¨
Develop
a
same
basic
program
as
the
example
1,except
that
the
jump
distance
is
greater¨
Notice
that
the
letter
R
denotes
a
relocatable
jaddress
of
0200H¨
The
relocatable
address
of
0200H
is
for
theassembler
program’s
internal
use
only¨
The
actual
machine
language
instruction
assembas
an
E9
F6
01,
which
does
not
appear
in
theassembler
listing¨
The
actual
displacement
is
a
01F6H
for
this
jumpinstruction1213¨
Example
314¨
The
far
jump
instruction
sometimes
appears
witthe
FAR
PTR
directives¨
Another
way
to
obtain
a
farjump
is
to
define
alabel
as
a
far
label¨
In
this
example,
the
label
UP
is
defined
as
a
farlabel
by
the
EXTRN
UP:
FAR
directive¨
When
the
program
files
are
jointed,
the
linkerinserts
the
address
for
the
UP
label
into
the
JMPUP
instruction.
It
also
inserts
address
in
the
JSTART
instruction15Jumps
with
Register
Operands16¨
The
jump
instruction
can
also
use
a
16-
or
32-biregister
as
an
operand.¨
This
automatically
sets
up
the
instruction
as
aindirect
jump¨
The
address
of
the
jump
is
in
the
register
specibythe
jump
instruction¨
Unlike
the
displacement
associated
with
the
nejump,
the
contents
of
the
register
are
transferdirectly
into
the
instruction
pointer¨
The
JUMP
AX
instruction,
for
example,
copies
thcontents
of
the
AX
register
into
the
IP
when
thejump
occurs¨
Example
4¨
Show
how
the
instruction
accesses
a
jump
table
ithe
code
segment¨
Read
a
key
from
the
keyboard
and
then
modifiesthe
ASCII
code
to
a
00H
in
AL
for
a
‘1’,
a
01Hfor
a
‘2’,
and
a
02H
for
a
‘3’¨
If
a
‘1’,
‘2’,
or
‘3’
is
typed,
AH
is
clearto
00H¨
Because
the
jump
table
contains
16-bit
offsetaddress,
the
contents
of
AX
are
doubled
to
0,
2,4,
so
a
16-bit
entry
in
the
table
can
be
accessed¨
Next,
the
offset
address
of
the
start
of
the
jumtable
is
loaded
to
SI,
and
AX
is
added
toform
thereference
to
the
jump
address¨
The
MOV
AX,
[SI]
instruction
then
fetches
anaddress
from
the
jump
table,
so
the
JMP
AXinstruction
jumps
to
the
address
(ONE,
TWO,
or17¨
Example4
(continued)¨
THREE)
stored
in
the
jumptable181920Indirect
Jumps
Using
an
Index21¨
Example
5¨
Repeat
the
Example
4
using
JMP
TABLE
[SI]
insteaof
JMP
AX2223Conditional
Jumps
and
Conditional
Sets24¨
In
the
8086~80286
microprocessors,
conditionajumps
are
always
short
jumps,
within
the
jumpinrange
between
+127
and
–128
bytes¨
In
the
80386
and
above,
conditional
jumps
areeither
short
or
near
jumps
which
allows
to
jump
tany
location
within
the
current
code
segment25¨
Notes26¨
The
conditional
jump
instructions
test
the
flasign
(S),
zero
(Z),
carry
(C),
parity
(P),
andoverflow
(O)¨
An
FFH
(255)
is
above
the
00H
in
the
set
ofunsigned
numbers,
but
an
FFH
(-1)
is
less
than
00for
signed
numbers¨
When
signed
numbers
are
compared,
use
the
JG,JL,
JGE,
JE
and
JNE
instructions¨
When
unsigned
numbers
are
compared,
use
the
JA,JB,
JAE,
JBE,
JE,
and
JNE
instructions27¨
Example
6¨
Use
JCXZ
conditional
jumps
instruction
to
searctable
for
a
0AH2829The
Conditional
SET
Instructions30¨
In
the
80386
and
above,
the
conditional
setinstructions
set
a
byte
to
either
a
01H
or
clearbyte
to
00H,
depending
on
the
outcome
of
thecondition
under
test¨
For
example,
the
SETNC
MEM
instruction
placesa
01H
into
memory
location
MEM
if
carry
iscleared,
and
a
00H
into
MEM
if
carry
is
set¨
The
contents
of
MEM
can
be
tested
at
a
later
poinin
the
program
to
determine
if
carry
is
cleared
athe
point
where
the
SETNC
MEM
instructionexecuted31LOOP32¨
Be
a
combination
of
a
decrement
CX
And
the
JNZconditional
jump¨
In
the
8086
through
the
80286
microprocessors,LOOP
decrements
CX;
if
CX<
>0,
it
jump
to
theaddress
indicated
by
the
label.
If
CX
becomes
a
0the
next
sequential
instruction
executes¨
In
the
80386
through
Pentium
4,
LOOPdecrements
either
CX
or
ECX¨
Example
7¨
Look
at
the
ExampleNo.
6-7
on
the
Page
No.
19233Conditional
Loops34¨
LOOPE
(loop
while
equal):jump
if
CX<
>
0
whilean
equal
condition
exists¨
LOOPNE
(loop
while
not
equal):
jump
if
CX<
>0while
an
not-equal
condition
existsControlling
the
flow
of
an
Assembly
language
Program35¨
.IF,
.ELSE,
.ELSEIF,
and
.ENDIFB¨
.REPEAT-.UNTIL,
and
.WHILE-.ENDW¨
These
statements
always
indicate
a
specialassembly
language
command
to
MASM6.*¨
Example
836¨
Look
at
theExample6-8
on
the
Page
193¨
Look
at
theExample6-9
on
the
Page
194¨
Look
at
the
Table
6-3¨
Look
at
theExample6-10
on
the
Page
195DO-WHILE
Loops37¨
Example
9¨
Look
at
theExample6-11
on
the
Page
196¨
Look
at
theExample6-12
on
the
Page
197¨
Look
at
theExample6-13
on
the
Page
198REPEAT-UNTIL
Loops38¨
Example
10¨
Look
at
theExample6-14
on
the
Page
199¨
Look
at
theExample6-15
on
the
Page
199Procedure39¨
The
procedure
or
subroutine
is
a
reusable
sectiof
the
software
that
is
stored
in
memory
once,
buused
as
often
as
necessary¨
The
CALL
instruction
links
to
the
procedure,
anthe
RET
(return)
instruction
returns
from
theprocedure¨
The
stack
stores
the
return
address
whenever
aprocedure
is
called
during
the
execution
of
aprogram¨
The
CALL
instruction
pushes
the
address
of
theinstruction
following
the
CALL
(return
address¨
the
stack¨
The
RET
instruction
removes
an
address
from
thestack
so
the
program
returns
to
the
instructionfollowing
the
CALL¨
A
procedure
begins
with
the
PROC
directive
andends
with
the
ENDP
directive¨
Each
directive
appears
with
the
name
of
theprocedure¨
The
procedure
directive
is
followed
by
the
typeprocedure:
NEAR
or
FAR¨
The
USES
statement
following
the
NEAR
or
FARallows
any
number
of
registers
to
be
automaticapushed
to
the
stack
and
popped
from
the
stackwithin
the
procedure40Procedure
(continued)the
Difference
Between
the
Near
and
the
Far
Procedures41¨
The
difference
in
the
RET
instruction:
the
nearreturn
instruction
uses
opcode
C3H,
and
the
farreturn
uses
opcode
CBH¨
A
near
return
removes
a
16-bit
number
from
thestack
and
places
it
into
the
instruction
pointereturn
from
the
procedure
in
the
current
codesegment¨
A
far
return
removes
a
32-bit
number
from
thestack
and
places
it
into
both
IP
and
CS
to
returnfrom
the
procedure
to
any
memory
location¨
Example
11¨
Look
at
theExample6-16
on
the
Page
20042CALL43¨
Transfer
the
flow
of
the
program
to
the
procedur¨
Differ
from
the
JUMP
instruction
because
a
CALLsaves
a
return
address
on
the
stack¨
The
return
instruction
returns
control
to
theinstruction
that
immediately
followings
the
CALin
a
program
when
a
ret
instruction
executes¨
Near
CALL:
be
three-byte
long,
with
a
+/-32Kbytes
displacement
or
distance
in
the
8086~8028processors;
with
32-bit
displacement,
I.
E.
+/-bytes
distance
in
80386
through
Pentium
4processors
when
operating
in
the
protected
modeCALL
(Continued)44¨
Far
CALL:
be
five-byte
long
instruction,
with
tnext
value
for
the
IP
and
CS
registers¨
The
far
CALL
instruction
places
the
contents
ofboth
IP
and
CS
onthe
stack
before
jumping
to
theaddress
indicated
by
bytes
2~5
of
the
instructio4546CALLs
with
Register
Operands47¨
Take
CALL
BX
instruction
as
an
example¨
Push
the
contents
of
IP
onto
the
stack,
then
jumpto
the
offset
address
located
in
register
BX,
incurrent
code
segment¨
This
type
of
CALL
always
uses
a
16-bit
offsetaddress,
stored
in
any
16-bit
register
except
thsegment
registers¨
Example
12¨
Look
at
theExample6-17
on
the
Page
20248CALLs
with
indirect
Memory
Addresses49¨
A
CALL
with
an
indirect
memory
address
isparticularly
useful
whenever
different
subroutneed
to
be
chosen
in
a
program¨
Example
13¨
Look
at
theExample6-18
on
the
Page
203RET50¨
The
return
instruction
(RET)
removes
a
16-bitnumber(near
return)
from
the
stack
and
places
iinto
IP¨
The
return
instruction
(RET)
removes
a
32-bitnumber(far
return)
from
the
stack
and
places
itinto
IP
and
CS¨
With
the
80386
through
the
Pentium
4
processorsoperating
in
the
protected
mode,
the
far
returnremoves
six
bytes
from
the
stack.
The
first
fourbytes
contain
the
new
value
for
EIP,
and
the
lasttwo
contain
the
new
value
for
CS¨
With
the
80386
through
the
Pentium
4
processorsoperating
in
the
protected
mode,
the
near
returnremoves
four
bytes
from
the
stack
and
places
theinto
EIP51¨
Example
14¨
Look
at
theExample6-19
on
the
Page
20552Instruction
to
Interrupts53¨
An
interrupt
is
either
a
hardware-generated
CAL(externally
derived
from
a
hardware
signal)
or
asoftware-generated
CALL
(internally
derived
frthe
execution
of
an
instruction
or
by
some
otherinternal
event)Interrupt
Vectors54¨
There
are
totally
256
different
interrupt
vectoeach
containing
the
address
of
an
interrupt
servprocedure¨
When
the
microprocessor
operates
in
the
real
moan
interrupt
vector
is
a
four-byte
number
storethe
first
1024
bytes
of
the
memory¨
In
the
protected
mode,
the
vecto
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026 年台风暴雨天气不要迎风开窗警示班会
- 2026 年军训不畏骄阳磨炼意志品质励志教育
- 2026及未来5年中国单联调光开关数据监测研究报告
- 2026及未来5年中国刷杆数据监测研究报告
- 2026事业单位工勤技能-广东-广东防疫员一级(高级技师)历年参考题库含答案详解3套试卷
- 《书法的魅力》教案-2026-2027学年浙美版(新教材)小学美术四年级上册
- 2026事业单位工勤技能-广东-广东仓库管理员四级(中级工)历年参考题库含答案详解3套试卷
- 2026事业单位工勤技能-山西-山西林木种苗工一级(高级技师)历年参考题库含答案详解3套试卷
- 2026事业单位工勤技能-山西-山西保育员四级(中级工)历年参考题库含答案详解3套试卷
- 2026事业单位工勤技能-山东-山东军工电子设备制造工四级(中级工)历年参考题库含答案详解3套试卷
- 2026年高考政治真题完全解读(黑吉辽蒙卷)
- 大邑社区工作者招考真题及答案2025
- 2026年扬州市市场监督管理系统事业单位人员招聘考试备考试题及答案详解
- 滴滴货运营销方案策划
- ISO10012-2026《质量管理-测量管理体系要求》之12:“7.1资源-7.1.1总则”专业指导问答材料(雷泽佳编制-2026A0)
- ISO140012026标准解读课件
- 2026云南曲靖国金资本运营集团有限公司招聘3人笔试历年常考点试题专练附带答案详解
- 海湾 GST-GM9000图形显示装置软件用户手册F2.480.067YC Ver3.01
- 2026中国资源循环集团电池有限公司招聘4人备考题库及一套参考答案详解
- JJG(交通) 111-2012 前插式激光测距自动弯沉仪
- 《化工企业可燃液体常压储罐区安全管理规范》解读课件
评论
0/150
提交评论