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

;------------------------------------------------
_LongDiv:
	push ebx
	xor bx, bx
	test edx, 80000000h
	jz _LongDiv_1
	mov bl, 1
	neg eax
	adc edx, 0
	neg edx
_LongDiv_1:
	test dword[esp + 12], 80000000h
	jz _LongDiv_2
	mov bh, 1
	neg dword[esp + 8]
	adc dword[esp + 12], 0
	neg dword[esp + 12]
_LongDiv_2:
	push dword[esp + 12]
	push dword[esp + 12]
	call _ULongDiv
	xor bl, bh
	jz _LongDiv_3
	neg eax
	adc edx, 0
	neg edx
_LongDiv_3:
	pop ebx
	ret 8
	
;------------------------------------------------
_ULongDiv:
	push ebx
	cmp dword[esp + 12], 0
	jne _ULongDiv_Hard
	mov ecx, eax
	mov eax, edx
	xor edx, edx
	div dword[esp + 8]
	mov ebx, eax
	mov eax, ecx
	div dword[esp + 8]
	mov edx, ebx
	pop ebx
	ret 8
	
_ULongDiv_Hard:
	push esi
	push edi
	sub esp, 8
	mov dword[esp], eax
	mov dword[esp + 4], edx
	xor eax, eax
	xor edx, edx
	
_ULongDiv_Hard_3:
	mov esi, dword[esp + 24]
	mov edi, dword[esp + 28]
	
	cmp dword[esp + 4], edi
	ja _ULongDiv_Hard_13
	jb _ULongDiv_Hard_2
	cmp dword[esp], esi
	jbe _ULongDiv_Hard_2

_ULongDiv_Hard_13:
	;------------------
	; osztand�
	;------------------
	cmp dword[esp + 4], 0
	je _ULongDiv_Hard_4
	bsr ebx, dword[esp + 4]
	add ebx, 32
	jmp _ULongDiv_Hard_5
_ULongDiv_Hard_4:
	bsr ebx, dword[esp]
_ULongDiv_Hard_5:
	mov ecx, ebx

	;------------------
	; oszt�
	;------------------
	cmp edi, 0
	je _ULongDiv_Hard_6
	bsr ebx, edi
	add ebx, 32
	jmp _ULongDiv_Hard_7
_ULongDiv_Hard_6:
	bsr ebx, esi
_ULongDiv_Hard_7:
	sub ecx, ebx
	
	;------------------
	; shift left
	;------------------
	cmp cl, 32
	ja _ULongDiv_Hard_8
	shld edi, esi, cl
	shl esi, cl
	jmp _ULongDiv_Hard_9
_ULongDiv_Hard_8:
	and cl, 31
	xor edi, edi
	shl esi, cl
	
	;------------------
	; shift right 1, ha oszt� > osztand�
	;------------------
_ULongDiv_Hard_9:
	cmp edi, dword[esp + 4]
	ja _ULongDiv_Hard_10
	jb _ULongDiv_Hard_11
	cmp esi, dword[esp]
	jbe _ULongDiv_Hard_11
_ULongDiv_Hard_10:
	shrd esi, edi, 1
	shr edi, 1
	dec cl
_ULongDiv_Hard_11:

	;------------------
	; osztand� - tmp oszt�
	;------------------
	sub dword[esp], esi
	sbb dword[esp + 4], edi
	
	cmp cl, 32
	ja _ULongDiv_Hard_12
	bts eax, ecx
	jmp _ULongDiv_Hard_3
_ULongDiv_Hard_12:
	and cl, 31
	bts edx, ecx
	jmp _ULongDiv_Hard_3
	
_ULongDiv_Hard_2:
	add esp, 8
	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