;; B0 OBJECT
;; ELF64 OBJECT FORMAT for Linux

format ELF64
use64


;Register renaming

r0 equ rax
r0d equ eax
r0w equ ax
r0b equ al
r1 equ rbx
r1d equ ebx
r1w equ bx
r1b equ bl
r2 equ rcx
r2d equ ecx
r2w equ cx
r2b equ cl
r3 equ rdx
r3d equ edx
r3w equ dx
r3b equ dl
r4 equ rdi
r4d equ edi
r4w equ di
r4b equ dil
r5 equ rsi
r5d equ esi
r5w equ si
r5b equ sil
r6 equ rbp
r6d equ ebp
r6w equ bp
r6b equ bpl
nr7 equ rsp
r7d equ esp
r7w equ sp
r7b equ spl

fp0 equ ST0
fp1 equ ST1
fp2 equ ST2
fp3 equ ST3
fp4 equ ST4
fp5 equ ST5
fp6 equ ST6
fp7 equ ST7

;Default Macros
macro UTF16_STRING name, [string]
{
common
	name:
local label,label2
	label:
	dw ((label2-label)/2)-3
	dw ((label2-label)/2)-3
	dw string
	label2:
	dw 0
}

macro syscall
{
	int 80h
}

public _B0_u8_2_u32_str
public _B0_memInit
public _B0_u8_2_u32_char
public _B0_u8_2_u16_char
public _B0_echo_test
public _B0_u16_2_u32_char
public _B0_malloc
public _B0_u16_2_u8_char
public _B0_u32_2_u8_str
public _B0_u32_2_u16_str
public _B0_Linux_Adjtimex
public _B0_u8_2_u16_str
public _B0_u16_2_u32_str
public _B0_Linux_Acct
public _B0_echo
public _B0_u32_2_u16_char
public _B0_main as 'main'
public _B0_u16_2_u8_str
public _B0_u32_2_u8_char
public _B0_Linux_Access





;Externs for exit from application
extrn exit


section '.data' writeable


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Linux_Access Function Variables ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

_B0_Linux_Access_filename equ 0
_B0_Linux_Access_mode equ 8

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; End Linux_Access Function Variables ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Linux_Acct Function Variables ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

_B0_Linux_Acct_filename equ 0

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; End Linux_Acct Function Variables ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Linux_Adjtimex Function Variables ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

_B0_Linux_Adjtimex_buffer_ptr equ 0

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; End Linux_Adjtimex Function Variables ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; memInit Function Variables ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; End memInit Function Variables ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; malloc Function Variables ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

_B0_malloc_mem_size equ 0

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; End malloc Function Variables ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; echo Function Variables ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

_B0_echo_ptr_string equ 0
_B0_echo_utf8_string equ 8
_B0_echo_utf8_length equ 264
_B0_echo_string_size equ 272

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; End echo Function Variables ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; echo_test Function Variables ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

_B0_echo_test_ptr_string equ 0

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; End echo_test Function Variables ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; u8_2_u16_char Function Variables ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

_B0_u8_2_u16_char_char equ 0

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; End u8_2_u16_char Function Variables ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; u8_2_u32_char Function Variables ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

_B0_u8_2_u32_char_char equ 0

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; End u8_2_u32_char Function Variables ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; u16_2_u8_char Function Variables ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

_B0_u16_2_u8_char_char equ 0

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; End u16_2_u8_char Function Variables ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; u16_2_u32_char Function Variables ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

_B0_u16_2_u32_char_char equ 0

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; End u16_2_u32_char Function Variables ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; u32_2_u8_char Function Variables ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

_B0_u32_2_u8_char_char equ 0

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; End u32_2_u8_char Function Variables ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; u32_2_u16_char Function Variables ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

_B0_u32_2_u16_char_char equ 0

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; End u32_2_u16_char Function Variables ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; u16_2_u8_str Function Variables ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

_B0_u16_2_u8_str_source_ptr equ 0
_B0_u16_2_u8_str_dest_ptr equ 8

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; End u16_2_u8_str Function Variables ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; u32_2_u8_str Function Variables ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

_B0_u32_2_u8_str_source_ptr equ 0
_B0_u32_2_u8_str_dest_ptr equ 8

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; End u32_2_u8_str Function Variables ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; u8_2_u16_str Function Variables ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

