第6章 程序控制指令-上课

上传人:飞*** 文档编号:56867128 上传时间:2018-10-16 格式:PPT 页数:42 大小:306.50KB
返回 下载 相关 举报
第6章 程序控制指令-上课_第1页
第1页 / 共42页
第6章 程序控制指令-上课_第2页
第2页 / 共42页
第6章 程序控制指令-上课_第3页
第3页 / 共42页
第6章 程序控制指令-上课_第4页
第4页 / 共42页
第6章 程序控制指令-上课_第5页
第5页 / 共42页
点击查看更多>>
资源描述

《第6章 程序控制指令-上课》由会员分享,可在线阅读,更多相关《第6章 程序控制指令-上课(42页珍藏版)》请在金锄头文库上搜索。

1、CHAPTER 6 Program Control Instructions (程序控制指令)(P. 183),6-1 THE JUMP GROUP,Unconditional Jump Conditional Jumps LOOP,6-1-1 Unconditional Jump (无条件转移指令)(P. 184),The unconditional jump instruction, JMP, allows the programmer to skip sections of a program and branch to any part of the memory for the ne

2、xt instruction. Three types of unconditional jump instructions are available to the microprocessor: Short jump Near jump Far jump Jumps with Register Operands Indirect jumps Using an Index,Short jump (短转移)(P. 184),Format JMP SHORT LABEL Machine language,Opcode,Operation IPIPDisplacement,Note: The sh

3、ort jump displacement is a distance represented by a one-byte signed number whose value ranges between +127 and 128. The short jump is an intrasegment jump that allows branches to memory locations within +127 and 128 bytes from the address following the jump. Short jump is relative program memory ad

4、dressing.,1000A,10009,10008,10007,10006,10005,10004,10003,10002,10001,10000,Memory,JMP,04,CS=1000H IP=0002H,FIGURE 6-2 A short jump to four memory locations beyond the address of the next instruction,New IP=IP+04 New IP=0006H,0000 33 DB XOR BX,BX 0002 B8 0001 START: MOV AX,1 0005 03 C3 ADD AX,BX 000

5、7 EB 17 JMP SHORT NEXT0020 8B D8 NEXT: MOV BX,AX 0022 EB DE JMP SHORT START,Machine Language,Assembly Language,Offset,Near jump (近转移)(P. 185),Format JMP (NEAR PTR) LABEL Machine language,Opcode,Operation IPIPDisplacement,Note: The near jump displacement is a distance represented by a signed 16-bit n

6、umber whose value ranges between +32767 and 32768. A near jump is an intrasegment jump that can jump to any memory location within the current real mode code segment. Short jump is relative program memory addressing.,1000A,10009,10008,10007,10006,10005,10004,10003,10002,10001,10000,Memory,JMP,02,FIG

7、URE 6-3 A near jump that adds the displacement (0002H) to the contents of IP,00,0000 33 DB XOR BX,BX 0002 B8 0001 START: MOV AX,1 0005 03 C3 ADD AX,BX 0007 E9 F601 JMP NEXT0200 8B D8 NEXT: MOV BX,AX 0202 E9 FDFD JMP START,Offset,Machine Language,Assembly Language,Far jump (远转移)(P. 186),Format JMP FA

8、R PTR LABEL Machine language,Opcode,Operation IPIP High, IP Low CSCS High, CS Low,A far jump instruction obtains a new segment and offset address to accomplish the jump. A far jump is an intersegment jump that accesses any location within the first 1M byte of memory in the real mode. A far jump is d

9、irect program memory addressing.,A3128,A3127,A3126,10004,10003,10002,10001,10000,Memory,JMP,27,FIGURE 6-4 A far jump instruction replaces the contents of both CS and IP with four bytes following the opcode.,01,00,A3,10005,EXTRN UP:FAR0000 33 DB XOR BX,BX 0002 B8 0001 START: MOV AX,1 0005 03 C3 ADD A

10、X,BX 0007 E9 F601 JMP NEXT0200 8B D8 NEXT: MOV BX,AX 0202 EA 0002 - JMP FAR PTR START0207 EA 0000 - JMP UP,Offset,Machine Language,Assembly Language,Jumps with Register Operands (带寄存器操作数的转移)(P. 181),Format JMP 16reg Operation IP 16reg For example, the JMP AX instruction copies the contents of the AX

11、 register into the IP when the jump occurs.,Notes The 16reg represents any 16-bit register except segment registers. The address of the jump is in the register specified by the jump instruction. A jump with register operand is intrasegment jump that allows a jump to any location within the current c

12、ode segment. A jump with register operand is indirect program memory addressing.,Indirect jumps Using an Index (使用变址的间接转移)(P. 188),The indirect jumps using an index use the form of addressing to directly access the jump table. The assembler assumes that the jump is near unless the FAR PTR directive

13、indicates a far jump instruction.,TABLE DW ONE ;lookup tableDW TWODW THREE JMP TABLE SI ;IP(TABLE+SI+1,TABLE+SI),6-1-2 Conditional Jumps (条件转移)(P. 189),The conditional jump instructions test the following flag bits: sign (S), zero (Z), carry (C), parity (P), and overflow (O). If the condition under

14、test is true, a branch to the label associated with the jump instruction occurs. If the condition is false, the next sequential step in the program executes. For example, a JC will jump if the carry bit is set.,Conditional jump instructions are always short jumps in the 8086 microprocessor. Conditio

15、nal jump instructions often follow the CMP or TEST instruction. Table 6-1 lists all the conditional jump instructions with their test conditions.,TABLE 6-1 Conditional jump instructions,TABLE 6-1 Conditional jump instructions (continued),FIGURE 6-5 Signed and unsigned numbers follow different orders

16、,6-1-3 LOOP (P. 186),Format LOOP LABEL Operation LOOP decrements CX; if CX0, it jumps to the address indicated by the label; If CX becomes a 0, the next sequential instruction executes. Compare the following instructions: LOOP LABEL DEC CXJNZ LABEL,EXAMPLE 6-6 ;A program that sums the contents of BL

17、OCK1 and BLOCK2;and stores the results over top of the data in BLOCK2.MODEL SMALL ;select SMALL model.DATA ;start of DATA segmentBLOCK1 DW 100 DUP(?) ;100 bytes for BLOCK1BLOCK2 DW 100 DUP(?) ; 100 bytes for BLOCK2 .CODE ;start of CODE segment.STARTUP ;start of programMOV AX,DS ;overlap DS and ESMOV ES,AXCLD ;select incrementMOV CX,100 ;load count of 100MOV SI,OFFSET BLOCK1 ;address BLOCK1MOV DI,OFFSET BLOCK2 ; address BLOCK2L1: LODSW ;load AX with BLOCK1ADD AX,ES:DI ;add BLOCK2 data to AXSTOSW ;stare sum in BLOCK2LOOP L1 ;repeat 100 times.EXIT ;exit to DOSEND ;end of file,

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 行业资料 > 其它行业文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号