华南理工大学汇编原理课件04

上传人:xh****66 文档编号:61656411 上传时间:2018-12-08 格式:PPT 页数:114 大小:905KB
返回 下载 相关 举报
华南理工大学汇编原理课件04_第1页
第1页 / 共114页
华南理工大学汇编原理课件04_第2页
第2页 / 共114页
华南理工大学汇编原理课件04_第3页
第3页 / 共114页
华南理工大学汇编原理课件04_第4页
第4页 / 共114页
华南理工大学汇编原理课件04_第5页
第5页 / 共114页
点击查看更多>>
资源描述

《华南理工大学汇编原理课件04》由会员分享,可在线阅读,更多相关《华南理工大学汇编原理课件04(114页珍藏版)》请在金锄头文库上搜索。

1、Part B,Fundamentals of Assembly Language,Chapter 4,Symbolic Instructions 基本的符号指令,Textbook: 6 Symbolic Instructions and Addressing,8086 Symbolic instructions,A list of the symbolic instructions for the Intel processor family arranged by category. Data Transfer 数据传送类指令 Arithmetic and Logical 算术、逻辑运算类指

2、令 Bit Shifting 位操作类指令 String Operation 串操作类指令 Transfer (Conditional and Unconditional ) 控制转移类指令 Processor Control 处理机控制类指令,Overview,Format of the Instructions,Statement element: identifier mnemonic operand(s) ;comment 标识符 助记符 操作数 ;注释,Instructions without an operand,Eg. 1) NOP (空操作指令) HLT (停机指令) . 2)

3、 RET (子程序返回指令) MOVSW (串传送指令) DAA (加法的十进制调整指令),Instructions with one operand,1) with a destination operand INC BX DEC CX 2 ) with a source operand PUSH AX POP DX,Instructions with two operands,destination operand (operand1) source operand (operand2). Examples:,Note:,Functions Addressing mode Affect F

4、lag register?,Copying Data mov xchg 复制数据指令,4.1,MOV instruction (move),The MOV instruction transfers (or copies) data referenced by the address in the second operand to the address in the first operand. Format:,从源操作数地址把一个字节、字或双字复制到目的操作数地址,存放在源地址的值不会改变。 比如C语言中赋值语句 int count=0;,label: MOV reg/mem, reg/

5、mem/imm ;reg/memreg/mem/imm,MOV instruction (move),You can move to a register a byte, a word, or a doubleword. AL BL CL DL AH BH CH DH AX BX CX DX SP BP SI DI EAX EBX ECX EDX ESP EBP ESI EDI,label: MOV reg/mem, reg/mem/imm ;reg/memreg/mem/imm,Valid MOV Operations,Bytefld db ? ;Define a byte Wordfld

6、db ? ;Define a word 1) Register Moves mov edx,ecx ;register-to-register mov es,ax ;register-to-segment register mov bytefld,dh ;Register-to-memory,direct mov bx,al ;register-to-memory,indirect,Examples,Valid MOV Operations,Bytefld db ? ;Define a byte Wordfld db ? ;Define a word 2) Immediate Moves mo

7、v cx,40h ;immediate-to-register mov bytefld,25 ;immediate-to-memory,direct mov wordfldbx,25 ;immediate-to-memory,indirect,Examples,Valid MOV Operations,Bytefld db ? ;Define a byte Wordfld db ? ;Define a word 3) Direct Momory Moves mov ch,bytefld ;memory-to-register mov cx,wordfldbx ;memory-to-regist

8、er,indirect,Examples,Valid MOV Operations,Bytefld db ? ;Define a byte Wordfld db ? ;Define a word 4) Segment Register Moves mov ax,ds ;segment register-to-register mov wordfld,ds ;segment register-to-memory,Examples,Invalid MOV:,Invalid Mov: Memory - to - memory Immediate - to - segment register Seg

