b0 Logo B0

Copyright © 2000-2008, Darran Kartaschew

Standard Library

Function Index - Alphabetical

A..D

E..H

I..L

M..P

Q..T

U..Z

Function Index - By Include File

stdlib.b0

stdlib_linux.b0

stdlib_unicode.b0

Functions

atof

takes a UTF16 encoded string (integer) and returns a floating point value in fp0

atof(source_ptr)

Library - stdlib.b0

Return Value

atof returns a signed floating point value in fp0.

Parameters

source_ptr - pointer to a UTF16 encoded string. The string must confirm to the standard string type.

Remarks

Nil.

Example

    r0 = &'10.10';
    atof(r0);     // fp0 now contains the value 10.10;

atoi

takes a UTF16 encoded string (integer) and returns an integer in r0

atoi(source_ptr)

Library - stdlib.b0

Return Value

atoi returns an unsigned integer in r0. Returns zero on error.

Parameters

source_ptr - pointer to a UTF16 encoded string. The string must confirm to the standard string type.

Remarks

Nil.

Example

    r0 = &'1234';
    r1 = atoi(r0);     // r1 now contains the value 1234;

ftoa

takes a floating point value located in fp0 and inserts it into the string provided.

ftoa(dest_ptr)

Library - stdlib.b0

Return Value

itoa returns zero.

Parameters

fp0 - signed floating point value (f80).

dest_ptr - pointer to a UTF16 encoded string. The string must confirm to the standard string type.

Remarks

Nil.

Example

    m16[1024] my_string;
    my_string[0] = 1024;    // Set buffer length
    my_string[1] = 0;       // Set allocated buffer size
    r0 = &my__string;
    fp0 = -10.10;
    ftoa(r0);               // my_string now contains the string '-10.10';

hash

takes a UTF16 encoded string and returns a 64bit hash.

hash(source_ptr)

Library - stdlib.b0

Return Value

hash returns an unsigned 64bit hash of the string.

Parameters

source_ptr - pointer to a UTF16 encoded string. The string must confirm to the standard string type.

Remarks

This hash function is based on ElfHash with modifications.

Example

    r0 = &'The quick brown fox jumped over the lazy dog';
    r1 = hash(r0);     // r1 now contains the hash of the string;

htoi

takes a UTF16 encoded string (hexadecimal) and returns an integer in r0

htoi(source_ptr)

Library - stdlib.b0

Return Value

htoi returns an unsigned integer in r0. Returns zero on error.

Parameters

source_ptr - pointer to a UTF16 encoded string. The string must confirm to the standard string type.

Remarks

Nil.

Example

    r0 = &'1234a';
    r1 = htoi(r0);     // r1 now contains the value 1234ah;

itoa

takes an integer and inserts it into the string provided.

itoa(value, dest_ptr)

Library - stdlib.b0

Return Value

itoa returns zero.

Parameters

value - unsigned value (type m64).

dest_ptr - pointer to a UTF16 encoded string. The string must confirm to the standard string type.

Remarks

Nil.

Example

    m16[1024] my_string;
    my_string[0] = 1024;    // Set buffer length
    my_string[1] = 0;       // Set allocated buffer size
    r0 = &my__string;
    itoa(10, r0);           // my_string now contains the string '10';

itoh

takes an integer and inserts it into the string provided.

itoh(value, dest_ptr)

Library - stdlib.b0

Return Value

itoh returns zero.

Parameters

value - unsigned value (type m64).

dest_ptr - pointer to a UTF16 encoded string. The string must confirm to the standard string type.

Remarks

Nil.

Example

    m16[1024] my_string;
    my_string[0] = 1024;    // Set buffer length
    my_string[1] = 0;       // Set allocated buffer size
    r0 = &my__string;
    itoh(10, r0);           // my_string now contains the string 'a';

memcmp

compares a memory block from 1 location to another.

memcmp(source_ptr, dest_ptr,size)

Library - stdlib.b0

Return Value

memcpy returns zero if memory blocks are equal, else returns count left. (eg size - return value = location of difference).

Parameters

source_ptr - pointer to memory source.

dest_ptr - pointer to a memory destinition.

size - number of bytes to compare.

Remarks

This performs a single byte-by-byte comparison. For larger blocks, avoid this function.

Example

    r0 = &'The quick brown fox jumped over the lazy dog';
    r1 = &'The quick brown fox jumped over the lazy dog';
    memcmp(r0, r1, 32);    // compare strings;

memcpy

copys a memory block from 1 location to another.

memcpy(source_ptr, dest_ptr,size)

Library - stdlib.b0

Return Value

memcpy returns zero if complete.

Parameters

source_ptr - pointer to memory source to be copied.

dest_ptr - pointer to a memory destinition.

size - number of bytes to copy.

Remarks

This performs a single byte-by-byte copy. For larger blocks, avoid this function.

Example

    m16[1024] buffer1;
    r0 = &'The quick brown fox jumped over the lazy dog';
    r1 = &buffer1;
    memcpy(r0, r1, 2048);    // copy the string to buffer1;

memInit

Setups up a local heap for use by procedures.

memInit()

Library - stdlib_linux.b0

Return Value

memcpy sets r6 to pointer of local heap.

Parameters

Nil

