Click here to Skip to main content
15,885,365 members
Articles / High Performance Computing / Vectorization

Bird Programming Language: Part 1

Rate me:
Please Sign up or sign in to vote.
4.92/5 (129 votes)
1 Jan 2013GPL312 min read 376.4K   2.7K   153  
A new general purpose language that aims to be fast, high level and simple to use.
Strict

Framework Brl.StandardIO
Import BRL.Retro
Import "Long.s"
Import "LongDiv.s"
Import "LongMod.s"

Extern "C"
Function CDeclLongDiv:Long(A:Long, B:Long)
Function CDeclLongMod:Long(A:Long, B:Long)
EndExtern

Function GetRandLong:Long()
	Local A:Long = Rand($7FFFFFFF)
	Local B:Long = Rand($7FFFFFFF)
	Return (A Shl 32) | B
	Return A
EndFunction

SeedRnd MilliSecs()
'CDeclLongDiv(30488454026493952:Long, 21931888646029312:Long)
'CDeclLongDiv(41851880996864:Long, 133852576088064:Long)
'Print CDeclLongDiv(100000000000000:Long, 1000000000000:Long)
'Print CDeclLongMod(234, 100)

Rem start
Local Count = 0
For Local i = 0 Until 10000
	Local A:Long = GetRandLong()
	Local B:Long = GetRandLong()
	
	If A Mod B <> CDeclLongMod(A, B)
		'Print A + " \ " + B
		Count:+1
	EndIf
Next
Print Count
EndRem

'Rem start
Global Count = 10000000
Global Arr:Long[Count]

For Local i = 0 To Count
	Arr[i] = GetRandLong()
Next

Local ms = MilliSecs()
For Local i = 0 Until Count
	StdDiv Arr[i], Arr[i + 1]
Next
Local mtime = MilliSecs() - ms
Print mtime

ms = MilliSecs()
For Local i = 0 Until Count
	DivTest Arr[i], Arr[i + 1]
Next
Local ntime = MilliSecs() - ms
Print ntime 
Print Float(ntime) / Float(mtime) * 100# - 100#
'End Rem

Function StdDiv(A:Long, B:Long)
	Local Ret:Long
	Ret = A Mod B
	Ret = A Mod B
	Ret = A Mod B
	Ret = A Mod B
	Ret = A Mod B
	Ret = A Mod B
	Ret = A Mod B
	Ret = A Mod B
	Ret = A Mod B
	Ret = A Mod B
	Ret = A Mod B
	Ret = A Mod B
EndFunction

Function DivTest(A:Long, B:Long)
	Local Ret:Long
	Ret = CDeclLongMod(A, B)
	Ret = CDeclLongMod(A, B)
	Ret = CDeclLongMod(A, B)
	Ret = CDeclLongMod(A, B)
	Ret = CDeclLongMod(A, B)
	Ret = CDeclLongMod(A, B)
	Ret = CDeclLongMod(A, B)
	Ret = CDeclLongMod(A, B)
	Ret = CDeclLongMod(A, B)
	Ret = CDeclLongMod(A, B)
	Ret = CDeclLongMod(A, B)
	Ret = CDeclLongMod(A, B)
EndFunction

Function PrintOk()
	Print "OK"
EndFunction

Function PrintLong(A:Long)
	Print A
	Delay 1000
EndFunction 

Function PrintDatas(A:Long, B:Long, i)
	Print Bin2(A)
	Print Bin2(B)
	Print i
	Print
	Delay 1000
EndFunction

Function Bin2$(A:Long)
	Local p:Int Ptr = Int Ptr(Varptr A)
	Return Bin(p[1]) + " " + Bin(p[0])
EndFunction

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)


Written By
Software Developer
Hungary Hungary
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions