[z88dk-dev] start of 64-bit long long for sdcc committed

Bridge to the z88dk-developers mailing list
Post Reply
alvin
Well known member
Posts: 1872
Joined: Mon Jul 16, 2007 7:39 pm

[z88dk-dev] start of 64-bit long long for sdcc committed

Post by alvin »

Multiplication, division, addition, subtraction, shifting of 64-bit longlongs should be working now for sdcc and the new c lib. It's completely untested other than to note that programs don't crash. I haven't updated headers yet (defining uint64_t for example) and still to come are the strtoull, atoull, printf %lld, etc. What I will be doing for testing is making a union of a longlong and two longs so that the top and bottom 32 bits can be printed or scanned individually.

For the classic c lib it should just be a matter of grabbing the relevant sdcc files in the "l" directory and the small integer math functions in the "math" subdirectory of the dev tree but it may be better to wait until it's known whether things work.

sdcc is generating very bloaty code for longlongs (72 bytes to add two longlongs, something like 32 bytes to push a longlong parameter for a function) so it needs to be changed either by us or them to use library functions to carry out longlong primitives to make this practical. The same situation exists for plain longs but the size penalty for inlining things isn't as large and at least in the case of longs, 50/50 there is a speed advantage to inlining once the code has been fixed up by the peephole rules.



------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/3029 ... 30105516;z
alvin
Well known member
Posts: 1872
Joined: Mon Jul 16, 2007 7:39 pm

Post by alvin »

The basic integer operations seem to be working.

Test program for zx target. Load the binary to 32768 and RAND USR that.
Each 64-bit integer is read in two 32-bit hex halves. Since everything is in hex it's handy to have a hex calculator to verify results.


// zcc +zx -vn -SO3 -startup=4 -clib=sdcc_ix --reserve-regs-iy --max-allocs-per-node200000 test.c -o test --list

#include <stdio.h>
#include <input.h>

struct long_s
{
unsigned long ls32;
unsigned long ms32;
};

union u64_s
{
long long a;
struct long_s b;
};

union u64_s x, y, z;

void main(void)
{
in_wait_nokey();
fflush(stdin);

while(1)
{
printf("\n\n[#1] MS32 <space> LS32 in hex\n");
scanf("%lx%lx", &x.b.ms32, &x.b.ls32);

printf("\n[#2] MS32 <space> LS32 in hex\n");
scanf("%lx%lx", &y.b.ms32, &y.b.ls32);

z.a = x.a + y.a;
printf("\n0x%08lx%08lx + 0x%08lx%08lx = 0x%08lx%08lx\n", x.b.ms32, x.b.ls32, y.b.ms32, y.b.ls32, z.b.ms32, z.b.ls32);

z.a = x.a - y.a;
printf("0x%08lx%08lx - 0x%08lx%08lx = 0x%08lx%08lx\n", x.b.ms32, x.b.ls32, y.b.ms32, y.b.ls32, z.b.ms32, z.b.ls32);

z.a = x.a * y.a;
printf("0x%08lx%08lx * 0x%08lx%08lx = 0x%08lx%08lx\n", x.b.ms32, x.b.ls32, y.b.ms32, y.b.ls32, z.b.ms32, z.b.ls32);

z.a = x.a / y.a;
printf("0x%08lx%08lx / 0x%08lx%08lx = 0x%08lx%08lx\n", x.b.ms32, x.b.ls32, y.b.ms32, y.b.ls32, z.b.ms32, z.b.ls32);

z.a = x.a % y.a;
printf("0x%08lx%08lx %% 0x%08lx%08lx = 0x%08lx%08lx\n", x.b.ms32, x.b.ls32, y.b.ms32, y.b.ls32, z.b.ms32, z.b.ls32);

z.a = x.a >> y.a;
printf("0x%08lx%08lx >> 0x%08lx%08lx = 0x%08lx%08lx\n", x.b.ms32, x.b.ls32, y.b.ms32, y.b.ls32, z.b.ms32, z.b.ls32);

z.a = x.a << y.a;
printf("0x%08lx%08lx << 0x%08lx%08lx = 0x%08lx%08lx\n", x.b.ms32, x.b.ls32, y.b.ms32, y.b.ls32, z.b.ms32, z.b.ls32);
}
}



------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/3029 ... 30105516;z
alvin
Well known member
Posts: 1872
Joined: Mon Jul 16, 2007 7:39 pm

Post by alvin »

64-bit longlongs are now fully supported in the new c lib.

http://www.z88dk.org/forum/viewtopic.php?id=9375



------------------------------------------------------------------------------
Mobile security can be enabling, not merely restricting. Employees who
bring their own devices (BYOD) to work are irked by the imposition of MDM
restrictions. Mobile Device Manager Plus allows you to control only the
apps on BYO-devices by containerizing them, leaving personal data untouched!
https://ad.doubleclick.net/ddm/clk/3045 ... 31938128;j
Post Reply