如何使用大量的? [英] How to use large numbers?

查看:127
本文介绍了如何使用大量的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用大量?像3441881739,30000000等

How to use large numbers in? like 3441881739,30000000 etc

mov eax,3441881739

在这种情况下,eax中的值是一个负数。如何解决呢?拆呢?怎么样?
我也需要做的添加/分/ MUL / DIV等方面的 CMP 操作。

In this case eax value is a negative number. How to fix it? split it? how? I need to do also add/sub/mul/div etc the cmp operation.

有人可以解释并举例怎么办呢?

Can someone explain and give an example how to do it?

我标记 FASM NASM 标签,但anothers装配也欢迎。
我的32位计算机上。

I marked fasm and nasm tags but anothers assembly are welcome too. I'm on 32-bit machine.

推荐答案

如果您要处理超过2 32 -1,你需要做的MULTIPLE- precision较大的数字算术。例如,添加一对64位的数字,你可以做这样的事情:

If you want to deal with numbers larger than 232-1, you'll need to do multiple-precision arithmetic. For example, to add a pair of 64-bit numbers you could do something like this:

mov eax, A_1    ; essentially C = A + B
mov edx, B_1
add eax, edx    ; note that for the low word, we just add
mov C_1, eax
mov eax, A_2
mov edx, B_2
adc eax, edx    ; but for the high word, we add with carry
mov C_2, eax

能够直接访问进位装置,这是比最高级语言相当简单。另外还有带借使多字减法容易和减法。乘法和除法依赖一点点。一个正常的32×32位乘法产生64位结果(低字EAX,EDX中高字)。如果你想要像64×64位的乘法运算(给人一种128位的结果),你需要实现自己。

Having access to the carry bit means that this is considerably simpler than with most higher level languages. There's also a subtract with borrow to make multi-word subtraction easy as well. Multiplication and division depend a little. A normal 32x32 bit multiplication produces a 64-bit result (low word in eax, high word in edx). If you want something like 64x64 bit multiplication (giving a 128-bit result) you'll need to implement that yourself.

例如,乘法(不使用内置的MUL / IMUL指令)可以做这样的事情:

For example, multiplication (without using the built-in mul/imul instructions) can be done something like this:

mult proc
; multiplies eax by ebx and places result in edx:ecx
    xor ecx, ecx
    xor edx, edx
mul1:
    test ebx, 1
    jz  mul2
    add ecx, eax
    adc edx, 0
mul2:
    shr ebx, 1
    shl eax, 1
    test ebx, ebx
    jnz  mul1
done:
    ret
mult endp

这篇关于如何使用大量的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