_B0_u8_2_u16_str_source_ptr equ 0
_B0_u8_2_u16_str_dest_ptr equ 8

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; End u8_2_u16_str Function Variables ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; u8_2_u32_str Function Variables ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

_B0_u8_2_u32_str_source_ptr equ 0
_B0_u8_2_u32_str_dest_ptr equ 8

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; End u8_2_u32_str Function Variables ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; u16_2_u32_str Function Variables ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

_B0_u16_2_u32_str_source_ptr equ 0
_B0_u16_2_u32_str_dest_ptr equ 8

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; End u16_2_u32_str Function Variables ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; u32_2_u16_str Function Variables ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

_B0_u32_2_u16_str_source_ptr equ 0
_B0_u32_2_u16_str_dest_ptr equ 8

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; End u32_2_u16_str Function Variables ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

_B0_string dw 0eh,0eh,047h,06ch,06fh,062h,061h,06ch,020h,053h,074h,072h,069h,06eh,067h,0ah,0

_B0_string2 dw 04h,04h,62h,30h,2122h,0ah,0
_B0_string3 dw 08h,08h,0aeh,021h,0263ah,020e0h,02297h,020ach,03a9h,0ah,0

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; main Function Variables ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

UTF16_STRING B0_DynStr0 , 048h,065h,06ch,06ch,06fh,020h,057h,06fh,072h,06ch,064h,020h,066h,072h,06fh,06dh,020h,042h,030h,0ah,0
UTF16_STRING B0_DynStr1 , 055h,054h,046h,020h,054h,065h,073h,074h,03ah,020h,0
UTF16_STRING B0_DynStr2 , 055h,054h,046h,020h,053h,079h,06dh,062h,06fh,06ch,073h,03ah,020h,0

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; End main Function Variables ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


db "EXB0 0.0.13",0


section '.text' executable


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Linux_Access Function Code;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

_B0_Linux_Access:
	push r1
	push r2
	push r3
	push r4
	push r5
	mov r1, [r6+_B0_Linux_Access_filename]
	mov r2, [r6+_B0_Linux_Access_mode]
	mov r0, 33
	syscall
	pop r5
	pop r4
	pop r3
	pop r3
	pop r1
	ret
	mov r0, 0
	ret

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; End Linux_Access Function Code;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Linux_Acct Function Code;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

_B0_Linux_Acct:
	push r1
	push r2
	push r3
	push r4
	push r5
	mov r1, [r6+_B0_Linux_Acct_filename]
	mov r0, 51
	syscall
	pop r5
	pop r4
	pop r3
	pop r3
	pop r1
	ret
	mov r0, 0
	ret

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; End Linux_Acct Function Code;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Linux_Adjtimex Function Code;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

_B0_Linux_Adjtimex:
	push r1
	push r2
	push r3
	push r4
	push r5
	mov r1, [r6+_B0_Linux_Adjtimex_buffer_ptr]
	mov r0, 124
	syscall
	pop r5
	pop r4
	pop r3
	pop r3
	pop r1
	ret
	mov r0, 0
	ret

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; End Linux_Adjtimex Function Code;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; memInit Function Code;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

_B0_memInit:
	mov r2, 16777216
	mov r1, 0000h
	mov r0, 045
	syscall
	mov r15, r0
	mov r1, r0
	add r1, r2
	mov r0, 045
	syscall
	mov r0, r15
	ret
	mov r0, 0
	ret

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; End memInit Function Code;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; malloc Function Code;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

_B0_malloc:
	mov r2, [r6+_B0_malloc_mem_size]
	mov r1, 0000h
	mov r0, 045
	syscall
	mov r1, r0
	add r1, r2
	mov r0, 045
	syscall
	ret
	mov r0, 0
	ret

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; End malloc Function Code;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; echo Function Code;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

_B0_echo:
	push r1
	push r2
	push r3
	mov byte [r6+_B0_echo_utf8_string+0], 0ffh
	mov byte [r6+_B0_echo_utf8_string+1], 0h
	mov r0, [r6+_B0_echo_ptr_string]
	mov r1, r6
	add r1, _B0_echo_utf8_string
	push r0
	push r6
	add r6, 0128h
	mov [r6+00h], r0
	mov [r6+08h], r1
	call _B0_u16_2_u8_str
	pop r6
	mov r3, r0
	pop r0
	mov [r6+_B0_echo_utf8_length], r3 
	mov r0, 4
	mov r1, 1
	mov r2, r6
	add r2, _B0_echo_utf8_string
	add r2, 2
	syscall
	pop r3
	pop r2
	pop r1
	mov r0, 0
	ret

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; End echo Function Code;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; echo_test Function Code;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