9、ment register- to - segment register Destination operand nots CS or immediate! 注意:源和目的操作数不可以任意组合,MOV instruction,MOV instruction not affect flag. The operand affects only the portion of the referenced register. Moving a byte to the CH does not affect the CL.,imm-reg/mem mov指令,mov al,4 ;al4,字节传送 mov

10、cx,0ffh ;cx00ffh,字传送 mov si,200h ;si0200h,字传送 mov byte ptr si,0ah ;byte ptr 说明是字节操作 mov word ptr si+2,0bh ;word ptr 说明是字操作,注意立即数是字节还是字 明确指令是字节操作还是字操作,Examples,Mem-reg,mov al,bx mov dx,bp ;dxss:bp mov es,si ;esds:si,不存在存储器向存储器的传送指令,Examples,Seg reg-reg/mem,mov si,ds mov ax,es ;axes mov ds,ax ;dsaxes,

11、对段寄存器的操作有一些限制,Examples,Summary,MOV并非任意传送, 不改变状态标志位,非法传送种种,两个操作数的类型不一致 例如源操作数是字节,而目的操作数是字;或相反 两个操作数不能都是存储器 传送指令很灵活,但主存之间的直接传送却不允许 段寄存器的操作有一些限制 段寄存器属专用寄存器,对他们的操作能力有限,两个操作数的类型要一致,绝大多数双操作数指令,除非特别说明,目的操作数与源操作数必须类型一致,否则为非法指令 MOV AL,050AH ;(X) 050Ah为字,而AL为字节 寄存器有明确的字节或字类型,有寄存器参与的指令其操作数类型就是寄存器的类型 对于存储器单元与立即

12、数同时作为操作数的情况,必须显式指明;byte ptr指示字节类型,word ptr指示字类型,两个操作数不能都是存储器,8086指令系统不允许两个操作数都是存储单元(除串操作指令),要实现这种传送,可通过寄存器间接实现 mov ax,buffer1 ;axbuffer1 ;(buffer1内容送ax) mov buffer2,ax ;buffer2ax ;这里buffer1和buffer2是两个字变量, ;实际表示直接寻址方式,Examples,要小心段寄存器的操作,不允许立即数传送给段寄存器 MOV DS,100H ;非法指令:立即数不能传送段寄存器 不允许直接改变CS值 MOV CS,S

13、I ;不允许使用的指令 不允许段寄存器之间的直接数据传送 MOV DS,ES ;非法指令:不允许段寄存器间传送,xchg,XCHG Instruction Format,XCHG swaps the two data items. 将两个不同地址的数据进行交换,2. 交换指令xchg(exchange),XCHG swaps the two data items.,mov cx, ax mov ax, bx mov bx, cx,xchg cx, bx,Examples,Note:,Not allow exchanging between memory to memory Not allow

14、using segment-register. Any addressing mold excepting immediate-addressing Not affect flag-bit. 寄存器 与 寄存器/存储器 之间交换数据,但不能用xchg交换两个存储器操作数, 不能用立即数,reg-to-reg,mov ax,1234h ;ax=1234h mov bx,5678h ;bx=5678h xchg ax,bx ;ax=5678h,bx=1234h xchg ah,al ;ax=7856h,Examples,寄存器与存储器交换xchg,xchg ax,2000h ; xchg 2000

15、h,ax xchg al,2000h ;字节交换 ;等同于 xchg 2000h,al,Examples,XCHG指令,Address transfer instruction LEA,load effective address (有效地址传送指令) Format:,LEA r16,mem ;(REG) Effective-Address of source operand,Address transfer instruction LEA,Load effective address Not the physical address Not the content of the unit,Examples,LEA指令,The LEA Instruction,Lea is useful for initializing a register with an offset address. A common use of LEA is to initialize an offset in BX, DI, or SI for indexing an address in memory.,Datatbl db 25 dup(?) ;table of 25 bytes Bytefld db ? ;one byte Lea bx,datatbl ;load offset add

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

当前位置:首页 > 生活休闲 > 科普知识

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