Click here to Skip to main content
15,867,141 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 367.4K   2.7K   153  
A new general purpose language that aims to be fast, high level and simple to use.
	format MS COFF
	public _LongMod				; ascall
	public _ULongMod			; ascall
	
section ".code" code readable executable

;------------------------------------------------
_LongMod:
	test edx, 80000000h
	jz _LongMod_1
	neg eax
	adc edx, 0
	neg edx
	push dword[esp + 8]
	push dword[esp + 8]
	call _ULongMod
	neg eax
	adc edx, 0
	neg edx
	ret 8
_LongMod_1:
	push dword[esp + 8]
	push dword[esp + 8]
	call _ULongMod
	ret 8
	
;------------------------------------------------
_ULongMod:
	cmp dword[esp + 8], 0
	jne _ULongMod_Hard
	mov ecx, eax
	mov eax, edx
	xor edx, edx
	div dword[esp + 4]
	mov eax, ecx
	div dword[esp + 4]
	mov eax, edx
	xor edx, edx
	ret 8
	
_ULongMod_Hard:
	push ebx
	push esi
	push edi
	
_ULongMod_Hard_3:
	mov esi, dword[esp + 16]
	mov edi, dword[esp + 20]
	
	cmp edx, edi
	ja _ULongMod_Hard_13
	jb _ULongMod_Hard_2
	cmp eax, esi
	jbe _ULongMod_Hard_2

_ULongMod_Hard_13:
	;------------------
	; osztand�
	;------------------
	cmp edx, 0
	je _ULongMod_Hard_4
	bsr ebx, edi
	add ebx, 32
	jmp _ULongMod_Hard_5
_ULongMod_Hard_4:
	bsr ebx, eax
_ULongMod_Hard_5:
	mov ecx, ebx

	;------------------
	; oszt�
	;------------------
	cmp edi, 0
	je _ULongMod_Hard_6
	bsr ebx, edi
	add ebx, 32
	jmp _ULongMod_Hard_7
_ULongMod_Hard_6:
	bsr ebx, esi
_ULongMod_Hard_7:
	sub ecx, ebx
	
	;------------------
	; shift left
	;------------------
	cmp cl, 32
	ja _ULongMod_Hard_8
	shld edi, esi, cl
	shl esi, cl
	jmp _ULongMod_Hard_9
_ULongMod_Hard_8:
	and cl, 31
	xor edi, edi
	shl esi, cl
	
	;------------------
	; shift right 1, ha oszt� > osztand�
	;------------------
_ULongMod_Hard_9:
	cmp edi, edx
	ja _ULongMod_Hard_10
	jb _ULongMod_Hard_11
	cmp esi, eax
	jbe _ULongMod_Hard_11
_ULongMod_Hard_10:
	shrd esi, edi, 1
	shr edi, 1
	dec cl
_ULongMod_Hard_11:

	;------------------
	; osztand� - tmp oszt�
	;------------------
	sub eax, esi
	sbb edx, edi
	
_ULongMod_Hard_2:
	pop edi
	pop esi
	pop ebx
	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