_B0_echo_test:
	push r1
	push r2
	push r3
	mov r0, [r6+_B0_echo_test_ptr_string]
	mov r3w, [r0+2]
	sub r3, 2
	shl r3, 1
	mov r2, r0
	add r2, 4
	mov r0, 4
	mov r1, 1
	syscall
	pop r3
	pop r2
	pop r1
	mov r0, 0
	ret

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; End echo_test Function Code;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; u8_2_u16_char Function Code;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

_B0_u8_2_u16_char:
	push r1
	push r15
	mov r0, [r6+_B0_u8_2_u16_char_char]
	mov r1, r0
	and r0, 0ffh
	mov r15, 07fh
	cmp r0, r15
	jbe .B0_END_BLOCK_000011
	push r6
	add r6, 08h
	mov [r6+00h], r1
	call _B0_u8_2_u32_char
	pop r6
	push r6
	add r6, 08h
	mov [r6+00h], r0
	call _B0_u32_2_u16_char
	pop r6
	jmp .B0_END_BLOCK_000012
	.B0_END_BLOCK_000011:
	and r0, 7fh
	.B0_END_BLOCK_000012:
	pop r15
	pop r1
	ret
	mov r0, 0
	ret

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; End u8_2_u16_char Function Code;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; u8_2_u32_char Function Code;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

_B0_u8_2_u32_char:
	push r1
	push r15
	mov r0, [r6+_B0_u8_2_u32_char_char]
	mov r1, r0
	and r0, 0ffh
	mov r15, 07fh
	cmp r0, r15
	jbe .B0_END_BLOCK_000014
	shr r1, 08h
	mov r15, 0dfh
	cmp r0, r15
	jbe .B0_END_BLOCK_000015
	mov r15, 0f0h
	cmp r0, r15
	jbe .B0_END_BLOCK_000016
	mov r15, r1
	and r0, 0fh
	shl r0, 06h
	and r1, 03fh
	or r0, r1
	shr r15, 08h
	mov r1, r15
	and r15, 03fh
	shl r0, 06h
	or r0, r15
	shr r1, 08h
	and r1, 03fh
	or r0, r1
	jmp .B0_END_BLOCK_000017
	.B0_END_BLOCK_000016:
	mov r15, r1
	and r0, 0fh
	shl r0, 06h
	and r1, 03fh
	or r0, r1
	shr r15, 08h
	and r15, 03fh
	shl r0, 06h
	or r0, r15
	.B0_END_BLOCK_000017:
	jmp .B0_END_BLOCK_000018
	.B0_END_BLOCK_000015:
	and r0, 01fh
	shl r0, 06h
	and r1, 03fh
	or r0, r1
	.B0_END_BLOCK_000018:
	jmp .B0_END_BLOCK_000019
	.B0_END_BLOCK_000014:
	and r0, 7fh
	.B0_END_BLOCK_000019:
	pop r15
	pop r1
	ret
	mov r0, 0
	ret

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; End u8_2_u32_char Function Code;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; u16_2_u8_char Function Code;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

_B0_u16_2_u8_char:
	mov r0, [r6+_B0_u16_2_u8_char_char]
	push r6
	add r6, 08h
	mov [r6+00h], r0
	call _B0_u16_2_u32_char
	pop r6
	push r6
	add r6, 08h
	mov [r6+00h], r0
	call _B0_u32_2_u8_char
	pop r6
	ret
	mov r0, 0
	ret

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; End u16_2_u8_char Function Code;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; u16_2_u32_char Function Code;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

