A compiler for my own peculiar programming language that resembles Visual Basic, but has support for lower-level features such as pointers. It uses another project of mine, NIR, to convert code into an intermediate representation, which is optimized and then dealt with by individual backends.
- nasm (for assembling x64 code)
- gcc (for linking the object files together)
firebasic <input files | flags> <output file>
Flags: /win (passes -mwindows to linker)
' Random number generator in Firebasic' nokiiaa, 2022ConstNULLAsVoid*=0DeclareFunctionLib"user32.dll"MessageBoxA(hWndasVoid*,lpTextasChar*,lpCaptionasChar*,uTypeasUInteger)AsIntegerFunctionRand(stateAsUInteger*)AsUIntegerDimxAsUInteger=*statex=xXor(x<<13)x=xXor(x>>17)x=xXor(x<<5)*state=xreturnxEndFunctionSubItoa(nAsInteger,outputAsChar*)DimdigitsAsInteger=0DimiAsInteger=0DimnumberAsInteger=nWhilenumberdigits+=1number/=10EndWhileoutput(digits)=0Whileni+=1output(digits-i)=nMod10+0x30n/=10EndWhileEndSubFunctionMainAsIntegerDimstateAsUInteger=244DimmessageAsChar*="Your random number: __________."WhileTrueItoa(Rand(&state)Mod1000,message+20)MessageBoxA(NULL,message,"Here it is! (wow)",0)EndWhileReturn0EndFunction