在32位机器上得到long long int [英] Long long int on 32 bit machines
问题描述
很简单的问题,我读了GCC支持得到long long int类型。但是,怎样才能使数学运算有了它,当CPU为32位宽只?
very simple question, I read that GCC supports long long int type. But how can make math operations with it, when CPU is 32 bit wide only?
推荐答案
编译器将综合数学运算(或使用函数调用)使用一个以上的CPU指令来执行操作。例如,添加操作将添加长长
值的低位组件(低字),然后将随身携带出的操作,并送入一个加上高换言之操作长长
。
The compiler will synthesize math operations (or use function calls) that use more than one CPU instruction to perform the operation. For example, an add operation will add the low order components (the low words) of the long long
values and will then take the carry out of that operation and feed it into an add operation on the high order words of the long long
.
所以下面的C code:
So the following C code:
long long a;
long long b;
long long c;
// ...
c = a + b;
可能会被重新由指令序列psented $ P $,看起来是这样的:
might be represented by an instruction sequence that looks something like:
mov eax, [a.low] ; add the low order words
add eax, [b.low]
mov edx, [a.high] ; add the high order words,
adc edx, [b.high] ; including the carry
mov [c.low], eax
mov [c.high], edx
如果你考虑一下,对于8位和16位系统的编译器必须为16和/或32位值长做这类事情以前长长
应运而生。
这篇关于在32位机器上得到long long int的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!