_B0_u16_2_u32_char:
	push r1
	push r15
	mov r0, [r6+_B0_u16_2_u32_char_char]
	mov r15, 0d800h
	mov r1, r0
	shr r1, 16
	and r0, 0ffffh
	cmp r0, r15
	jb .B0_END_BLOCK_000022
	mov r15, 0dfffh
	cmp r0, r15
	ja .B0_END_BLOCK_000023
	and r1, 03ffh
	mov r15, r0
	and r15, 3fh
	shl r15, 10
	shr r0, 06h
	and r0, 0fh
	add r0, 1
	shl r0, 16
	or r0, r15
	or r0, r1
	.B0_END_BLOCK_000023:
	.B0_END_BLOCK_000022:
	pop r15
	pop r1
	ret
	mov r0, 0
	ret

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; End u16_2_u32_char Function Code;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; u32_2_u8_char Function Code;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

_B0_u32_2_u8_char:
	push r15
	push r1
	push r2
	mov r0, [r6+_B0_u32_2_u8_char_char]
	mov r15, 10ffffh
	cmp r0, r15
	jbe .B0_END_BLOCK_000025
	mov r0, 0
	ret
	.B0_END_BLOCK_000025:
	mov r15, 0d800h
	cmp r0, r15
	jb .B0_END_BLOCK_000026
	mov r15, 0dfffh
	cmp r0, r15
	ja .B0_END_BLOCK_000027
	xor r0, r0
	.B0_END_BLOCK_000027:
	.B0_END_BLOCK_000026:
	mov r15, 07fh
	cmp r0, r15
	jbe .B0_END_BLOCK_000028
	mov r15, 07ffh
	cmp r0, r15
	ja .B0_END_BLOCK_000029
	mov r1, r0
	shr r1, 6
	and r0, 03fh
	or r1, 0c0h
	or r0, 80h
	shl r0, 8
	or r0, r1
	jmp .B0_END_BLOCK_000030
	.B0_END_BLOCK_000029:
	mov r15, 0ffffh
	cmp r0, r15
	ja .B0_END_BLOCK_000031
	mov r1, r0
	shr r1, 6
	mov r15, r0
	shr r15, 12
	and r0, 3fh
	or r0, 80h
	or r1, 80h
	or r15, 0e0h
	and r1, 0ffh
	and r15, 0ffh
	shl r0, 16
	shl r1, 8
	or r0, r1
	or r0, r15
	jmp .B0_END_BLOCK_000032
	.B0_END_BLOCK_000031:
	mov r1, r0
	shr r1, 6
	mov r15, r0
	shr r15, 12
	mov r2, r0
	shr r2, 18
	and r0, 3fh
	or r0, 80h
	or r1, 80h
	or r15, 80h
	or r2, 0f0h
	and r1, 0ffh
	and r15, 0ffh
	and r2, 0ffh
	shl r0, 24
	shl r1, 16
	shl r15, 8
	or r0, r1
	or r0, r15
	or r0, r2
	.B0_END_BLOCK_000032:
	.B0_END_BLOCK_000030:
	.B0_END_BLOCK_000028:
	pop r2
	pop r1
	pop r15
	ret
	mov r0, 0
	ret

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; End u32_2_u8_char Function Code;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; u32_2_u16_char Function Code;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

_B0_u32_2_u16_char:
	push r1
	push r15
	mov r0, [r6+_B0_u32_2_u16_char_char]
	mov r15, 10000h
	cmp r0, r15
	jb .B0_END_BLOCK_000034
	mov r15, 10ffffh
	cmp r0, r15
	ja .B0_END_BLOCK_000035
	mov r1, r0
	and r1, 03ffh
	or r1, 0dc00h
	mov r15, r1
	shl r15, 16
	shr r0, 10
	mov r1, r0
	shr r1, 6
	and r0, 3fh
	and r1, 1fh
	sub r1, 1
	shl r1, 6
	or r0, r1
	or r0, 0d800h
	or r0, r15
	jmp .B0_END_BLOCK_000036
	.B0_END_BLOCK_000035:
	xor r0, r0
	.B0_END_BLOCK_000036:
	jmp .B0_END_BLOCK_000037
	.B0_END_BLOCK_000034:
	mov r15, 0d800h
	cmp r0, r15
	jb .B0_END_BLOCK_000038
	mov r15, 0dfffh
	cmp r0, r15
	ja .B0_END_BLOCK_000039
	xor r0, r0
	.B0_END_BLOCK_000039:
	.B0_END_BLOCK_000038:
	.B0_END_BLOCK_000037:
	pop r15
	pop r1
	ret
	mov r0, 0
	ret

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; End u32_2_u16_char Function Code;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; u16_2_u8_str Function Code;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

