[Info-vax] Kednos PL/I
Arne Vajhøj
arne at vajhoej.dk
Thu Sep 14 20:56:12 EDT 2023
On 9/14/2023 10:38 AM, Johnny Billquist wrote:
> On 2023-09-14 13:18, Andreas Gruhl wrote:
>> Arne Vajhøj schrieb am Donnerstag, 14. September 2023 um 02:53:20 UTC+2:
>>> On 9/13/2023 4:53 PM, gah4 wrote:
>>>> On Wednesday, September 13, 2023 at 12:28:45 PM UTC-7, Arne Vajhøj
>>>> wrote:
>>>> (snip, I wrote)
>>>>>> Does Alpha have 64 bit multiply and divide?
>>>>
>>>>> In instruction set?
>>>>
>>>>> Multiply: yes
>>>>
>>>> With 128 bit product?
>>> No.
>> Sorry Arne, but I would prefer to say yes.
>> Since Alpha can only deliver 64 bits per instruction, you have to use
>> two of them:
>> MULQ for the lower 64 bits and then UMULQ for the upper 64 bits.
>
> It's UMULH, but I agree. The Alpha was definitely designed for getting a
> 128 bit result from 64 bit multiply. But it is done via two
> instructions. MULQ;UMULH. If you want a signed MUL, you then need a
> couple of more steps to adjust the result. But it's a simple thing.
So first a MULQ and then a UMULH works similar to how EMUL
worked on VAX?
(obviously 64 bit * 64 bit = 128 bit instead of 32 bit * 32 bit = 64 bit)
Looks like it.
$ type mul64.mar
.title m64
.psect $CODE quad,pic,con,lcl,shr,exe,nowrt
.entry mul64,^m<>
emul 4(ap),8(ap),#0, at 12(ap)
ret
.end
$ macro mul64
emul 4(ap),8(ap),#0, at 12(ap)
^
%AMAC-I-MEMREFNOT, memory reference not naturally aligned in routine MUL64
at line number 4 in file DISK2:[ARNE]mul64.mar;1
$ type mul128.m64
$code_section
$routine mul128,kind=stack
mulq r16,r17,r22
stq r22,(r18)
umulh r16,r17,r23
stq r23,8(r18)
$return
$end_routine mul128
.end
$ macro/alpha mul128
$ type bigmul.c
#include <stdio.h>
void mul64(long int a, long int b, long int *c);
void mul128(long long int a, long long int b, long long int *c);
int main(int argc, char *argv[])
{
long int a32 = 0x40000000L;
long int b32 = 0x00000004L;
long int c64[2];
mul64(a32, b32, c64);
printf("%08X %08X\n", c64[1], c64[0]);
long long int a64 = 0x4000000000000000LL;
long long int b64 = 0x0000000000000004LL;
long long c128[2];
mul128(a64, b64, c128);
printf("%016LX %016LX\n", c128[1], c128[0]);
return 0;
}
$ cc bigmul
$ link bigmul + mul64 + mul128
$ run bigmul
00000001 00000000
0000000000000001 0000000000000000
Arne
More information about the Info-vax
mailing list