Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

exremally stupid error

123 views
Skip to first unread message

fir

unread,
May 13, 2022, 9:12:42 PM5/13/22
to
i write my compiler and i got some rutine

RunFrame
{

DrawLine3d 20.0 30.0 40.0 100.0 0.0 400.0 0xaaaa77
DrawLine3d 22.0 30.0 43.0 130.0 0.0 400.0 0xaaaa77
DrawLine3d 29.0 30.0 42.0 130.0 0.0 400.0 0xaaaa77

}

I got 3 routines that draw lines there and it worx

the problem is ehen i putt those routines in separate call like

foo
{
DrawLine3d 20.0 30.0 40.0 100.0 0.0 400.0 0xaaaa77
DrawLine3d 22.0 30.0 43.0 130.0 0.0 400.0 0xaaaa77
DrawLine3d 29.0 30.0 42.0 130.0 0.0 400.0 0xaaaa77
}

and call this foo from DrawFrame then it crashes though
ime the assembly is the same (rxcep this call and ret)

In fact it DOnt crashes immediatelly if those lines fiit in the centre of
screen it dont crasjes it only crashes when i move camere and those lines
began to become partially outside the window (though this function clips etc and the oryginal version worx ok)


what the hell it could be - i post the executable files and even compiler so you could run and see


https://filebin.net/kap86bfd533x7491


teh assembly generated seems to be ok


DeawLines:
//l.128 DrawLine3d 20.0 30.0 40.0 100.0 1.0 400.0 0xaaaa77
mov eax 11184759
push eax
mov eax 1137180672
push eax
mov eax 1065353216
push eax
mov eax 1120403456
push eax
mov eax 1109393408
push eax
mov eax 1106247680
push eax
mov eax 1101004800
push eax
call ("green_fire.dll"->DrawLine3d)
pop eax
pop eax
pop eax
pop eax
pop eax
pop eax
pop eax
//l.129 DrawLine3d 22.0 30.0 43.0 130.0 2.0 400.0 0xaaaa77
mov eax 11184759
push eax
mov eax 1137180672
push eax
mov eax 1073741824
push eax
mov eax 1124204544
push eax
mov eax 1110179840
push eax
mov eax 1106247680
push eax
mov eax 1102053376
push eax
call ("green_fire.dll"->DrawLine3d)
pop eax
pop eax
pop eax
pop eax
pop eax
pop eax
pop eax
//l.130 DrawLine3d 29.0 30.0 42.0 130.0 3.0 400.0 0xaaaa77
mov eax 11184759
push eax
mov eax 1137180672
push eax
mov eax 1077936128
push eax
mov eax 1124204544
push eax
mov eax 1109917696
push eax
mov eax 1106247680
push eax
mov eax 1105723392
push eax
call ("green_fire.dll"->DrawLine3d)
pop eax
pop eax
pop eax
pop eax
pop eax
pop eax
pop eax
//l.133 }

ret




Kaz Kylheku

unread,
May 13, 2022, 9:19:28 PM5/13/22
to
On 2022-05-14, fir <profes...@gmail.com> wrote:
> what the hell it could be

What the hell, indeed.

Is it a bird? ... a plane?

No! It's a dumb pollack writing incoherent nonsense about things having
no relation to C.

In a few minutes, we will have your local weather, followed by the
bridges-and-tunnels traffic report. But first, off-topic, abrasive
banter Bonita Montero, followed by complete drivel from Skybuck ...


--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal

fir

unread,
May 13, 2022, 9:26:18 PM5/13/22
to
sobota, 14 maja 2022 o 03:19:28 UTC+2 Kaz Kylheku napisał(a):
> On 2022-05-14, fir <profes...@gmail.com> wrote:
> > what the hell it could be
> What the hell, indeed.
>
> Is it a bird? ... a plane?
>
> No! It's a dumb pollack writing incoherent nonsense about things having
> no relation to C.
>
> In a few minutes, we will have your local weather, followed by the
> bridges-and-tunnels traffic report. But first, off-topic, abrasive
> banter Bonita Montero, followed by complete drivel from Skybuck ...
>
>
maybe in your brainwashed world...in fact this is normal c programming

