8086汇编——课堂笔记整理3

STD set Director  将DF=1

MOVSB ES:[DI]=DS:[SI]

MUL IMUL

MUL SRC 无符号    IMUL SRC 有符号

MUL/IMUL  reg/mem8  ->  AX<-AL*reg/mem8

MUL/IMUL  reg/mem16  ->  DX:AX<-AX*reg/mem16

MUL/IMUL  reg/mem32  ->  EDX:EAX<-EAX*reg/mem32

IMUL: 改变CF,OF;CF=OF=1,高位不为0;CF=OF=0,高位为0,无符号数/有符号数没有进位

IMUL REG,SRC,IMM;  REG<-REG*sign-extened IMM

16/32,16/32,8  ;  16,16,16(->extened)  ;  32,32,16(->extened)

DIV IDIV

DIV SRC;无符号          IDIV SRC ;有符号

DIV/IDIV reg/mem8 ;AX/reg/mem8,余数->AH,商->AL

DIV/IDIV reg/mem16;  DX:AX/reg/mem16,余数->DX,商->AX

DIV/IDIV reg/mem32;  EDX:EAX/reg/mem32,余数->EDX,商->EAX

expend 被除数

CBW:AL->AX

CWD:AX->DX:AX

CWDE:AX->EAX

CDQ:EAX->EDX:EAX

e,g,1

<c>unsigned A=1020,B=1000;unsigned N1,N2;N1=A/B,N2=A%B

<a>

A WORD 1020

B WORD 1000

N1 WORD ?

N2 WORD ?

MOV AX A

MOV DX,0;将DX初始化为0

CWD

IDIV B

MOV N1,AX

MOV N2,DX

e.g.2

suppose X,Y,Z,V are 16-bit signed number,calculate (V-(X*Y+Z))/X.quotient in AX,remainder in DX

MOV AX,X

IMUL Y

MOV BX,AX

MOV CX,DX

MOV AX,Z

CWD

ADD BX,AX

ADC CX,DX

MOV AX,V

CWD

SUB AX,BX

SBB DX,CX

IDIV X

 

AAA

将2个unpacked BCD码的和生成一个unpacked BCD码

MOV AL,09H

MOV BL,04H

ADD AL,BL

AAA

改变AF:低8位向高8位进位,AF=1;AH<-(AH)+1

 

AAS

MOV AL,0106H

MOV BL,7H

SUB AL,BL

AAS

改变AF:低8位襄高8位借位,AF=1;AH<-(AH)-1

 

AAM

MOV AL,09H

MOV BL,07H

MUL BL

AAM

 

AAD

MOV AX,0208H

MOV BL,04H

AAD;AL<-(AL)+(AH)*10

DIV AX,BL

 

DAA

MOV AL,54H

MOV BL,43H

ADD AL,BL

DAA

 

DAS

A=4612;B=3576

MOV AL,A

SUB AL,B

DAS

MOV B,AL

MOV AL,A+1

SBB AL,B+1

DAS

MOV B+1,AL

 

posted @ 2016-04-22 00:20  ShellHan  阅读(238)  评论(0编辑  收藏  举报