_B0_u16_2_u8_str:
	push r1
	push r2
	push r3
	push r4
	push r5
	push r8
	push r9
	push r15
	mov r5, [r6+_B0_u16_2_u8_str_source_ptr]
	mov r4, [r6+_B0_u16_2_u8_str_dest_ptr]
	xor r8, r8
	xor r9, r9
	xor r3, r3
	xor r2, r2
	mov r2w, [r5+2]
	mov r9b, [r4]
	add r5, 4
	add r4, 2
	.B0_END_BLOCK_000041:
	xor r0, r0
	mov r0w, [r5]
	mov r15, 0d800h
	cmp r0, r15
	jb .B0_END_BLOCK_000042
	mov r15, 0dfffh
	cmp r0, r15
	ja .B0_END_BLOCK_000043
	add r5, 2
	mov r3w, [r5]
	shl r3, 16
	or r0, r3
	sub r2, 1
	.B0_END_BLOCK_000043:
	.B0_END_BLOCK_000042:
	push r6
	add r6, 010h
	mov [r6+00h], r0
	call _B0_u16_2_u8_char
	pop r6
	mov r15, 0ffh
	cmp r0, r15
	ja .B0_END_BLOCK_000044
	mov [r4], r0b
	add r4, 1
	add r8, 1
	jmp .B0_END_BLOCK_000045
	.B0_END_BLOCK_000044:
	mov r15, 0ffffh
	cmp r0, r15
	ja .B0_END_BLOCK_000046
	mov [r4], r0w
	add r4, 2
	add r8, 2
	jmp .B0_END_BLOCK_000047
	.B0_END_BLOCK_000046:
	mov r15, 0ffffffh
	cmp r0, r15
	ja .B0_END_BLOCK_000048
	mov [r4], r0w
	shr r0, 16
	mov [r4+2], r0b
	add r8, 3
	add r4, 3
	jmp .B0_END_BLOCK_000049
	.B0_END_BLOCK_000048:
	mov [r4], r0d
	add r4, 4
	add r8, 4
	.B0_END_BLOCK_000049:
	.B0_END_BLOCK_000047:
	.B0_END_BLOCK_000045:
	cmp r9, r8
	ja .B0_END_BLOCK_000050
	mov r4, [r6+_B0_u16_2_u8_str_dest_ptr]
	mov [r4+1], r8b
	mov r0, r8
	ret
	.B0_END_BLOCK_000050:
	add r5, 2
	sub r2, 1
	test r2, r2
	jne .B0_END_BLOCK_000041
	xor r9, r9
	mov [r4], r9
	mov r4, [r6+_B0_u16_2_u8_str_dest_ptr]
	mov [r4+1], r8b
	mov r0, r8
	pop r15
	pop r9
	pop r8
	pop r5
	pop r4
	pop r3
	pop r2
	pop r1
	ret
	mov r0, 0
	ret

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; End u16_2_u8_str Function Code;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; u32_2_u8_str Function Code;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