Jan van den Broek

unread,
May 14, 2022, 3:54:47 AM5/14/22
to
2022-05-14, Kaz Kylheku <480-99...@kylheku.com> schrieb:
> On 2022-05-14, fir <profes...@gmail.com> wrote:
>> what the hell it could be
>
> What the hell, indeed.
>
> Is it a bird? ... a plane?
>
> No! It's a dumb pollack writing incoherent nonsense about things having
> no relation to C.
>
> In a few minutes, we will have your local weather, followed by the
> bridges-and-tunnels traffic report. But first, off-topic, abrasive
> banter Bonita Montero, followed by complete drivel from Skybuck ...

And that is the reason that newsreaders have killfiles.

--
Jan v/d Broek
balg...@dds.nl

fir

unread,
May 14, 2022, 5:51:58 AM5/14/22
to
well i should add you weak shittalkers..never say something valueable on point, first
to talk shit

fir

unread,
May 14, 2022, 10:38:50 AM5/14/22
to
alright it was caused by -Ofast flag used to compile the library (it turns on -O3 and i got problems with this O3 already back then)

Kaz Kylheku

unread,
May 14, 2022, 11:51:08 AM5/14/22
to
Yes; but what newsreaders need is stronger killfiles that can't be
temporarily circumvented with a couple of keystrokes in situations when
they report "3 new articles" and they are all killed.

Ben

unread,
May 14, 2022, 12:25:06 PM5/14/22
to
fir <profes...@gmail.com> writes:

> alright it was caused by -Ofast flag used to compile the library (it
> turns on -O3 and i got problems with this O3 already back then)

It's more accurate (usually) to say that a bug is revealed by an
optimisation setting. It's possible that -Ofast introduced a bug, but
that's a rather rate occurrence.

--
Ben.

fir

unread,
May 14, 2022, 12:31:23 PM5/14/22
to
i dont think so note they have such flags as -funsafe-math-optimizations -mfpmath=both
and so on, they just turn things to ride on the edge i guess, i suspect that maybe they
needed 16 bytes aligned stack frame or something, but i dont care to debug on binary level
as im weak/not much used to it (still if someone wants to check binaries are provided)

David Brown

unread,
May 15, 2022, 6:03:00 AM5/15/22
to
The "-funsafe-math-optimizations" flag does not give you a risk of the
compiler generating bad code. It means that the generated code might
not give the same results as specified by the IEEE standards - perhaps
rearrangements will lead to different rounding, or the compiler might
make some assumptions that reduce the amount of checking of arguments it
does.

<https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#index-funsafe-math-optimizations>



Compilers are never perfect, and have bugs, but as Ben says these are a
rather rare occurrence. They are perhaps more likely when using the
rarer optimisation levels, simply because such flags have less overall
testing in the field, but when you have code that "breaks" when
optimisation is enabled, it is almost always a bug in your own code, or
at least a misunderstanding.



fir

unread,
May 15, 2022, 10:12:33 AM5/15/22
to
you should better check than talking generalities which are often false - and
i say this becouse its better to know than talk false generalities becouse its misleading
and harmfull ..sadly many people do that

i remember i got -O3 issues already few years ago (as i almost zero code last years
in coding time it was not so long) that time it was as i remember stack frame aligment
issue on sse commands .. i dont remember the details hovever, .. i just concluded
to not use O3 but in meantime i added -OFast and i was unaware it turns O3

that is PROBABLY the issue, if someone got time may debug it..im personally better move on with code and cant sink in details now (already feel a bit tired though it would be good to have own compiler,
it quite nice, its small liek 500KB on disk and i can redistribute it with sources making them editable like scripts.. its cool... sadly after 3 weeks of coding i feel tired but if i will break the work i will not have soem things and it would be nice to have yet something )

David Brown

