Click here to Skip to main content
15,893,622 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 383.1K   2.7K   153  
A new general purpose language that aims to be fast, high level and simple to use.
	format MS COFF
	public _ULongToFloat		; ascall
	public _LongShiftLeft		; ascall + cl
	public _LongShiftRight		; ascall + cl
	public _ULongShiftRight		; ascall + cl
	public _LongMul			; ascall

section ".code" code readable executable

;------------------------------------------------
_LongShiftRight:
	cmp cl, 64
	jae _LongShiftRight_1
	cmp cl, 32
	jbe _LongShiftRight_2
	and cl, 31
	mov eax, edx
	sar edx, 31
	sar eax, cl
	ret
_LongShiftRight_2:
	shrd eax, edx, cl
	sar edx, cl
	ret
_LongShiftRight_1:
	sar edx, 31
	mov eax, edx
	ret
	
	
;------------------------------------------------
_ULongShiftRight:
	cmp cl, 64
	jae _ULongShiftRight_1
	cmp cl, 32
	jbe _ULongShiftRight_2
	and cl, 31
	mov eax, edx
	xor edx, edx
	shr eax, cl
	ret
_ULongShiftRight_2:
	shrd eax, edx, cl
	shr edx, cl
	ret
_ULongShiftRight_1:
	xor edx, edx
	xor eax, eax
	ret
	
	
;------------------------------------------------
_LongShiftLeft:
	cmp cl, 64
	jae _LongShiftLeft_1
	cmp cl, 32
	jbe _LongShiftLeft_2
	and cl, 31
	mov edx, eax
	xor eax, eax
	shl edx, cl
	ret
_LongShiftLeft_2:
	shld edx, eax, cl
	shl eax, cl
	ret
_LongShiftLeft_1:
	xor edx, edx
	xor eax, eax
	ret
	
;------------------------------------------------
_ULongToFloat:
	mov eax, dword[esp + 8]
	and dword[esp + 8], 0x7FFFFFFF
	fild qword[esp + 4]
	and eax, 0x80000000
	mov dword[esp + 4], 0
	mov dword[esp + 8], eax
	fild qword[esp + 4]
	fchs
	faddp
	ret 8
	
	
;------------------------------------------------
_LongMul:
	mov eax, dword[esp + 4]
	mov edx, dword[esp + 8]
	push dword[esp + 12]
	push dword[esp + 16]
	call _LongMul_AsCall
	ret 16

_LongMul_AsCall:
	mov ecx, edx
	or ecx, dword[esp + 8]
	jnz _LongMul_1
	mul dword[esp + 4]
	ret 8
_LongMul_1:
	mov dword[esp - 4], edx
	mul dword[esp + 4]
	mov dword[esp - 8], eax
	mov ecx, edx

	mov eax, dword[esp - 4]
	mul dword[esp + 8]
	mov edx, eax
	add edx, ecx
	mov eax, dword[esp - 8]
	ret 8
	
	

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