_B0_u32_2_u8_str:
	push r1
	push r2
	push r3
	push r4
	push r5
	push r8
	push r9
	push r15
	mov r5, [r6+_B0_u32_2_u8_str_source_ptr]
	mov r4, [r6+_B0_u32_2_u8_str_dest_ptr]
	xor r8, r8
	xor r9, r9
	xor r3, r3
	xor r2, r2
	mov r2w, [r5+4]
	mov r9b, [r4]
	add r5, 8
	add r4, 2
	.B0_END_BLOCK_000052:
	xor r0, r0
	mov r0d, [r5]
	push r6
	add r6, 010h
	mov [r6+00h], r0
	call _B0_u32_2_u8_char
	pop r6
	mov r15, 0ffh
	cmp r0, r15
	ja .B0_END_BLOCK_000053
	mov [r4], r0b
	add r4, 1
	add r8, 1
	jmp .B0_END_BLOCK_000054
	.B0_END_BLOCK_000053:
	mov r15, 0ffffh
	cmp r0, r15
	ja .B0_END_BLOCK_000055
	mov [r4], r0w
	add r4, 2
	add r8, 2
	jmp .B0_END_BLOCK_000056
	.B0_END_BLOCK_000055:
	mov r15, 0ffffffh
	cmp r0, r15
	ja .B0_END_BLOCK_000057
	mov [r4], r0w
	shr r0, 16
	mov [r4+2], r0b
	add r8, 3
	add r4, 3
	jmp .B0_END_BLOCK_000058
	.B0_END_BLOCK_000057:
	mov [r4], r0d
	add r4, 4
	add r8, 4
	.B0_END_BLOCK_000058:
	.B0_END_BLOCK_000056:
	.B0_END_BLOCK_000054:
	cmp r9, r8
	ja .B0_END_BLOCK_000059
	mov r4, [r6+_B0_u32_2_u8_str_dest_ptr]
	mov [r4+2], r8b
	mov r0, r8
	ret
	.B0_END_BLOCK_000059:
	add r5, 4
	sub r2, 1
	test r2, r2
	jne .B0_END_BLOCK_000052
	mov r4, [r6+_B0_u32_2_u8_str_dest_ptr]
	mov [r4+2], r8b
	mov r0, r8
	pop r15
	pop r9
	pop r8
	pop r5
	pop r4
	pop r3
	pop r2
	pop r1
	ret
	mov r0, 0
	ret

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; End u32_2_u8_str Function Code;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; u8_2_u16_str Function Code;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

_B0_u8_2_u16_str:
	push r1
	push r2
	push r3
	push r4
	push r5
	push r8
	push r9
	push r15
	mov r5, [r6+_B0_u8_2_u16_str_source_ptr]
	mov r4, [r6+_B0_u8_2_u16_str_dest_ptr]
	xor r8, r8
	xor r9, r9
	xor r2, r2
	mov r2b, [r5+1]
	mov r9w, [r4]
	cmp r9, r2
	jae .B0_END_BLOCK_000061
	pop r15
	pop r9
	pop r8
	pop r5
	pop r4
	pop r3
	pop r2
	pop r1
	mov r0, 0
	ret
	.B0_END_BLOCK_000061:
	add r5, 2
	add r4, 4
	.B0_END_BLOCK_000062:
	xor r0, r0
	mov r0b, [r5]
	mov r15, 07fh
	cmp r0, r15
	jbe .B0_END_BLOCK_000063
	mov r15, 0dfh
	cmp r0, r15
	jbe .B0_END_BLOCK_000064
	mov r15, 0f0h
	cmp r0, r15
	jbe .B0_END_BLOCK_000065
	xor r1, r1
	mov r1b, [r5+1]
	shl r1, 8
	or r0, r1
	xor r1, r1
	mov r1b, [r5+2]
	shl r1, 16
	or r0, r1
	xor r1, r1
	mov r1b, [r5+3]
	shl r1, 24
	or r0, r1
	add r5, 3
	sub r2, 3
	jmp .B0_END_BLOCK_000066
	.B0_END_BLOCK_000065:
	xor r1, r1
	mov r1b, [r5+1]
	shl r1, 8
	or r0, r1
	xor r1, r1
	mov r1b, [r5+2]
	shl r1, 16
	or r0, r1
	add r5, 2
	sub r2, 2
	.B0_END_BLOCK_000066:
	jmp .B0_END_BLOCK_000067
	.B0_END_BLOCK_000064:
	xor r1, r1
	mov r1b, [r5+1]
	shl r1, 8
	or r0, r1
	add r5, 2
	sub r2, 2
	.B0_END_BLOCK_000067:
	.B0_END_BLOCK_000063:
	push r6
	add r6, 010h
	mov [r6+00h], r0
	call _B0_u8_2_u16_char
	pop r6
	mov r15, 0d800h
	cmp r0, r15
	jb .B0_END_BLOCK_000068
	mov r15, 0dfffh
	cmp r0, r15
	ja .B0_END_BLOCK_000069
	mov [r4], r0d
	add r4, 4
	add r8, 2
	jmp .B0_END_BLOCK_000070
	.B0_END_BLOCK_000069:
	mov [r4], r0w
	add r4, 2
	add r8, 1
	.B0_END_BLOCK_000070:
	jmp .B0_END_BLOCK_000071
	.B0_END_BLOCK_000068:
	mov [r4], r0w
	add r4, 2
	add r8, 1
	.B0_END_BLOCK_000071:
	add r5, 1
	sub r2, 1
	test r2, r2
	jne .B0_END_BLOCK_000062
	mov r4, [r6+_B0_u8_2_u16_str_dest_ptr]
	mov [r4+2], r8w
	mov r0, r8
	pop r15
	pop r9
	pop r8
	pop r5
	pop r4
	pop r3
	pop r2
	pop r1
	ret
	mov r0, 0
	ret

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; End u8_2_u16_str Function Code;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; u8_2_u32_str Function Code;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

_B0_u8_2_u32_str:
	push r1
	push r2
	push r3
	push r4
	push r5
	push r8
	push r9
	push r15
	mov r5, [r6+_B0_u8_2_u32_str_source_ptr]
	mov r4, [r6+_B0_u8_2_u32_str_dest_ptr]
	xor r8, r8
	xor r9, r9
	xor r2, r2
	mov r2b, [r5+1]
	mov r9w, [r4]
	cmp r9, r2
	jae .B0_END_BLOCK_000073
	pop r15
	pop r9
	pop r8
	pop r5
	pop r4
	pop r3
	pop r2
	pop r1
	mov r0, 0
	ret
	.B0_END_BLOCK_000073:
	add r5, 2
	add r4, 8
	.B0_END_BLOCK_000074:
	xor r0, r0
	mov r0b, [r5]
	mov r15, 07fh
	cmp r0, r15
	jbe .B0_END_BLOCK_000075
	mov r15, 0dfh
	cmp r0, r15
	jbe .B0_END_BLOCK_000076
	mov r15, 0f0h
	cmp r0, r15
	jbe .B0_END_BLOCK_000077
	xor r1, r1
	mov r1b, [r5+1]
	shl r1, 8
	or r0, r1
	xor r1, r1
	mov r1b, [r5+2]
	shl r1, 16
	or r0, r1
	xor r1, r1
	mov r1b, [r5+3]
	shl r1, 24
	or r0, r1
	add r5, 3
	sub r2, 3
	jmp .B0_END_BLOCK_000078
	.B0_END_BLOCK_000077:
	xor r1, r1
	mov r1b, [r5+1]
	shl r1, 8
	or r0, r1
	xor r1, r1
	mov r1b, [r5+2]
	shl r1, 16
	or r0, r1
	add r5, 2
	sub r2, 2
	.B0_END_BLOCK_000078:
	jmp .B0_END_BLOCK_000079
	.B0_END_BLOCK_000076:
	xor r1, r1
	mov r1b, [r5+1]
	shl r1, 8
	or r0, r1
	add r5, 2
	sub r2, 2
	.B0_END_BLOCK_000079:
	.B0_END_BLOCK_000075:
	push r6
	add r6, 010h
	mov [r6+00h], r0
	call _B0_u8_2_u32_char
	pop r6
	mov [r4], r0d
	add r4, 4
	add r8, 1
	add r5, 1
	sub r2, 1
	test r2, r2
	jne .B0_END_BLOCK_000074
	mov r4, [r6+_B0_u8_2_u32_str_dest_ptr]
	mov [r4+4], r8d
	mov r0, r8
	pop r15
	pop r9
	pop r8
	pop r5
	pop r4
	pop r3
	pop r2
	pop r1
	ret
	mov r0, 0
	ret

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; End u8_2_u32_str Function Code;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; u16_2_u32_str Function Code;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

