flat assembler
Message board for the users of flat assembler.

flat assembler > High Level Languages > Flat C

Author
Thread Post new topic Reply to topic
bazizmix



Joined: 15 Jan 2016
Posts: 42
This is the next step from FlatC-- (https://board.flatassembler.net/topic.php?t=19700)
and FlatC- (https://board.flatassembler.net/topic.php?t=20153).
Flat assembler used as backend.

Practically identical to standard C.
Additions:
1) Directive #debug - output debug in x64dbg format (dd32 or dd64)
2) Directive #gui - compiling in windows gui format (default is console format)
3) Directive #dll - compiling in DLL format
4) Directive #elf - format ELF for Linux
5) The asm operator may have a list of used variables -
asm (var1, var2, ...) {...} if variables are not used anywhere else.
See in test.c example the strlen() function.
Command line:
Usage: fc.exe [/ 64] [/ debug] <source>
/ 64 generate 64-bit program
/ debug generate debug info for x64dbg
(by default - generate 32-bit program)
Look results from tst.bat and tst64.bat


Description: Flat ะก v.0.022
Download
Filename: FlatC.7z
Filesize: 375.47 KB
Downloaded: 227 Time(s)

Post 26 Nov 2018, 14:19
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 476
Wow ! Output asm code from c code ! Super-druper-amazing !
SSE\AVX support ?
Post 20 Jan 2019, 14:14
View user's profile Send private message Reply with quote
bazizmix



Joined: 15 Jan 2016
Posts: 42
Only SSE for floating point expressions:
addss,addsd,subss,subsd,mulss,mulsd,divss,divsd,pxor,ucomiss,ucomisd,comiss,comisd,
cvtsi2ss,cvtsi2sd,cvtss2sd,cvttss2si,cvtsd2ss,cvttsd2si,movss,movsd .
All other instructions can be included via asm operator
Post 20 Jan 2019, 15:08
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 476
I mean this:
_mm_shuffle_ps like in c++

And support this includes:
<xmmintrin.h> SSE
<emmintrin.h> SSE2
<pmmintrin.h> SSE3
<tmmintrin.h> SSSE3
<smmintrin.h> SSE4.1
<nmmintrin.h> SSE4.2


Last edited by Roman on 20 Jan 2019, 21:40; edited 1 time in total
Post 20 Jan 2019, 15:35
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 476
What is the code size limit ?
Post 20 Jan 2019, 21:39
View user's profile Send private message Reply with quote
bazizmix



Joined: 15 Jan 2016
Posts: 42
Quote:

And support this includes:
<xmmintrin.h> SSE
<emmintrin.h> SSE2
<pmmintrin.h> SSE3
<tmmintrin.h> SSSE3
<smmintrin.h> SSE4.1
<nmmintrin.h> SSE4.2

No
Quote:

What is the code size limit ?

I suppose - limit is the same as in fasm1
Post 21 Jan 2019, 05:44
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 476
I found error.
float x = 55.0f + CamX;
float z = 55.0f - CamZ;
x /= 6.327272f; miss in asm code !
x = x / 6.327272f; miss in asm code !
z /= 6.327272f; miss in asm code !
z = z / 6.327272f; miss in asm code !

This code correct in asm code.
float x = (55.0f + CamX) / 6.327272f;
float z = (55.0f - CamZ) / 6.327272f;


C flat get asm code:
comiss xmm1,dword [xmm4] Fasm error ! Must be comiss xmm1,xmm4 !
Post 19 Jul 2019, 02:04
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 476
C flat get asm code from my example:
comiss xmm0,dword[xmm6] Fasm error ! Must be comiss xmm0,xmm6 !
Code:
// Simple windows gui program
#debug
#gui
#include "kernel32.h"
#include "user32.h"
#include "msvcrt.h"
char *msg = "Hi! I'm the example "
#ifdef _WIN64
"64"
#else
"32"
#endif
"-bit program!";
float floorf (float wx) {
      asm{  roundss xmm1,[wx],9
            movss  [wx],xmm1  }
        return wx;  }
//float lerpA(float a,float b,float t){ return a-(a*t)+(b*t); }
float Lerp(float a,float b,float t){ return (b*t); }
typedef struct vec4 {
    float x;
    float y;
    float z;
    float w;
} vec4;
void main(){
    float fir = 4;
    vec4  dif = {11,2,3,5};
    dif.x += fir;
    dif.y += fir;
    dif.z += fir;
    dif.w += fir;
    float height;
    float LvlSize = 110.0f;
    float CamX = 50.0f;
    float CamZ = 50.0f;
    float x = (55.0f + CamX) / 6.327272f;
    float z = (55.0f - CamZ) / 6.327272f;

    float col = floorf(x);
    float row = floorf(z);

    float A = 1.0f;
    float B = 2.0f;
    float C = 3.0f;
    float D = 4.0f;

    float dx = x - col;
    float dz = z - row;

    if(dz < 1.0f - dx)
     { float uy = B - A;
       float vy = C - A;
       height = A + Lerp(0.0f, uy, dx) + Lerp(0.0f, vy, dz);
      }
    else {
       float uy = C - D;
       float vy = B - D;
       height = D + Lerp(0.0f,uy,1.0f - dx) + Lerp(0.0f, vy, 1.0f - dz);
       }
    char rrt[100];
    char *tname = "result: %1.4f";
    sprintf(rrt,tname,height);
    MessageBox(HWND_DESKTOP,rrt,MB_OK,MB_OK);
    ExitProcess(0);
}
    
Post 19 Jul 2019, 02:10
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2019, Tomasz Grysztar.

Powered by rwasa.