JAVA

SHL BL, CL ;BL 4

OR DL,BL ;4 BL DL

DIV, IDIV. .

:

. AX, - . , - AL. , - + 255 (0FFH) +127 (7FH) , :  AX 堠 ͠ AL

: ) :

( ). EDX:EAX, - . EDX, - EAX. + FFFFFFFF 7FFFFFFF :

 EDX EAX 堠 EDX | EAX

: -

: ꠠ |

DIV IDIV . EAX, EDX CDQ. :

DIV DIVISOR

DIVISOR (DB), . DIVISOR (DW), . DIVISOR (DD), .

, , 13 3 4 1/3. 4, - 1. , ( ) 4,333... (4) (,333). 1/3 ,333... - , 1 - . : DIV

DIV . . 4.28 D10DIV :

1. ,

2. ,

3.

4. .

DIV 2000 (8092) 80H (128). 00 , 40H (64) - AL.

DIV BYTE1 . , . - 12 , 05 - AL.

DIV 1000 DX 0080 AX.

DIV WORD1 DX:AX. 0000 DX, 0002 - AX. : IDIV

IDIV (Integer DIVide) . . 4.28 E101DIV , D10DIV, DIV IDIV. IDIV 2000 ( ) 80H ( ). 00 , -00 (-64) - AL. DIV, , + 64.

:

IDIV

2 Š (-18) FB (-5)

3 1000 (4096) 0080 (128)

4 0000 0002

4 , DIV.

, , DIV IDIV . , DIV , IDIV - . , .

TITLE EXDIV (M) DIV IDIV

CODESG SEGMENT PARA 'Code'

ORG 100H

BEGIN: JMP SHORT MAIN

;

BYTE1 DB 80H ;

BYTE2 DB 16H

WORD1 DW 2000

WORD2 DW 0010H

WORD3 DW 1000H

MAIN PROC NEAR ;

CALL D10DIV ; / DIV

CALL E101DIV ; / IDIV

MAIN ENDP

; DIV:

;

D10DIV PROC

MOV AX,WORD1 ; /

DIV BYTE1 ;: AH: AL

MOV AL,BYTE1 ; /

SUB ,͠ ;.

DIV BYTE2 ;: AH: AL

MOV DX, WORD2 ; /

MOV AX,WORD3 ; DX:AX

DIV WORD1 ;: DX:AX

MOV AX,WORD1 ; /

SUB DX, DX ;. DX

DIV WORD3 ;: DX:AX

RET

D10DIV ENDP

; IDIV:

E101DIV PROC

MOV AX, WORD1 ; /

IDIV BYTE1 ;: AH: AL

MOV AL,BYTE1 ; /

CBW ;.

IDIV BYTE3 ;: AH: AL

MOV DX,WORD2 ; /

MOV AX, WORD3 ; DX:AX

IDIV WORD1 ;: DX:AX

MOV AX,WORD1 ; /

CWD ;. DX

IDIV WORD3 ;: DX:AX RET

E10DIV ENDP

CODESG ENDS

END BEGIN

. 4.28.

.

2 (2, 4 ..) . , AX:

2:

SHR AX,1

8:

MOV CL.3

SHR AX,CL

DIV IDIV, . ( , ) . , , . . 1 , , .

: - , , () ; - , , (DX) .

, 1:

:

: 0123 01 (1)23

: 0001 4026 0001 (1)4026

. , DIV IDIV . , DIVBYTE - , AX. , DIVWORD - , DX:AX.

򠠠

CMP AH,DIVBYTE CMP DX,DIVWORD

JNB ;堠 JNB ;

DIV DIVBYTE DIV DIVWORD

IDIV , , , , NEG  .

, , . , 1. , . AX, - EBX, CX:

SUB CX,CX ;

20: CMP AX,BX ; < ,

JB 0 ;

SUB AX,BX ;. .

INC CX ;

JMP 20 ;

0: RET ; CX, AX

CX , AX - . , - . DX:AX, :

1. 20 AX BX DX.

2. SUB SBB DX,00 ( ).

: .

NEG . NEG 1. :

NEG AX

NEG BL

NEG BINAMT ;( )

64- ( ) 堠  . , EDX:EAX 64- . NEG

, . NOT:

NOT EDX

NOT EAX

ADD EAX,1 1 EAX

ADC EDX, 0 EDX

: , , , . , , . , , ASCII-. ASCII- , ⠠ .

Intel IA-32. IA-32 CISC, .


<< >>