unread,
May 15, 2022, 3:45:56 PM5/15/22
to
If you think the problem is with stack alignments, then it is not a
matter of optimisation flags. x86-64 processors require certain stack
alignments for some of the SIMD instructions (which are more likely to
be used in higher optimisations - thus you will see the problem more
often at higher optimisations, despite it not being an optimisation
issue). Windows DLLs and callbacks often do not have the stack aligned
enough, so if you are using gcc on Windows you might hit such problems.

The answer is to tell gcc that it has to assume you are interacting with
Windows DLLs with poor stack alignment, and it must add extra
instructions to compensate. That is, I believe, the "-mstackrealign" flag.

<https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html>

As I say, it is not an issue with the compiler, it is a misunderstanding
by the user.

(I haven't tested this myself - I have no real interest in programming
on Windows and it is not an issue on Linux.)

fir

unread,
May 15, 2022, 5:16:03 PM5/15/22
to
when i discovered it dont work with O3 i dont wnat to much spoend time on it now,
one need to prioritize work and there are more important things

im not sure but its posible that my demo work on linux by wine emulation

https://filebin.net/hqtyniltng9gu2et

im not sure as i never seen that wine on my eyes ..i mean im not sure if compilation works as iy uses bats but maybe the output exe worx

fir

unread,
May 15, 2022, 5:30:44 PM5/15/22
to
it compiles now weird subset of what i call gneralized c, nut i already made a terrible mes in the source of this compiler
writing compiler is in fact not so easy, or i got things not enough retinked to dwell in swamp again

this is becouse programing is standable when one can divide things on small factorized steps and compiler makes ttouble with dat..its probably possible to divide on this easy clear steps but if some halfly conceptualizes things and half go way on shortcuts it become swamp

what i can now compile is like that:



import "green_fire.dll" (cdecl) DrawAACube DrawAAWireCube RandColor SetupLights_3moving SetPointLight DrawDot3d DrawLine3d SetupWindow2 Set3dDrawingMode DrawSomeText2 rand2 ToggleFullscreen ClearFrameData DrawCircle RegisterRunFrame RegisterMouseMove RegisterKeyDown RegisterOnResize SetSleepValue SetScaleOnResize SetupWindow3 (var) frame_size_x frame_size_y frame_bitmap frame_number
import "msvcrt.dll" (cdecl) printf


void SetupLight
SetPointLight 0 1 -1100.0 0.0 0.0 7000.0 50000.0 0.30 1.9 1.3 1.3 0.01 0.01 0.01 0.18 1.1 1.1 1.1 0.01 0.01 0.01
SetPointLight 1 3 1100.0 500.0 500.0 7000.0 50000.0 0.30 1.3 1.9 1.3 0.01 0.01 0.01 0.18 1.1 1.1 1.1 0.01 0.01 0.01
SetPointLight 2 3 0.0 -1500.0 -500.0 7000.0 50000.0 0.30 1.3 1.3 1.9 0.01 0.01 0.01 0.18 1.1 1.1 1.1 0.01 0.01 0.01 ;


void SetupCloud
{
int[1000] cloud_x,
int[1000] cloud_y,
int[1000] cloud_z,
int[1000] cloud_r,
int[1000] cloud_color

0$ i$999$4:
cloud_x[i] = (rand2 200 500),
cloud_y[i] = (rand2 200 500)
cloud_z[i] = (rand2 0 1300)
cloud_r[i] = (rand2 10 20)
cloud_color[i] = (RandColor 0 255 0 255 0 255) ;
}




void SetupCloud2
{
int[1000] cloud2_x,
int[1000] cloud2_y
int[1000] cloud2_z,
int[1000] cloud2_r
int[1000] cloud2_color

0$ i$999$4:
cloud2_x[i] = (rand2 -1200 -500)
cloud2_y[i] = (rand2 -1200 -1500)
cloud2_z[i] = (rand2 0 -1300)
cloud2_r[i] = (rand2 10 20)
cloud2_color[i] = (RandColor 0 255 0 255 0 255) ;
}


void DrawCloud:
0$ i$999$4: DrawDot3d float(cloud_x[i]) float(cloud_y[i]) float(cloud_z[i]) float(cloud_r[i]) cloud_color[i] ;;

void DrawCloud2:
0$ i$999$4: DrawAAWireCube float(cloud_x[i]) float(cloud_y[i]) float(cloud_z[i]) float(cloud_r[i]) cloud_color[i] ;;

void DrawCloud22:
0$ i$999$4: DrawAACube float(cloud2_x[i]) float(cloud2_y[i]) float(cloud2_z[i]) float(cloud2_r[i]) cloud2_color[i] ;;


void DeawLines:
0$ j$995$4: k = j+4, DrawLine3d float(cloud_x[j]) float(cloud_y[j]) float(cloud_z[j]) float(cloud_x[k]) float(cloud_y[k]) float(cloud_z[k]) 0xaaaa77 ;;


// int initialised = 0
void Initialise { initialised?=0: SetupLight, SetupCloud, SetupCloud2, initialised = 1; }


void RunFrame int advance
{
Initialise, ClearFrameData 0x666666
// SetupLights_3moving
// int f = frame_number


DrawLine3d 100.0 100.0 0.0 100.0 -100.0 0.0 0xffffff
DrawLine3d 100.0 -100.0 0.0 -100.0 -100.0 0.0 0xffffff
DrawLine3d -100.0 -100.0 0.0 -100.0 100.0 0.0 0xffffff
DrawLine3d -100.0 100.0 0.0 100.0 100.0 0.0 0xffffff

DrawDot3d 0.0 0.0 100.0 20.0 0x557788
DrawDot3d 0.0 0.0 150.0 30.0 0x557722
DrawDot3d 0.0 0.0 -100.0 10.0 0xaa7788

DrawCloud, // DrawCloud2,
DrawCloud22
DeawLines


}


void ProcessMouseMove mouse_x mouse_y { }
void ProcessKeyDown key {
}
void OnResize { RunFrame }


void main
{
RegisterMouseMove &ProcessMouseMove
RegisterKeyDown &ProcessKeyDown
RegisterOnResize &OnResize
RegisterRunFrame &RunFrame
SetSleepValue 5, SetScaleOnResize 0, Set3dDrawingMode 1
SetupWindow3 " Example Green Fire App compiled by Furia \x00" 20 20 700 500 700 500
}



Ben

unread,
May 15, 2022, 7:49:13 PM5/15/22
to
fir <profes...@gmail.com> writes:

> when i discovered it dont work with O3 i dont wnat to much spoend
> time on it now, one need to prioritize work and there are more
> important things

That may be a wasted opportunity. I've found that when things go wrong
with high-levels of optimisation, 9 times out of 10 it's a opportunity to
find a bug that's currently not showing up in testing yet.

--
Ben.

fir

unread,
May 15, 2022, 7:57:22 PM5/15/22
to
niedziela, 15 maja 2022 o 23:30:44 UTC+2 fir napisał(a):
this loop form 0$ i$999$4 is a stub coz i got : (which i guess more fits) used (to break on log line after foo: and things like that) ..i changed to break on ":"+whitespace so now loop is

10:100{ something} //loop on 10 to 100 inclusively (on i)
:100 { something } //loop on 0 to 100 (on i)
k:10:200:10 {} //from 10 to 200 step 10 by k

noit saying this is good as loop is importan thing and such minimal form is not so visible but for now i go for syntactical simplicity

fir

unread,
May 15, 2022, 8:06:06 PM5/15/22
to
maybe but i trade total simplicity and mess for moving forward ..need some results..
good that anybody writes on this gropu though... sad bartc is inactive as i said i sometemes
would say he writes to much about the same things but bow he writes to less and at least this user was able to talk on point (and im geting more and more tired and soon will wanish... writing thic compiler is kinda fun and pain together..esp im not the younger.. im old and nearly zero work done (sometimes last times i was writing i did 2% of what i need to do when being 45 (sleep ^ yawn))

fir

unread,
May 15, 2022, 8:18:26 PM5/15/22
to
poniedziałek, 16 maja 2022 o 01:57:22 UTC+2 fir napisał(a):
somewjat later i will probably do an option to put this for loop not only at the begining of
log line, i mean to be able to use

tab[10:18] = 0;

same as
10:18: tab[i] = 0;

fir

unread,
May 17, 2022, 6:37:58 AM5/17/22
to
i probably should implement in native support for chunks, the question is how to name it

simple static arrays i wil made like

int10000 tab1
float2048 tab2

so dynamic maybe

ints tab
floats tab

so chunk will be chars

wonder if then i could name dynamic chunk of 'chars' like charss? (in present naming chars is chunk and charss is chunks)

probably i will make thich charss or maybe will add alternative name for chars as text (and texts) or something like this

im a bit tired though

fir

unread,
May 17, 2022, 7:10:21 AM5/17/22
to
wtorek, 17 maja 2022 o 12:37:58 UTC+2 fir napisał(a):
> i probably should implement in native support for chunks, the question is how to name it
>
> simple static arrays i wil made like
>
> int10000 tab1
> float2048 tab2
>
> so dynamic maybe
>
> ints tab
> floats tab
>
> so chunk will be chars
>
> wonder if then i could name dynamic chunk of 'chars' like charss? (in present naming chars is chunk and charss is chunks)
>
> probably i will make thich charss or maybe will add alternative name for chars as text (and texts) or something like this
>
> im a bit tired though

floats[30] could be added as floats with size set to 30 initially;

what i need to generate

floats x
?

when i generate int[100] z
i only need to emit
FlushOutAsm("\n .bss %.*s: %d ", ChunkLength(a4) , a4.beg, value );

wait a minute i should mull it by 4, seems i got bug in my code, though it still worked?
seems so
to make dynamic ints z (or ints[333]) whet i need
need to emit "?? z: 0p" (?? is a shortcut for .data which better looks in asembler source imo)

and emit


push 333
push z
call("msvcrt.dll"->realloc")
pop edx
pop edx

in some init_runtime routine which i need to cal before program starts
doesnt seem to hard (i dont even need to put import msvcrt.dll in my asm
as my asm scans the asm code and collect it itself)

then i need to give reckognizing routines for z.size = 199 , z.size*=2 and things like that (emiting realoc calls) and z.add(88) which resizes one and adds at the end (such realloc based array makes this kind natural list and this add method is very usable, like in code when collecting somethin, used itself in compiler)

a bit sad i feel like emeritus again







fir

unread,
May 17, 2022, 8:45:45 AM5/17/22
to
i must say i very get liked this _Add() pattern (based on realooc seed) in C,
this simplifies typing a lot

like
///////////////////////////
ints spheres

for(int i=0; i<100; i++)
spheres.add(i);

//////////
instedad of

//////////////////////
const int spheres_max = 100;
int spheres[spheres_max ];

for(int i=0; i<100; i++)
spheres[i] = i;
//////////

the add form incomparably better

fir

unread,
May 17, 2022, 6:52:31 PM5/17/22
to
ok i implemented basics of it and it seem to work

may show pieces of implementation as its maybe interesting
- showing its wuite easy

//catch definition

if(atoms_len == 2) // ints tab
if( CCS(a0, "ints") )
if( CCL(a1) )
{
int initial_value = 0;
FlushOutAsm("\n .data %.*s: %dp ", ChunkLength(a1) , a1.beg, 0 );
FlushOutAsm("\n .data %.*s_size: %di ", ChunkLength(a1) , a1.beg, initial_value );

RegisterDynamicSeed(a1, initial_value);
return 'arr';
}

//catch size assign

if(atoms_len == 5) // x.size=22
if( CCL(a0) )
if( CCS(a1, ".") )
if( CCS(a2, "size") )
if( CCS(a3, "=") )
if( CCI(a4) )
{
int dynamic = CheckIfThisIsDynamicSeed(a0);
if(dynamic)
{
int size = (int) ConvertChunk2Int(a4);
EmitResize(a0, size);
return 'arr';

}
else
{
ERROR_EXIT("cant resize tis, its not dynamic seed");
}

}


//catch add

if(atoms_len == 6) // x.add(22)
if( CCL(a0) )
if( CCS(a1, ".") )
if( CCS(a2, "add") )
if( CCS(a3, "(") )
if( CCI(a4) )
if( CCS(a5, ")") )
{
int dynamic = CheckIfThisIsDynamicSeed(a0);
if(dynamic)
{
int value = (int) ConvertChunk2Int(a4);

EmitAdd2DynamicArray(a0, value);
return 'arr';

}
else
{
ERROR_EXIT("cant add to tis, its not dynamic seed");
}

}

//function used

//register and find seeds

struct DynamicSeedList { chunk name; int value;};
static DynamicSeedList* dynamic_seed_list = NULL;
static int dynamic_seed_list_size = 0;

void dynamic_seed_list_AddOne(chunk name, int value)
{
dynamic_seed_list_size++;
dynamic_seed_list = (DynamicSeedList*) realloc(dynamic_seed_list, dynamic_seed_list_size * sizeof(DynamicSeedList) );
dynamic_seed_list[dynamic_seed_list_size-1] = {name, value};
return ;
}

int CheckIfThisIsDynamicSeed(chunk name)
{
for(int i=0; i< dynamic_seed_list_size; i++)
{
if(ChunksAreEqual(dynamic_seed_list[i].name, name))
return 1;
}
return 0;

}


void RegisterDynamicSeed(chunk name, int initial_value)
{
dynamic_seed_list_AddOne( name, initial_value);

}

//real asembler emiters

void EmitResize(chunk name, int size)
{
FlushOutAsm("\n push %d", size );
FlushOutAsmChunkPE("\n push (", name, ") ");
FlushOutAsm("\n call (\"msvcrt.dll\"->realloc)");
FlushOutAsmChunkPE("\n mov (", name, ") eax ");
FlushOutAsm("\n pop edx");
FlushOutAsm("\n pop edx");
FlushOutAsmChunkPE("\n mov (", name, ") eax ");
FlushOutAsm("\n mov eax %d", size);
FlushOutAsmChunkPE("\n mov (", name, "_size) eax ");
}
void EmitAdd2DynamicArray(chunk name, int value)
{
//inc size by one
FlushOutAsmChunkPE("\n mov eax (", name, "_size) ");

FlushOutAsm("\n push eax"); //use to assign

FlushOutAsm("\n add eax 4 ");
FlushOutAsmChunkPE("\n mov (", name, "_size) eax ");
//reallock
FlushOutAsm("\n push eax");
FlushOutAsmChunkPE("\n push (", name, ") ");
FlushOutAsm("\n call (\"msvcrt.dll\"->realloc)");
FlushOutAsmChunkPE("\n mov (", name, ") eax ");
FlushOutAsm("\n pop edx");
FlushOutAsm("\n pop edx");
//add value
FlushOutAsm("\n pop ebx ");
FlushOutAsmChunkPE("\n mov eax (", name, ") ");
FlushOutAsm("\n add eax ebx");
FlushOutAsm("\n mov (eax) %d ", value);

}

//emit runtime startup
void EmitDynamicSeedArraysStartups()
{

FlushOutAsm("\n setup_dynamic_arrays:");

for(int i=0; i< dynamic_seed_list_size; i++)
{
chunk name = dynamic_seed_list[i].name;
int value = dynamic_seed_list[i].value;

EmitResize(name, value);

}
FlushOutAsm("\n ret");

}



the compiled code test

void TestNewArray
{
ints array

1:5
array.add(77);

0:7
printf "\x0a %d \x00" array[i*4];

array.size = 29
printf "\x0a %d \x00" array_size


}
//console output


77
77
77
77
77
3211367
262191
10158328
29

Rosario19

unread,
May 18, 2022, 2:43:36 AM5/18/22
to
On Fri, 13 May 2022 18:12:35 -0700 (PDT), fir wrote:

if the parameter 0 1 2 3 4 5 6 are in the function defined as double
example
DrawLine3d(double, double, double ecc, int)
the assembly code is not ok because one double is 2 ints here

>i write my compiler and i got some rutine
>
>RunFrame
>{
>
> DrawLine3d 20.0 30.0 40.0 100.0 0.0 400.0 0xaaaa77
> DrawLine3d 22.0 30.0 43.0 130.0 0.0 400.0 0xaaaa77
> DrawLine3d 29.0 30.0 42.0 130.0 0.0 400.0 0xaaaa77
>
>}
>
>I got 3 routines that draw lines there and it worx
>
>the problem is ehen i putt those routines in separate call like
>
>foo
>{
> DrawLine3d 20.0 30.0 40.0 100.0 0.0 400.0 0xaaaa77
> DrawLine3d 22.0 30.0 43.0 130.0 0.0 400.0 0xaaaa77
> DrawLine3d 29.0 30.0 42.0 130.0 0.0 400.0 0xaaaa77
>}
>
>and call this foo from DrawFrame then it crashes though
>ime the assembly is the same (rxcep this call and ret)

fir

unread,
May 18, 2022, 2:49:42 AM5/18/22
to
środa, 18 maja 2022 o 08:43:36 UTC+2 Rosario19 napisał(a):
> On Fri, 13 May 2022 18:12:35 -0700 (PDT), fir wrote:
>
> if the parameter 0 1 2 3 4 5 6 are in the function defined as double
> example
> DrawLine3d(double, double, double ecc, int)
> the assembly code is not ok because one double is 2 ints here
> >i write my compiler and i got some rutine
> >
they are float

i made demo showing that one can add balls in space when pressing space

hovever i made a bit of mess with some thingand as to compiler only crazy elements
of syntax work (something like shattered glass),
hovever the demo itself looking good imo tnx to my rasterizer - and if someone would
place balls the ball is placed in the point the camera has a point of rotation-around so
to place another bal not only rotate but move the camera (with left or right button or
holding left shift and moviung mouse - and when mouse cursor is detatched use mouse wheel down to attach again)

https://filebin.net/8cc5ik74wr89q0qu


fir

unread,
May 20, 2022, 9:04:52 PM5/20/22
to
cleanded the syntax a bit, like

void SetupLight
SetPointLight 0 1 -1100.0 0.0 0.0 7000.0 50000.0 0.30 1.9 1.3 1.3 0.01 0.01 0.01 0.18 1.1 1.1 1.1 0.01 0.01 0.01
SetPointLight 1 3 1100.0 500.0 500.0 7000.0 50000.0 0.30 1.3 1.9 1.3 0.01 0.01 0.01 0.18 1.1 1.1 1.1 0.01 0.01 0.01
SetPointLight 2 3 0.0 -1500.0 -500.0 7000.0 50000.0 0.30 1.3 1.3 1.9 0.01 0.01 0.01 0.18 1.1 1.1 1.1 0.01 0.01 0.01 ;
void SetupCloud
{
ints cloud_x, ints cloud_y, ints cloud_z, ints cloud_r, ints cloud_color
1:200: cloud_x.add(rand2 200 1900),
cloud_y.add(rand2 200 1500)
cloud_z.add(rand2 0 1300)
cloud_r.add(rand2 10 30)
cloud_color.add(RandColor 0 255 0 255 0 255) ;
}
void SetupCloud2
{
ints cloud2_x, ints cloud2_y, ints cloud2_z, ints cloud2_r, ints cloud2_color
1:500: cloud2_x.add(rand2 -1200 1500)
cloud2_y.add(rand2 -1200 -1500)
cloud2_z.add(rand2 0 -1300)
cloud2_r.add(rand2 10 20)
cloud2_color.add(RandColor 0 255 0 255 0 255) ;
}
void Initialise {initialised?=0: SetupLight, SetupCloud, SetupCloud2, initialised = 1; }


void DrawCloud1: 0:199: DrawDot3d float(cloud_x[i*4]) float(cloud_y[i*4]) float(cloud_z[i*4]) float(cloud_r[i*4]) cloud_color[i*4] ;;
void DrawCloud11: 0:199: DrawAAWireCube float(cloud_x[i*4]) float(cloud_y[i*4]) float(cloud_z[i*4]) float(cloud_r[i*4]) 0xaaaa77 ;;
void DrawCloud12: 0:199: DrawAAWireCube float(cloud_x[i*4]) float(cloud_y[i*4]) float(cloud_z[i*4]) float(cloud_r[i*4]*2) 0xaaaa77 ;;
void DrawCloud2: 0:499: DrawAACube float(cloud2_x[i*4]) float(cloud2_y[i*4]) float(cloud2_z[i*4]) float(cloud2_r[i*4]) cloud2_color[i*4] ;;
void DeawLines: 0:198: DrawLine3d float(cloud_x[i*4]) float(cloud_y[i*4]) float(cloud_z[i*4]) float(cloud_x[i*4+4]) float(cloud_y[i*4+4]) float(cloud_z[i*4+4]) 0xaaaa77 ;;
void RunFrame int advance
{
Initialise, ClearFrameData 0x666666
DrawLine3d 100.0 100.0 0.0 100.0 -100.0 0.0 0xffffff
DrawLine3d 100.0 -100.0 0.0 -100.0 -100.0 0.0 0xffffff
DrawLine3d -100.0 -100.0 0.0 -100.0 100.0 0.0 0xffffff
DrawLine3d -100.0 100.0 0.0 100.0 100.0 0.0 0xffffff
DrawDot3d 0.0 0.0 100.0 20.0 0x557788
DrawDot3d 0.0 0.0 150.0 30.0 0x557722
DrawDot3d 0.0 0.0 -100.0 10.0 0xaa7788
DrawCloud1,
DrawCloud2,
DrawCloud11,
DrawCloud12
DrawDotsBag
// DrawSomeText2F 0xa99999 0x666666 10 20 "hello, this is example program compiled by fir's furia compiler \x00"
DrawSomeText2F 0xcccccc 0x666666 10 20 "hello, this is example program compiled by fir's furia compiler \x00"
// DeawLines
// DrawTextByBalls "hello\x00" 0 0 0x999999
// DrawCubesCubeGeo
}
void ProcessMouseMove mouse_x mouse_y { }
void ProcessKeyDown key {
key?=' ' {FireDotFromCamera 0.0 0.0 10000 20 0x11aacc }
key?='A' {FireDotFromCamera 1.0 0.0 10000 20 0xffffff }
key?='D' {DeleteDotFromBag cameraPos[0] cameraPos[4] cameraPos[8] 10.0 }
key?='X' {}
key?='Z' {}
}
void OnResize { RunFrame }
void main
{
RegisterMouseMove &ProcessMouseMove
RegisterKeyDown &ProcessKeyDown
RegisterOnResize &OnResize
RegisterRunFrame &RunFrame
SetSleepValue 5, SetScaleOnResize 0, Set3dDrawingMode 1
SetupWindow3 " Example Green Fire App compiled by Furia \x00" 20 20 700 500 700 500
}



https://filebin.net/qtu4djk1eizl222q


thouhj i wouldnt say i internally wrote itwell, its a mess, also very uneffective in compiling, but i dont know compiler theory
some may run a demo hovever i builtin a test for memory bandwidth of a machuna thet runs it (press f2 then pres f1 to see the measurments

on my old machine for example for-loop memory bandwidth is about 6-7 GB/s where msvcrt memset is 12 GB.. my freind colegue on more new and more xpensive machine has 13 GB on loop and 54 GB on memset.. this big difference seems weird to me as i once was writing memsets in assembly/vector sse and afair dont noticed speedups then like see wouldnf couse more mem bandwith only improved arithmetic part.. do things has changed or what?
0 new messages