Delphi-PRAXiS
Seite 2 von 2     12   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Programmieren allgemein (https://www.delphipraxis.net/40-programmieren-allgemein/)
-   -   [ASM] Dividieren von Ganzzahlen (https://www.delphipraxis.net/78353-%5Basm%5D-dividieren-von-ganzzahlen.html)

Dax 3. Okt 2006 20:32

Re: [ASM] Dividieren von Ganzzahlen
 
Örm, falsch.

x86 Instruction Set Reference
CWD/CDQ—Convert Word to Doubleword/Convert Doubleword
to Quadword

Description

Doubles the size of the operand in register AX or EAX (depending on the operand size) by
means of sign extension and stores the result in registers DX:AX or EDX:EAX, respectively.
The CWD instruction copies the sign (bit 15) of the value in the AX register into every bit position
in the DX register (see Figure 7-6 in the IA-32 Intel Architecture Software Developer’s
Manual, Volume 1). The CDQ instruction copies the sign (bit 31) of the value in the EAX
register into every bit position in the EDX register.
The CWD instruction can be used to produce a doubleword dividend from a word before a word
division, and the CDQ instruction can be used to produce a quadword dividend from a doubleword
before doubleword division.
The CWD and CDQ mnemonics reference the same opcode. The CWD instruction is intended
for use when the operand-size attribute is 16 and the CDQ instruction for when the operand-size
attribute is 32. Some assemblers may force the operand size to 16 when CWD is used and to 32
when CDQ is used. Others may treat these mnemonics as synonyms (CWD/CDQ) and use the
current setting of the operand-size attribute to determine the size of values to be converted,
regardless of the mnemonic used.


Sprich: es füllt EDX mit Sign(EAX).

@Balu: Intel x86 Instruction Set Reference - Google mal danach ;)

3_of_8 3. Okt 2006 20:34

Re: [ASM] Dividieren von Ganzzahlen
 
Habe ich das nicht gesagt?

Muetze1 3. Okt 2006 20:44

Re: [ASM] Dividieren von Ganzzahlen
 
Zitat:

Zitat von Dax
Örm, falsch.

Öhm, nö. Und deine gepostete Doku sagt dies sogar aus. 3_of_8 hat es zwar in Kurzform geschrieben aber vollkommen richtig.

/EDIT: Mitten im POST ein Discon... *grml*

Amateurprofi 3. Okt 2006 20:47

Re: [ASM] Dividieren von Ganzzahlen
 
Zitat:

Zitat von Dax
Örm, falsch..

FALSCH. Was 3_of_8 schrieb ist völlig korrekt.


Zitat:

Zitat von Dax
Sprich: es füllt EDX mit Sign(EAX)...

FALSCH.
Würde CDQ EDX mit Sign(EAX) füllen, dann wäre EDX, je nach Interpretation von "Sign(EAX)", entweder $80000000 oder $00000001 oder $00000000

Richtig ist, daß CDQ Bit 31 aus EAX in jedes Bit von EDX kopiert also ist EDX dann entweder $FFFFFFFF oder $00000000, also exakt so, wie 3_of_8 es schrieb.

Dax 3. Okt 2006 20:56

Re: [ASM] Dividieren von Ganzzahlen
 
Ach verdammt, ich hab statt edx da oben eax gelesen :oops: Und beim schreiben nich gedacht :wall: Ich meinte, das Sign(EAX) in jedes Bit geschrieben wird, nicht ins ganze Register...

*jetzt besser die klappe hält*


Alle Zeitangaben in WEZ +1. Es ist jetzt 21:22 Uhr.
Seite 2 von 2     12   

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz