Code: Select all
300 Gas32: -t 2000 -s console
380 Gcc32: -t 2000 -gen gcc -Wc -O2 -s console
360 Gcc64: -t 2000 -gen gcc -Wc -O2 -s console
300 SARG's version
Code: Select all
152 gas
230 gcc32
170 gcc64
115 SARG
Code: Select all
#include "Windows.bi" ' for e.g. MessageBox(0, "Hello string", "Hello title", MB_OK)
#include "crt.bi"
Print String(20, str("x")) ' String(20, "x") chokes if there is a Utf-8 BOM
Print Left("Добро пожаловать", 5); ' combined output of the three rows:
Print Mid("Добро пожаловать", 6, 5); ' Добро пожалоловать
Print Right("Добро пожаловать", 6)
Print "That was a Russian text printed as Utf8"
Dim MyInt As integer=123456
Dim MyHex As integer=&H1234ABCD
Dim MySingle As Single=123.456
Dim MyDouble As Double=123.456
asm
#ifdef __FB_64BIT__
mov rax, [MyHex]
#else
mov eax, [MyHex]
#endif
end asm
' Global variable, visible to main part and procedures
dim shared global as integer=1000
sub foo(number as integer, text as string)
' Local variables visible only inside this procedure
dim a as integer
a = global * 3 + number / 2
print a, text
global = 555
end sub
' Local variables visible only to main part of FB program
dim a as integer
dim s as string
a = 5
a = a * 2
s = "hello"
s += ", there!"
print a, s
foo(123, "foo was here")
foo(-12345, "foo was here again")
print "MyInt=", MyInt
print "MySingle=", MySingle
print "MyDouble=", MyDouble
print
if (sizeof(any ptr))=8 Then
Print "sizes in 64-bit code:"
else
Print "sizes in 32-bit code:"
endif
Print sizeof(single), "single"
Print sizeof(double), "double"
Print sizeof(short), "short"
Print sizeof(integer), "integer"
Print sizeof(integer<32>), "integer<32>"
Print sizeof(integer<64>), "integer<64>"
Print sizeof(long), "long"
Print sizeof(longint), "longint"
Print sizeof(any ptr), "ptr"
Print "compiled "; Time()
sleep