English 中文(简体)
64bit nasm Division idiv [duplicate]
原标题:64bit nasm division idiv [duplicate]
;print out division message
mov rcx, 0                       ;zero out register
mov rax, [input]
mov rcx, [input2]
idiv rcx                        ;divide rax by rcx
mov rdi, rax                    ;for printing purposes
call print_int

我看不出,为什么这种n断,用64台借机将一米带“空洞点例外”,而且这些数值不是浮动点。

我知道,在进行分裂之后,引人应当坐在黑手里,而其余的人应当相信,但从现在起,我只是想把我的手带上来。

最佳回答

你的职能对我来说是很困难的。 www.un.org/Depts/DGACM/index_spanish.htm

_mydiv:
  xor  %rdx, %rdx ; clear high bits of dividend
  mov  %rdi, %rax ; copy dividend argument into rax
  idiv %rsi       ; divide by divisor argument
  ret             ; return (quotient is in rax)

Translated into NASM syntax and to the windows ABI, I think that would be something like:

_mydiv:
  mov  r8, rdx    ; copy divisor argument to scratch register
  xor  rdx, rdx   ; clear high bits of dividend
  mov  rax, rcx   ; copy dividend argument into rax
  idiv r8         ; divide by divisor in scratch register
  ret             ; return (quotient is in rax)

您的参数是否一致,如何混淆一些东西?

Edit: looking at your code, it occurs to me that it might not be written as a proper function at all. The important steps are:

  1. Put dividend in RDX:RAX - for you that probably means clearing out RDX and putting the input dividend in RAX.
  2. Put divisor in some other register - you chose RCX, that should be fine.
  3. Divide - idiv rcx.
  4. Result will be in RAX.

You should pay particular attention to step 1 - make sure that RDX:RAX has sane contents! Why you re getting a floating point exception I can t guess from the code you ve shown.

问题回答

您实际上将RDX:RAX的128倍数字由RCX区分。 因此,如果RDX未启动,结果可能大于64倍,导致出现超支例外。 在该司之前添加一个CQO,以将RAS输入RDX。

我可以解释一下浮动点的比值,但也许有人决定重新使用通用数学差错的中断矢量,有些地方倒下了线?





相关问题
List of suspected Malicious patterns

I am doing an anti-virus project by disassembling its code and analyzing it. So I want a list of the Suspected Malicious pattern codes, so I can observe which is suspected and which is not? So I want ...

Prefetch for Intel Core 2 Duo

Has anyone had experience using prefetch instructions for the Core 2 Duo processor? I ve been using the (standard?) prefetch set (prefetchnta, prefetcht1, etc) with success for a series of P4 ...

How are mutex and lock structures implemented?

I understand the concept of locks, mutex and other synchronization structures, but how are they implemented? Are they provided by the OS, or are these structures dependent on special CPU instructions ...

Installing GNU Assembler in OSX

No matter how hard I google, I can t seem to find a (relatively) easy-to-follow instruction on how to install the GNU Assembler on a mac. I know I can use gcc -c (Apple Clang on a Mac) to assemble .s ...

8086 assembler,INT 16,2

I got stuck at this thing,I want to see if right shift button has been pressed,so I have this assambler code: mov ah,2 int 16h ;calling INT 16,2 - Read Keyboard Flags interrupt mov ah,...

Translate a FOR to assembler

I need to translate what is commented within the method, to assembler. I have a roughly idea, but can t. Anyone can help me please? Is for an Intel x32 architecture: int secuencia ( int n, ...

热门标签