Remarks

This function allocates enough space for a local variable heap. It also sets r6 accordingly. If a define LOCAL_HEAP is not set, then a heap of 64MB is created.

Example

    #define LOCAL_HEAP = 100000h;
    memInit();          // Allocate a local heap of 1MB;

u8_2_u16_char

converts a UTF8 encoded character into a UTF16 encoded character.

u8_2_u16_char(char)

Library - stdlib_unicode.b0

Return Value

u8_2_u16_char returns a UTF16 encoded character. bits 0-15: 1st word, bits 16-32: 2nd word (if surrogate pair).

Parameters

char - UTF8 encoded character. Each byte of m64 passed is part of the char. eg. bits 0-7 = 1st byte, bits 8-15 = 2nd byte, etc. Max 8 bytes passed.

Remarks

Nil.


u8_2_u16_str

converts a UTF8 encoded string into a UTF16 encoded string.

u8_2_u16_str(source_ptr,dest_ptr)

Library - stdlib_unicode.b0

Return Value

u8_2_u16_str returns number of words utilised.

Parameters

source_ptr - UTF8 encoded string.

dest_ptr - pointer to UTF16 string.

Remarks

Nil.


u8_2_u32_char

converts a UTF8 encoded character into a UTF32 encoded character.

u8_2_u32_char(char)

Library - stdlib_unicode.b0

Return Value

u8_2_u32_char returns a UTF32 encoded character.

Parameters

char - UTF8 encoded character. Each byte of m64 passed is part of the char. eg. bits 0-7 = 1st byte, bits 8-15 = 2nd byte, etc. Max 8 bytes passed.

Remarks

Nil.


u8_2_u32_str

converts a UTF8 encoded string into a UTF32 encoded string.

u8_2_u32_str(source_ptr,dest_ptr)

Library - stdlib_unicode.b0

Return Value

u8_2_u32_str returns number of dwords utilised.

Parameters

source_ptr - UTF8 encoded string.

dest_ptr - pointer to UTF16 string.

Remarks

Nil.


u16_2_u8_char

converts a UTF16 encoded character into a UTF8 encoded character.

u16_2_u8_char(char)

Library - stdlib_unicode.b0

Return Value

u16_2_u8_char returns a UTF8 encoded character. bits 0-7: 1st byte, bits 8-15: 2nd byte, etc.

Parameters

char - UTF16 encoded character. Each byte of m64 passed is part of the char. eg. bits 0-15 = 1st word, bits 15-31 = 2nd word, etc. Max 2 words passed.

Remarks

Nil.


u16_2_u8_str

converts a UTF16 encoded string into a UTF8 encoded string.

u16_2_u8_str(source_ptr,dest_ptr)

Library - stdlib_unicode.b0

Return Value

u16_2_u8_str returns number of bytes utilised.

Parameters

source_ptr - UTF16 encoded string.

dest_ptr - pointer to UTF8 string.

Remarks

Nil.


u16_2_u32_char

converts a UTF16 encoded character into a UTF32 encoded character.

u16_2_u32_char(char)

Library - stdlib_unicode.b0

Return Value

u16_2_u32_char returns a UTF32 encoded character.

Parameters

char - UTF16 encoded character. Each byte of m64 passed is part of the char. eg. bits 0-15 = 1st word, bits 15-31 = 2nd word, etc. Max 2 words passed.

Remarks

Nil.


u16_2_u32_str

converts a UTF16 encoded string into a UTF32 encoded string.

u16_2_u32_str(source_ptr,dest_ptr)

Library - stdlib_unicode.b0

Return Value

u16_2_u32_str returns number of dwords utilised.

Parameters

source_ptr - UTF16 encoded string.

dest_ptr - pointer to UTF32 string.

Remarks

Nil.


u32_2_u8_char

converts a UTF32 encoded character into a UTF8 encoded character.

u32_2_u8_char(char)

Library - stdlib_unicode.b0

Return Value

u32_2_u8_char returns a UTF8 encoded character. bits 0-7: 1st byte, bits 8-15: 2nd byte, etc.

Parameters

char - UTF32 encoded character.

Remarks

Nil.


u32_2_u8_str

converts a UTF32 encoded string into a UTF8 encoded string.

u32_2_u8_str(source_ptr,dest_ptr)

Library - stdlib_unicode.b0

Return Value

u32_2_u8_str returns number of bytes utilised.

Parameters

source_ptr - UTF32 encoded string.

dest_ptr - pointer to UTF8 string.

Remarks

Nil.


u32_2_u16_char

converts a UTF32 encoded character into a UTF16 encoded character.

u32_2_u16_char(char)

Library - stdlib_unicode.b0

Return Value

u32_2_u16_char returns a UTF16 encoded character. bits 0-15: 1st word, bits 15-31: 2nd word.

Parameters

char - UTF32 encoded character.

Remarks

Nil.


u32_2_u16_str

converts a UTF32 encoded string into a UTF16 encoded string.

u32_2_u16_str(source_ptr,dest_ptr)

Library - stdlib_unicode.b0

Return Value

u32_2_u16_str returns number of words utilised.

Parameters

source_ptr - UTF32 encoded string.

dest_ptr - pointer to UTF16 string.

Remarks

Nil.