_B0_u16_2_u32_str:
	push r1
	push r2
	push r3
	push r4
	push r5
	push r8
	push r9
	push r15
	mov r5, [r6+_B0_u16_2_u32_str_source_ptr]
	mov r4, [r6+_B0_u16_2_u32_str_dest_ptr]
	xor r8, r8
	xor r9, r9
	xor r2, r2
	mov r2b, [r5+2]
	mov r9w, [r4]
	cmp r9, r2
	jae .B0_END_BLOCK_000081
	pop r15
	pop r9
	pop r8
	pop r5
	pop r4
	pop r3
	pop r2
	pop r1
	mov r0, 0
	ret
	.B0_END_BLOCK_000081:
	add r5, 2
	add r4, 8
	.B0_END_BLOCK_000082:
	xor r0, r0
	mov r0w, [r5]
	mov r15, 0d800h
	cmp r0, r15
	jb .B0_END_BLOCK_000083
	mov r15, 0dfffh
	cmp r0, r15
	ja .B0_END_BLOCK_000084
	add r5, 2
	mov r3w, [r5]
	shl r3, 16
	or r0, r3
	sub r2, 1
	.B0_END_BLOCK_000084:
	.B0_END_BLOCK_000083:
	push r6
	add r6, 010h
	mov [r6+00h], r0
	call _B0_u16_2_u32_char
	pop r6
	mov [r4], r0d
	add r4, 4
	add r8, 1
	add r5, 2
	sub r2, 1
	test r2, r2
	jne .B0_END_BLOCK_000082
	mov r4, [r6+_B0_u16_2_u32_str_dest_ptr]
	mov [r4+4], r8d
	mov r0, r8
	pop r15
	pop r9
	pop r8
	pop r5
	pop r4
	pop r3
	pop r2
	pop r1
	ret
	mov r0, 0
	ret

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; End u16_2_u32_str Function Code;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; u32_2_u16_str Function Code;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

_B0_u32_2_u16_str:
	push r1
	push r2
	push r3
	push r4
	push r5
	push r8
	push r9
	push r15
	mov r5, [r6+_B0_u32_2_u16_str_source_ptr]
	mov r4, [r6+_B0_u32_2_u16_str_dest_ptr]
	xor r8, r8
	xor r9, r9
	xor r3, r3
	xor r2, r2
	mov r2w, [r5+4]
	mov r9w, [r4]
	add r5, 8
	add r4, 2
	.B0_END_BLOCK_000086:
	xor r0, r0
	mov r0d, [r5]
	push r6
	add r6, 010h
	mov [r6+00h], r0
	call _B0_u32_2_u16_char
	pop r6
	mov r15, 0d800h
	cmp r0, r15
	jb .B0_END_BLOCK_000087
	mov r15, 0dfffh
	cmp r0, r15
	ja .B0_END_BLOCK_000088
	mov [r4], r0d
	add r4, 4
	add r8, 2
	jmp .B0_END_BLOCK_000089
	.B0_END_BLOCK_000088:
	mov [r4], r0w
	add r4, 2
	add r8, 1
	.B0_END_BLOCK_000089:
	jmp .B0_END_BLOCK_000090
	.B0_END_BLOCK_000087:
	mov [r4], r0w
	add r4, 2
	add r8, 1
	.B0_END_BLOCK_000090:
	cmp r9, r8
	ja .B0_END_BLOCK_000091
	mov r4, [r6+_B0_u32_2_u16_str_dest_ptr]
	mov [r4+2], r8w
	mov r0, r8
	ret
	.B0_END_BLOCK_000091:
	add r5, 4
	sub r2, 1
	test r2, r2
	jne .B0_END_BLOCK_000086
	mov r4, [r6+_B0_u32_2_u16_str_dest_ptr]
	mov [r4+2], r8w
	mov r0, r8
	pop r15
	pop r9
	pop r8
	pop r5
	pop r4
	pop r3
	pop r2
	pop r1
	ret
	mov r0, 0
	ret

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; End u32_2_u16_str Function Code;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; main Function Code;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

_B0_main:
	push r0
	push r6
	add r6, 08h
	call _B0_memInit
	pop r6
	mov r6, r0
	pop r0
	push r6
	add r6, 08h
	mov qword [r6+00h], B0_DynStr0
	call _B0_echo
	pop r6
	push r6
	add r6, 08h
	mov qword [r6+00h], B0_DynStr1
	call _B0_echo
	pop r6
	mov r0, _B0_string2
	push r6
	add r6, 08h
	mov [r6+00h], r0
	call _B0_echo
	pop r6
	push r6
	add r6, 08h
	mov qword [r6+00h], B0_DynStr2
	call _B0_echo
	pop r6
	mov r0, _B0_string3
	push r6
	add r6, 08h
	mov [r6+00h], r0
	call _B0_echo
	pop r6
	mov r0, _B0_string
	push r6
	add r6, 08h
	mov [r6+00h], r0
	call _B0_echo
	pop r6
	mov r0, 0
	jmp B0_sys_exit
	mov r0, 0
	ret

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; End main Function Code;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


B0_sys_exit:
	push r0
	call exit


;EOF
