FASMLIB v0.8.0


Table of Contents

1. About FASMLIB
2. Usage
Environment Variable FASMLIB
Assembler-Specific Usage
FASM
MASM
NASM/YASM
Error Handling
Checking for Error
Error codes
Fundamental Procedures
3. String Library
Procedures
Unicode
4. Conversion
To Decimal
From Decimal
To Hexadecimal
From Hexadecimal
5. Memory Management
Manipulation
Heap
Procedures
Internal Procedures
Heap - How it works
Memory Leak
6. File I/O
fileio.create
fileio.open
fileio.append
fileio.read
fileio.write
fileio.seek
fileio.tell
fileio.size
fileio.close
7. Process Management
process.exit
8. Streams
Stream interface
Stream Object
Stream Virtual Table
Methods
Method Wrappers
Standard I/O Streams
stdin
stdout
stderr
Memory Stream
Methods
File Stream
Methods
Aliases
9. Text Processing
Write procedures
Decimal
Hexadecimal
Read procedures
Decimal
Hexadecimal
Output Format String
10. Internal Features
Data Macros
libcall
ifndef
disp
Time/Date macros
Branch Hints
Compilation stopping macros
11. File Layout
12. Credits
13. Help Wanted
14. Contact
Index

Chapter 1. About FASMLIB

FASMLIB is portable general-purpose library for 32bit x86 assembly language.

One it's purpose is to rid assembly programmers of rewriting basic routines every time. FASMLIB provides many commonly-used routines. They are well tested, easy to use, and tend to prevent bugs in code.

Another purpose is to allow assembly programmers have single source working for multiple operation systems. FASMLIB wraps some most common routines of supported OSes, with same interface for all OSes. Thus all your code which uses FASMLIB can run under any supported platform. This multiplatform support is of course limited to x86 32bit processors. Currently win32 and linux platforms are supported.

FASMLIB is designed to allow people to use it easily with only pure assembly, without need for macros. But for FASM users, FASMLIB contains couple of optional high-level macros that can make it's usage easier.

FASMLIB is NOT designed to be fast. Simplicity of usage, bugproofnes, powerfulness and maintability are more important.

FASMLIB is designed to be both simple to use and powerful. This is often solved by having two versions of procedures, one simple for common use, and one powerful

Altough name may suggest FASMLIB is only for use with FASM (Flat Assembler), this is not true. FASMLIB currently has support for FASM, MASM, NASM and YASM. Support for more assemblers can be added on demand. This name is remnaint from time when it was FASM-only library. Currently I am considering renaming it to "LibASM" by version 1.

Chapter 2. Usage

This chapter describes how to use FASMLIB. First, we will learn how to include it to your project, in various assemblers. Then, we will learn how your code should work with FASMLIB. Example code is in FASM, NASM and YASM compatible syntax.

Environment Variable FASMLIB

To access FASMLIB from anywhere on your disk, you should set up envirnment variable "FASMLIB". It should point into directory where FASMLIB archive is unpacked.

Following is description how to set up persistent environment variable on supported platforms.

On win32.  rightclick My Computer, select Properties - Advanced - Environment Variables, click New. Set Variable Name to "FASMLIB" and Variable Value to path to FASMLIB directory

On linux with bash.  add following line to your ~/.bashrc file:

export FASMLIB=<path to fasmlib directory>
		

Assembler-Specific Usage

This chapter discusses specifics of using FASMLIB in various assemblers.

FASM

This section covers FASM-specific usage of FASMLIB.

Including (by sources)

Users of FASM can include FASMLIB into their project directly by including it's sources. This is prefered method for FASM.

First you need to define target operating system, and include FASMLIB sources. To do it, add these lines to code section:

		SYSTEM equ win32
		;SYSTEM equ linux
		include "%FASMLIB%/include/fasm/fasmlib-src"
	

Then you must set place for FASMLIB variables. For this, you use IncludeIData and IncludeUData macros.

IncludeIData defines initialized data. You can place this in any writable and readable place, prefereably into data section.

IncludeUData reserves space for uninitialized data. You should place this at the end of data section, so that unitialized data here won't be present in executable file, only reserved at header.

Example 2.1. win32 example:

format PE console
include '%FASMINC%/win32ax.inc'

.code

	SYSTEM EQU win32
	include '%FASMLIB%/include/fasm/fasmlib-src.inc'

start:
	<<- your code here ->>

.data
	<<- your data here ->>
	IncludeIData
	IncludeUData

.end start		
	

Example 2.2. linux example:

format ELF executable
entry start

;code
segment readable executable

	SYSTEM equ linux
	include '%FASMLIB%/include/fasm/fasmlib-src.inc'

start:
	<<- your code here ->>

;data
segment readable writeable
	<<- your data here ->>
	IncludeIData
	IncludeUData	
	

Note

When you include FASMLIB by sources, you can use FASMLIB's internal features in your project.

Note

Including FASMLIB sources makes compilation time considerably longer. In future I plan to provide headers for linking FASMLIB library file, but this in not high in my importance list. If you need this, please let me know, so I can work on it.

Calling

You can call FASMLIB procedures with near call

	call	mem.init

Arguments are pushed in reverse order. That means you call mem.copy(dest,src,size) with:

	push	[size]
	push 	[src]
	push	[dest]
	call	mem.copy

All arguments are dword-sized. That means, even if you are passing byte or word sized value, you must push it as dword

	push	dword 'a'
	push	[stream]
	call	stream.write.char

Qword (64bit) arguments are passed as two dwords

	push	0
	push	dword [dist+4]		;push high order dword
	push	dword [dist]		;push low order dword
	push	[handle]
	call	file.seek

Procedure always clears it's arguments from stack, not caller.

	push	[size]
	push	[src]
	push	[dest]
	call	mem.copy
	;no need for add esp, 3*4 here

Every procedure preserves EBX, ECX, ESI, EDI, EBP and DF.

Every procedure that doesn't return 64bit value preserves EDX too.

Every procedure returns error status in CF. If CF is set, error occured, and EAX contains error code. More on error handling in next chapter.

	push	100h		;size of block
	call	mem.alloc	;allocate block of memory
	jc	error		;check error

Procedure returns dword (32 bit) value in EAX.

	push	100h		;size of block
	call	mem.alloc	;allocate block of memory
	jc	error		;check error
	mov	[block], eax	;save returned value

Procedure returns qword (64 bit) value in EDX:EAX.

	push	[handle]
	call	file.tell		;call procedure which returns qword
	jc	error			;check error
	mov	dword [value], eax	;save low order dword of returned value
	mov	dword [value+4], edx	;save high order dword of returned value

Procedure returns boolean value in ZF.

	push	100h		;size of blocks to compare
	push	[block2]	;pointer to block
	push	[block1]	;pointer to another block
	call	mem.cmp		;compare blocks
	jc	error		;check error first!
	je	same		;blocks are same
	jne	different	;blocks are different

Function can also return overflow, or end-reached notice in OF

	push	100h		;read 100h bytes from file
	push	edi		;to buffer pointed by edi
	push	[handle]	;from our file handle
	call	fileio.read
	jc	error		;check error first!
	jo	EOF_reached	;file.read sets OF when end of file is reached	

If function wants to return equal/greater/lesser state, it can use combination of ZF/OF/SF to setup flags for signed conditional jumps.

	push	100h		;size of memory blocks
	push	esi		;compare memory block pointed by esi
	push	edi		;to memory block pointed by edi
	call	mem.cmp		;compare memory blocks contents
	jc	error
	jg	edi_greater 	;edi block is greater
	jl	esi_greater	;esi block is greater (edi is lesser)
	je	equal		;both blocks are equal

you can use all signed conditional jumps: je, jne, jg, jge, jl, jle, jng, jnge, jnl, jnle.

Warning

If function doesn't return anything in EAX, ZF, SF or OF, consider it's value undefined!

Note

If FASMLIB is included by source, you can use libcall macro for highlevel calling.

MASM

This section covers MASM-specific usage of FASMLIB.

Including

To include FASMLIB definitions to MASM project, add this line to your code segment:

%include @Environ(fasmlib)\\include\\masm\\fasmlib.inc
	

Now compile your file to MS-COFF file:

ml.exe /c /coff myfile.asm
	

Finally, you must link your project with FASMLIB library file. Library for MASM is "bin/fasmlib2.lib" in FASMLIB directory. You can refer to it using environment variable FASMLIB. This is example using MS link:

link /subsystem:console myfile.obj "%FASMLIB%\bin\fasmlib2.lib" kernel32.lib
	

Note

In MASM, all names use "_" instead of "." characters. For example you have mem_init instead of mem.init.

Example 2.3. 


.586
.model flat, stdcall
option casemap:none    ; case sensitive

;include FASMLIB headers
%include @Environ(FASMLIB)\\include\\masm\\fasmlib.inc

.data
	<<- your data here ->>


.code
start:
	<<- your code here ->>

end start	
	

Calling (pure assembly)

Note

In MASM, all names use underscore "_" instead of dot ".".

You can call FASMLIB procedures with near call

	call	mem_init

Arguments are pushed in reverse order. That means you call mem.copy(dest,src,size) with:

	push	size
	push 	src
	push	dest
	call	mem_copy

All arguments are dword-sized. That means, even if you are passing byte or word sized value, you must push it as dword

	push	dword ptr 'a'
	push	stream
	call	stream_write_char

Qword (64bit) arguments are passed as two dwords

	push	0
	push	dword ptr [dist+4]		;push high order dword
	push	dword ptr [dist]		;push low order dword
	push	handle
	call	file_seek

Procedure always clears it's arguments from stack, not caller.

	push	size
	push	src
	push	dest
	call	mem_copy
	;no need for add esp, 3*4 here

Every procedure preserves EBX, ECX, ESI, EDI, EBP and DF.

Every procedure that doesn't return 64bit value preserves EDX too.

Every procedure returns error status in CF. If CF is set, error occured, and EAX contains error code. More on error handling in next chapter.

	push	100h		;size of block
	call	mem_alloc	;allocate block of memory
	jc	error		;check error

Procedure returns dword (32 bit) value in EAX.

	push	100h		;size of block
	call	mem_alloc	;allocate block of memory
	jc	error		;check error
	mov	block, eax	;save returned value

Procedure returns qword (64 bit) value in EDX:EAX.

	push	handle
	call	file_tell			;call procedure which returns qword
	jc	error				;check error
	mov	dword ptr [value], eax		;save low order dword of returned value
	mov	dword ptr [value+4], edx	;save high order dword of returned value

Procedure returns boolean value in ZF.

	push	100h		;size of blocks to compare
	push	offset block2	;pointer to block
	push	offset block1	;pointer to another block
	call	mem_cmp		;compare blocks
	jc	error		;check error first!
	je	same		;blocks are same
	jne	different	;blocks are different

Function can also return overflow, or end-reached notice in OF

	push	100h		;read 100h bytes from file
	push	edi		;to buffer pointed by edi
	push	handle		;from our file handle
	call	fileio_read
	jc	error		;check error first!
	jo	EOF_reached	;file.read sets OF when end of file is reached	

If function wants to return equal/greater/lesser state, it can use combination of ZF/OF/SF to setup flags for signed conditional jumps.

	push	100h		;size of memory blocks
	push	esi		;compare memory block pointed by esi
	push	edi		;to memory block pointed by edi
	call	mem_cmp		;compare memory blocks contents
	jc	error
	jg	edi_greater 	;edi block is greater
	jl	esi_greater	;esi block is greater (edi is lesser)
	je	equal		;both blocks are equal

you can use all signed conditional jumps: je, jne, jg, jge, jl, jle, jng, jnge, jnl, jnle.

Warning

If function doesn't return anything in EAX, ZF, SF or OF, consider it's value undefined!

NASM/YASM

This section covers usage of FASMLIB in NASM and YASM (these two are compatible).

Including (win32)

To include FASMLIB definitions to NASM/YASM project, add this line to your source:

%include "%!FASMLIB/include/nasm/fasmlib.inc
	

Now compile your file to MS-COFF file:

nasm -f win32 myfile.asm
	

Finally, you must link your project with FASMLIB library file. Library file for NASM/YASM on win32 is "bin/fasmlib.lib" in FASMLIB directory. You can refer to it using environment variable FASMLIB. This is example using MS link:

link /subsystem:console myfile.obj "%FASMLIB%\bin\fasmlib.lib" kernel32.lib
	

Example 2.4. 

myfile.asm:

	;compile with:
	;  nasm -f win32 myfile.asm
	;link with: (using MS link)
	;  link /entry:start /subsystem:console myfile.obj "%FASMLIB%/bin/fasmlib.lib"

%include "%!FASMLIB/include/nasm/fasmlib.inc
global _start
[section .text]
_start:	
	<<- your code here ->>

[section .data]
	<<- your data here ->>
	

Note

If you use YASM, be sure to use at least version 0.5. In version 0.4 you have to replace every push with push dword.

Including (linux)

To include FASMLIB definitions to NASM/YASM project, add this line to your source:

%include "%!FASMLIB/include/nasm/fasmlib.inc
	

Then compile your file to ELF object format:

nasm -f elf myfile.asm
	

or

yasm -f elf myfile.asm
	

Then you link it to executable: (bash)

ld myfile.obj $FASMLIB/bin/fasmlib.a -o myfile
	

Example 2.5. 

myfile.asm:

	;compile with:
	;  nasm -f elf myfile.asm
	;link with: (in bash)
	;  ld -e _start myfile.o $FASMLIB/bin/fasmlib.a -o myfile

%include "%!FASMLIB/include/nasm/fasmlib.inc
global _start
[section .text]
_start:	
	<<- your code here ->>

[section .data]
	<<- your data here ->>
	

Note

If you use YASM, be sure to use at least version 0.5. In version 0.4 you have to replace every push with push dword.

Calling

You can call FASMLIB procedures with near call

	call	mem.init

Arguments are pushed in reverse order. That means you call mem.copy(dest,src,size) with:

	push	[size]
	push 	[src]
	push	[dest]
	call	mem.copy

All arguments are dword-sized. That means, even if you are passing byte or word sized value, you must push it as dword

	push	dword 'a'
	push	[stream]
	call	stream.write.char

Qword (64bit) arguments are passed as two dwords

	push	0
	push	dword [dist+4]		;push high order dword
	push	dword [dist]		;push low order dword
	push	[handle]
	call	file.seek

Procedure always clears it's arguments from stack, not caller.

	push	[size]
	push	[src]
	push	[dest]
	call	mem.copy
	;no need for add esp, 3*4 here

Every procedure preserves EBX, ECX, ESI, EDI, EBP and DF.

Every procedure that doesn't return 64bit value preserves EDX too.

Every procedure returns error status in CF. If CF is set, error occured, and EAX contains error code. More on error handling in next chapter.

	push	100h		;size of block
	call	mem.alloc	;allocate block of memory
	jc	error		;check error

Procedure returns dword (32 bit) value in EAX.

	push	100h		;size of block
	call	mem.alloc	;allocate block of memory
	jc	error		;check error
	mov	[block], eax	;save returned value

Procedure returns qword (64 bit) value in EDX:EAX.

	push	[handle]
	call	file.tell		;call procedure which returns qword
	jc	error			;check error
	mov	dword [value], eax	;save low order dword of returned value
	mov	dword [value+4], edx	;save high order dword of returned value

Procedure returns boolean value in ZF.

	push	100h		;size of blocks to compare
	push	[block2]	;pointer to block
	push	[block1]	;pointer to another block
	call	mem.cmp		;compare blocks
	jc	error		;check error first!
	je	same		;blocks are same
	jne	different	;blocks are different

Function can also return overflow, or end-reached notice in OF

	push	100h		;read 100h bytes from file
	push	edi		;to buffer pointed by edi
	push	[handle]	;from our file handle
	call	fileio.read
	jc	error		;check error first!
	jo	EOF_reached	;file.read sets OF when end of file is reached	

If function wants to return equal/greater/lesser state, it can use combination of ZF/OF/SF to setup flags for signed conditional jumps.

	push	100h		;size of memory blocks
	push	esi		;compare memory block pointed by esi
	push	edi		;to memory block pointed by edi
	call	mem.cmp		;compare memory blocks contents
	jc	error
	jg	edi_greater 	;edi block is greater
	jl	esi_greater	;esi block is greater (edi is lesser)
	je	equal		;both blocks are equal

you can use all signed conditional jumps: je, jne, jg, jge, jl, jle, jng, jnge, jnl, jnle.

Warning

If function doesn't return anything in EAX, ZF, SF or OF, consider it's value undefined!

Error Handling

Checking for Error

Every procedure returns error state in CF:

	call	file.open
	jc	error

If CF=1 after returning from FASMLIB procedure, it means some error happened. In such case procedure hasn't completed it's task, and didn't return anything (most of times). You should check CF after !every! procedure, even if it's unlikely that function will return some error.

	push	[handle]
	call	file.close
	jc	error		;this can help catching bad handle

When procedure returns with CF=1, then EAX contains error code. Error code is symbolic constant. Name of these constants start with ERR_. Always use their symbolic name, not direct value, because it can change.

	call	file.open
	jc	error_open
	...
	error_open:
	cmp	eax, ERR_FILE_NOT_FOUND
	je	file_not_found
	jmp	error

When procedure that returns 64bit value in EDX:EAX returns error, value of EDX is undefined

List of errors procedure can return is in description of every procedure. There can be also one or more + followed by name of other procedure. This means that other procedure is called internally, and it's return values can be returned aswell.

When you recieve error, you can handle it in way you like. You don't have to do anything extra for this, just check error value and continue execution. For example after getting ERR_FILE_NOT_FOUND from file.open, you can ask user to enter new file path etc.

	call	file.open
	jnc	file_opened
	cmp	eax, ERR_FILE_NOT_FOUND
	je	enter_new_file_name
	jmp	error_file_open
	file_opened:

Typical way to handle error is to release resources (close files, free memory etc.), then display error message, uninitialize FASMLIB and quit. To get error message from FASMLIB error code, use err.text. To uninitialize FASMLIB in case of unexpected error, use fasmlib.shutdown.To This is example of error hander:


_err_format db 10, "Error: %s!", 10, 0

	...

error:
	;EAX = error message associated with error code in EAX
	push	eax
	call	err.text

	;write error message
	push	eax
	push	_err_format
	call	stderr.write.format
 
	;unintialize FASMLIB
	call	fasmlib.uninit

	;end program with exit code 1
	push	1
	call	process.exit

Error codes

err.text

Description

This procedure returns error message associated with error code.

Arguments

errcode

This can be either FASMLIB error code or custom error code .

Returns

CF=0 always, and EAX = pointer to zero-terminated ASCII string holding error message

Errors

None

Fundamental Procedures

These are very basic procedures of FASMLIB, and should be always used.

fasmlib.init

Description

Initializes all modules in FASMLIB. In current version, it calls mem.init and stdstream.init .

Arguments

None

Returns

CF=1 on error

Remarks

Warning

Don't forget to call fasmlib.uninit or fasmlib.shutdown after you are done with FASMLIB.

fasmlib.uninit

Description

Uninitializes all modules in FASMLIB. In current version, it calls mem.uninit and stdstream.uninit .

Arguments

None

Returns

CF=1 on error

Remarks

Warning

If any called procedure returns error, this procedure immediately returns. This behavior is not ideal for error handlers. Use fasmlib.shutdown in error handlers.

fasmlib.shutdown

Description

Uninitializes all modules in FASMLIB. In current version, it calls mem.uninit and stdstream.uninit . Procedure is meant to be used in error handlers only: it tries to uninitialize as much as possible, even if some error hapens. Use fasmlib.uninit for normal uninitialization.

Arguments

None

Returns

Nothing

Chapter 3. String Library

FASMLIB provides library for working with strings. These are static strings, placed in user defined buffer. Strings are in ASCII format, eg. one byte per character. Strings are terminated by zero byte.

Common problem with such strings is that their maximal allowed size is limited. If someone tries to write string longer than buffer size into such buffer, it overflows and overwrites following data. This is most common method for exploiting software.

To prevent this happening, FASMLIB procedures always take pointer to string buffer and size of buffer. If you wish to disable buffer size limitation for particular string, just pass -1 (0xFFFFFFFF) as buffer size.

FASMLIB never reads beyond given buffer size. If source string is not terminated (no zero byte inside buffer), only part in buffer is taken as actual string.

Whenever result of string operation should overflow buffer, only portion of result which fits into buffer is written, and error ERR_BUFFER_FULL is returned.

This behavior allows limited working with constant-length and non-zero-terminated strings (for example section name in PE file header). It can be done by ignoring ERR_BUFFER_FULL error.

Procedures

These are procedures that operate on strings.

str.copy

Description

Copies string into string buffer.

Arguments

dest

Pointer to destination string buffer.

destlen

Size of destination string buffer.

src

Pointer to source string.

srclen

Size of source string buffer. You can set this to -1 (FFFFFFFFh) if string is quaranteed to be properly zero-terminated.

Returns

CF set on error, otherwise EAX = dest.

Errors

ERR_BUFFER_OVERFLOW

Destination buffer is not big enough. Only first destlen bytes of string were written. String in destination buffer is NOT zero terminated.

ERR_ZERO_SIZE

destlen=0 or srclen=0.


str.cat

Description

Concatenates (appends) string to end of another string.

Arguments

dest

Pointer to destination string.

destlen

Size of destination string buffer.

src

Pointer to source string.

srclen

Size of source string buffer. You can set this to -1 (FFFFFFFFh) if string is quaranteed to be properly zero-terminated.

Returns

CF set on error, otherwise EAX = dest.

Errors

ERR_BUFFER_OVERFLOW

Destination buffer is not big enough. Only first destlen bytes of resulting string were written. String in destination buffer is NOT zero terminated.

ERR_ZERO_SIZE

destlen=0 or srclen=0.

+str.len
+str.copy

str.catchar

Description

Concatenates (appends) character to end of string.

Arguments

string

Pointer to destination string.

buflen

Size of destination string buffer.

char

Character which we are appending to string. Only low order byte of this dword is used, rest is ignored.

Returns

CF set on error, otherwise EAX = string.

Errors

ERR_BUFFER_OVERFLOW

Destination buffer is not big enough. Only first destlen bytes of string were written. String in destination buffer is NOT zero terminated.

ERR_ZERO_VALUE

char=0

ERR_ZERO_SIZE

strlen=0

+str.len

str.ins

Description

Inserts string to into another string.

Arguments

dest

Pointer to destination string, the one into which we insert.

destlen

Size of destination string buffer.

src

Pointer to source string, the one we are inserting.

srclen

Size of source string buffer. You can set this to -1 (FFFFFFFFh) if string is quaranteed to be properly zero-terminated.

pos

Position in destination string where we are insrting. Position 0 corresponds to beginning of string, before first character.

Returns

CF set on error, otherwise EAX = dest.

Errors

ERR_OUT_OF_RANGE

Position is outside of destination string, pos > strlen(dest). You are trying to insert behind end of string.

ERR_BUFFER_OVERFLOW

Destination buffer is not big enough. Only first destlen bytes of resulting string were written. String in destination buffer is NOT zero terminated.

ERR_ZERO_SIZE

destlen=0 or srclen=0.

+str.len
+mem.copy

str.inschar

Description

Inserts character to given position in another string.

Arguments

string

Pointer to destination string, the one into which we insert.

buflen

Size of destination string buffer.

char

Character which we are inserting to string. Only low order byte of this dword is used, rest is ignored.

pos

Position in destination string where we are insrting. Position 0 corresponds to beginning of string, before first character.

Returns

CF set on error, otherwise EAX = string.

Errors

ERR_OUT_OF_RANGE

Position is outside of destination string, pos > strlen(dest). You are trying to insert behind end of string.

ERR_BUFFER_OVERFLOW

Destination buffer is not big enough. Only first destlen bytes of resulting string were written. String in destination buffer is NOT zero terminated.

ERR_ZERO_SIZE

destlen=0 or srclen=0

+str.ins

str.sub

Description

Extracts substring from another string.

Arguments

dest

Pointer to destination string buffer.

destlen

Size of destination string buffer.

src

Pointer to source string.

srclen

Size of source string buffer. You can set this to -1 (FFFFFFFFh) if string is quaranteed to be properly zero-terminated.

index

Position in source string from where we start extracting. Position 0 corresponds to first character, included.

len

Length of string we want to extract.

Returns

CF set on error, otherwise EAX = dest, and OF set if string overlapped and less than len characters were copied

Errors

ERR_OUT_OF_RANGE

Position is outside of destination string, pos >= strlen(dest). You are trying to extract string from behind end of source string.

ERR_BUFFER_OVERFLOW

Destination buffer is not big enough. Only first destlen bytes of extracted string were written. String in destination buffer is NOT zero terminated.

ERR_ZERO_SIZE

destlen=0 or srclen=0.

+str.len
+mem.copy

Remarks

Note

If source string doesn't contain enough characters from given index, string shorter than len is copied and procedure returns with OF set.

Note

If len=0, destination buffer is filled with empty string.

str.lowcase

Description

Converts characters in string to lowcase. Works only for ASCII characters (a-z and A-Z), no other encodings are supported.

Arguments

string

Pointer to string.

buflen

Size of string buffer. You can set this to -1 (FFFFFFFFh) if string is quaranteed to be properly zero-terminated.

Returns

CF set on error, otherwise EAX = string.

Errors

ERR_ZERO_SIZE

buflen=0


str.upcase

Description

Converts characters in string to upcase. Works only for ASCII characters (a-z and A-Z), no other encodings are supported.

Arguments

string

Pointer to string.

buflen

Size of string buffer. You can set this to -1 (FFFFFFFFh) if string is quaranteed to be properly zero-terminated.

Returns

CF set on error, otherwise EAX = string.

Errors

ERR_ZERO_SIZE

buflen=0


str.len

Description

Returns length of string. If string isn't zero-terminated within it's buffer, size of buffer is returned, and OF is set.

Arguments

string

Pointer to string.

buflen

Size of string buffer. You can set this to -1 (FFFFFFFFh) if string is quaranteed to be properly zero-terminated.

Returns

CF set on error, otherwise EAX = length of string, and OF set if string isn't zero-terminated.

Errors

ERR_ZERO_SIZE

buflen=0


str.cmp

Description

Compares two strings, whether they are identical (case sensitive). If strings are different, tells which is greater (by comparing first different character). This is useful for sorting strings.

Arguments

str1

Pointer to first string.

str1len

Size of buffer of first string. You can set this to -1 (FFFFFFFFh) if string is quaranteed to be properly zero-terminated.

str2

Pointer to second string.

str2len

Size of buffer of second string. You can set this to -1 (FFFFFFFFh) if string is quaranteed to be properly zero-terminated.

Returns

CF set on error, otherwise {flagscmp:flags set for signed conditional jumps}, and if ZF=0, then EAX = offset where strings differ

Errors

ERR_ZERO_SIZE

str1len=0 or str2len=0

Remarks

Warning

Use returned value in EAX with caution. It can point to end-of-string zero character. (like for "ab" and "abc"). It can even point behind end of buffer, when string wasn't properly zero-terminated within it's buffer (like for "ab" in 2 byte buffer, and "abc").

Note

If one string is longer than another, and shorter string is same as beginning of longer

str.cmpi

Description

Compares two strings, whether they are identical. This procedure is case-insensitive for ASCII characters (a-z and A-Z). Other encodings are not supported. If strings are different, tells which is greater (by comparing first different character). This is useful for sorting strings.

Arguments

str1

Pointer to first string.

str1len

Size of buffer of first string. You can set this to -1 (FFFFFFFFh) if string is quaranteed to be properly zero-terminated.

str2

Pointer to second string.

str2len

Size of buffer of second string. You can set this to -1 (FFFFFFFFh) if string is quaranteed to be properly zero-terminated.

Returns

CF set on error, otherwise {flagscmp:flags set for signed conditional jumps}, and if ZF=0, then EAX = offset where strings differ

Errors

ERR_ZERO_SIZE

str1len=0 or str2len=0

Remarks

Warning

Use returned value in EAX with caution. It can point to end-of-string zero character. (like for "ab" and "abc"). It can even point behind end of buffer, when string wasn't properly zero-terminated within it's buffer (like for "ab" in 2 byte buffer, and "abc").

Note

If one string is longer than another, and shorter string is same as beginning of longer

str.pos

Description

Finds position of first occurence of string pattern inside another string.

Arguments

string

Pointer to string in which we are searching.

buflen

Size of buffer of string in which we are searching. You can set this to -1 (FFFFFFFFh) if string is quaranteed to be properly zero-terminated.

pattern

Pointer to pattern string.

patlen

Size of pattern string buffer. You can set this to -1 (FFFFFFFFh) if string is quaranteed to be properly zero-terminated.

Returns

CF set on error, otherwise ZF set if pattern wasn't found, otherwise EAX = index of first occurence of pattern within string.

Errors

ERR_ZERO_VALUE

Pattern is empty string.

ERR_ZERO_SIZE

buflen=0 or patlen=0.

+str.len
+mem.find

str.poschar

Description

Finds position of first occurence of character inside another string.

Arguments

string

Pointer to string in which we are searching.

buflen

Size of buffer of string in which we are searching. You can set this to -1 (FFFFFFFFh) if string is quaranteed to be properly zero-terminated.

char

Character which we are looking for.

Returns

CF set on error, otherwise ZF set if character wasn't found, otherwise EAX = index of first occurence of character within string.

Errors

ERR_ZERO_VALUE

char=0.

ERR_ZERO_SIZE

buflen=0.

Unicode

FASMLIB doesn't support any Unicode functionality. Some Unicode support is planned, but it is a very difficult problem, and will probably take long time to implement.

If you want unicode support, you should use some external Unicode library, for example ICU or glibc.

Chapter 4. Conversion

FASMLIB provides several routines for conversion between binary formats and their string representations.

Currently supported are byte/word/dword binary numbers, and signed/unsigned decimal/hexadecimal ASCII string formats.

To Decimal

These procedures convert number to decimal string representation.

conv.b_dec

Description

Converts unsigned byte (8bit) value to decimal string. For more options use extconv.b_dec .

Arguments

dest

Pointer to destination string buffer.

destlen

Size of destination string buffer. Size 4 is always enough for this procedure.

value

Byte value to convert. Only low order byte of this dword is used, rest is ignored.

Returns

CF=1 on error.

Errors

ERR_BUFFER_FULL

Destination buffer is not big enough, must be at least 4 bytes. Only first destlen bytes of resulting string were written. String in destination buffer is NOT zero terminated.

ERR_ZERO_SIZE

destlen=0.


conv.w_dec

Description

Converts unsigned word (16bit) value to decimal string. For more options use extconv.w_dec .

Arguments

dest

Pointer to destination string buffer.

destlen

Size of destination string buffer. Size 6 is always enough for this procedure.

value

Word value to convert. Only low order word of this dword is used, rest is ignored.

Returns

CF=1 on error.

Errors

ERR_BUFFER_FULL

Destination buffer is not big enough, must be at least 6 bytes. Only first destlen bytes of resulting string were written. String in destination buffer is NOT zero terminated.

ERR_ZERO_SIZE

destlen=0.


conv.d_dec

Description

Converts unsigned dword (32bit) value to decimal string. For more options use extconv.d_dec .

Arguments

dest

Pointer to destination string buffer.

destlen

Size of destination string buffer. Size 11 is always enough for this procedure.

value

Dword value to convert.

Returns

CF=1 on error.

Errors

ERR_BUFFER_FULL

Destination buffer is not big enough, must be at least 11 bytes. Only first destlen bytes of resulting string were written. String in destination buffer is NOT zero terminated.

ERR_ZERO_SIZE

destlen=0.


conv.q_dec

Description

Converts unsigned qword (64bit) value to decimal string. For more options use extconv.q_dec .

Arguments

dest

Pointer to destination string buffer.

destlen

Size of destination string buffer. Size 11 is always enough for this procedure.

valuelow

Low order dword of value to convert.

valuehigh

High order dword of value to convert.

Returns

CF=1 on error.

Errors

ERR_BUFFER_FULL

Destination buffer is not big enough (must be at least 21 bytes). Only first destlen bytes of resulting string were written. String in destination buffer is NOT zero terminated.

ERR_ZERO_SIZE

destlen=0.


conv.ib_dec

Description

Converts signed byte (8bit) value to decimal string. For more options use extconv.ib_dec .

Arguments

dest

Pointer to destination string buffer.

destlen

Size of destination string buffer. Size 5 is always enough for this procedure.

value

Byte value to convert. Only low order byte of this dword is used, rest is ignored.

Returns

CF=1 on error.

Errors

ERR_BUFFER_FULL

Destination buffer is not big enough, must be at least 5 bytes. Only first destlen bytes of resulting string were written. String in destination buffer is NOT zero terminated.

ERR_ZERO_SIZE

destlen=0.


conv.iw_dec

Description

Converts signed word (16bit) value to decimal string. For more options use extconv.iw_dec .

Arguments

dest

Pointer to destination string buffer.

destlen

Size of destination string buffer. Size 7 is always enough for this procedure.

value

Word value to convert. Only low order word of this dword is used, rest is ignored.

Returns

CF=1 on error.

Errors

ERR_BUFFER_FULL

Destination buffer is not big enough, must be at least 7 bytes. Only first destlen bytes of resulting string were written. String in destination buffer is NOT zero terminated.

ERR_ZERO_SIZE

destlen=0.


conv.id_dec

Description

Converts signed dword (32bit) value to decimal string. For more options use extconv.id_dec .

Arguments

dest

Pointer to destination string buffer.

destlen

Size of destination string buffer. Size 12 is always enough for this procedure.

value

Dword value to convert.

Returns

CF=1 on error.

Errors

ERR_BUFFER_FULL

Destination buffer is not big enough, must be at least 12 bytes. Only first destlen bytes of resulting string were written. String in destination buffer is NOT zero terminated.

ERR_ZERO_SIZE

destlen=0.


conv.iq_dec

Description

Converts signed qword (64bit) value to decimal string. For more options use extconv.iq_dec .

Arguments

dest

Pointer to destination string buffer.

destlen

Size of destination string buffer. Size 22 is always enough for this procedure.

valuelow

Low order dword of value to convert.

valuehigh

High order dword of value to convert.

Returns

CF=1 on error.

Errors

ERR_BUFFER_FULL

Destination buffer is not big enough, must be at least 22 bytes. Only first destlen bytes of resulting string were written. String in destination buffer is NOT zero terminated.

ERR_ZERO_SIZE

destlen=0.


extconv.b_dec

Description

Converts unsigned byte (8bit) value to decimal string. Supports padding of output with spaces or zeroes. For simpler version see conv.b_dec .

Arguments

dest

Pointer to destination string buffer.

destlen

Size of destination string buffer.

value

Byte value to convert. Only low order byte of this dword is used, rest is ignored.

padding

Type of padding: type 0 is no padding, type 1 is prepending with spaces, type 2 is prepending with leading zeroes.

padlen

Length to which should output be padded. If output is already longer than this value before padding, then output is not padded. Ignored if padding = 0.

len

Pointer to dword variable, which will on return hold length of output (terminating zero not included). Ignored if zero.

Returns

CF=1 on error.

Errors

ERR_BUFFER_FULL

Destination buffer is not big enough. Only first destlen bytes of resulting string were written. String in destination buffer is NOT zero terminated. Variable pointed by len contains destlen

ERR_ZERO_SIZE

destlen=0. Variable pointed by len is set to 0.

ERR_INVALID_MODE

padding > 2. Variable pointed by len is set to 0.


extconv.w_dec

Description

Converts unsigned word (16bit) value to decimal string. Supports padding of output with spaces or zeroes. For simpler version see conv.w_dec .

Arguments

dest

Pointer to destination string buffer.

destlen

Size of destination string buffer.

value

Word value to convert. Only low order word of this dword is used, rest is ignored.

padding

Type of padding: type 0 is no padding, type 1 is prepending with spaces, type 2 is prepending with leading zeroes.

padlen

Length to which should output be padded. If output is already longer than this value before padding, then output is not padded. Ignored if padding = 0.

len

Pointer to dword variable, which will on return hold length of output (terminating zero not included). Ignored if zero.

Returns

CF=1 on error.

Errors

ERR_BUFFER_FULL

Destination buffer is not big enough. Only first destlen bytes of resulting string were written. String in destination buffer is NOT zero terminated. Variable pointed by len contains destlen

ERR_ZERO_SIZE

destlen=0. Variable pointed by len is set to 0.

ERR_INVALID_MODE

padding > 2. Variable pointed by len is set to 0.


extconv.d_dec

Description

Converts unsigned dword (32bit) value to decimal string. Supports padding of output with spaces or zeroes. For simpler version see conv.d_dec .

Arguments

dest

Pointer to destination string buffer.

destlen

Size of destination string buffer.

value

Dword value to convert.

padding

Type of padding: type 0 is no padding, type 1 is prepending with spaces, type 2 is prepending with leading zeroes.

padlen

Length to which should output be padded. If output is already longer than this value before padding, then output is not padded. Ignored if padding = 0.

len

Pointer to dword variable, which will on return hold length of output (terminating zero not included). Ignored if zero.

Returns

CF=1 on error.

Errors

ERR_BUFFER_FULL

Destination buffer is not big enough. Only first destlen bytes of resulting string were written. String in destination buffer is NOT zero terminated. Variable pointed by len contains destlen

ERR_ZERO_SIZE

destlen=0. Variable pointed by len is set to 0.

ERR_INVALID_MODE

padding > 2. Variable pointed by len is set to 0.


extconv.q_dec

Description

Converts unsigned qword (64bit) value to decimal string. Supports padding of output with spaces or zeroes. For simpler version see conv.q_dec .

Arguments

dest

Pointer to destination string buffer.

destlen

Size of destination string buffer.

valuelow

Low order dword of value to convert.

valuehigh

High order dword of value to convert.

padding

Type of padding: type 0 is no padding, type 1 is prepending with spaces, type 2 is prepending with leading zeroes.

padlen

Length to which should output be padded. If output is already longer than this value before padding, then output is not padded. Ignored if padding = 0.

len

Pointer to dword variable, which will on return hold length of output (terminating zero not included). Ignored if zero.

Returns

CF=1 on error.

Errors

ERR_BUFFER_FULL

Destination buffer is not big enough. Only first destlen bytes of resulting string were written. String in destination buffer is NOT zero terminated. Variable pointed by len contains destlen

ERR_ZERO_SIZE

destlen=0. Variable pointed by len is set to 0.

ERR_INVALID_MODE

padding > 2. Variable pointed by len is set to 0.


extconv.ib_dec

Description

Converts signed byte (8bit) value to decimal string. Supports padding of output with spaces or zeroes, and explicit plus sign. For simpler version see conv.ib_dec .

Arguments

dest

Pointer to destination string buffer.

destlen

Size of destination string buffer.

value

Byte value to convert. Only low order byte of this dword is used, rest is ignored.

padding

Type of padding: Type 0 is no padding. Type 1 is prepending with spaces, and sign counts into padding size. Type 2 is prepending with leading zeroes. In this type padlen specifies number digits displayed. One more character is always printed as sign (' ', '+' or '-').

padlen

Length to which should output be padded. If output is already longer than this value before padding, then output is not padded. Ignored if padding = 0.

plus

Set to 1 if you want to display plus sign on positive numbers.

len

Pointer to dword variable, which will on return hold length of output (terminating zero not included). Ignored if zero.

Returns

CF=1 on error.

Errors

ERR_BUFFER_FULL

Destination buffer is not big enough. Only first destlen bytes of resulting string were written. String in destination buffer is NOT zero terminated. Variable pointed by len contains destlen

ERR_INVALID_MODE

padding > 2, or plus > 1

ERR_ZERO_SIZE

destlen=0. Variable pointed by len is set to 0. Variable pointed by len is set to 0.


extconv.iw_dec

Description

Converts signed word (16bit) value to decimal string. Supports padding of output with spaces or zeroes, and explicit plus sign. For simpler version see conv.iw_dec .

Arguments

dest

Pointer to destination string buffer.

destlen

Size of destination string buffer.

value

Word value to convert. Only low order word of this dword is used, rest is ignored.

padding

Type of padding: Type 0 is no padding. Type 1 is prepending with spaces, and sign counts into padding size. Type 2 is prepending with leading zeroes. In this type padlen specifies number digits displayed. One more character is always printed as sign (' ', '+' or '-').

padlen

Length to which should output be padded. If output is already longer than this value before padding, then output is not padded. Ignored if padding = 0.

plus

Set to 1 if you want to display plus sign on positive numbers.

len

Pointer to dword variable, which will on return hold length of output (terminating zero not included). Ignored if zero.

Returns

CF=1 on error.

Errors

ERR_BUFFER_FULL

Destination buffer is not big enough. Only first destlen bytes of resulting string were written. String in destination buffer is NOT zero terminated. Variable pointed by len contains destlen

ERR_ZERO_SIZE

destlen=0. Variable pointed by len is set to 0.

ERR_INVALID_MODE

padding > 2, or plus > 1 Variable pointed by len is set to 0.


extconv.id_dec

Description

Converts signed dword (32bit) value to decimal string. Supports padding of output with spaces or zeroes, and explicit plus sign. For simpler version see conv.id_dec .

Arguments

dest

Pointer to destination string buffer.

destlen

Size of destination string buffer.

value

Dword value to convert.

padding

Type of padding: Type 0 is no padding. Type 1 is prepending with spaces, and sign counts into padding size. Type 2 is prepending with leading zeroes. In this type padlen specifies number digits displayed. One more character is always printed as sign (' ', '+' or '-').

padlen

Length to which should output be padded. If output is already longer than this value before padding, then output is not padded. Ignored if padding = 0.

plus

Set to 1 if you want to display plus sign on positive numbers.

len

Pointer to dword variable, which will on return hold length of output (terminating zero not included). Ignored if zero.

Returns

CF=1 on error.

Errors

ERR_BUFFER_FULL

Destination buffer is not big enough. Only first destlen bytes of resulting string were written. String in destination buffer is NOT zero terminated. Variable pointed by len contains destlen

ERR_ZERO_SIZE

destlen=0. Variable pointed by len is set to 0.

ERR_INVALID_MODE

padding > 2, or plus > 1 Variable pointed by len is set to 0.


extconv.iq_dec

Description

Converts signed qword (64bit) value to decimal string. Supports padding of output with spaces or zeroes, and explicit plus sign. For simpler version see conv.iq_dec .

Arguments

dest

Pointer to destination string buffer.

destlen

Size of destination string buffer.

valuelow

Low order dword of value to convert.

valuehigh

High order dword of value to convert.

padding

Type of padding: Type 0 is no padding. Type 1 is prepending with spaces, and sign counts into padding size. Type 2 is prepending with leading zeroes. In this type padlen specifies number digits displayed. One more character is always printed as sign (' ', '+' or '-').

padlen

Length to which should output be padded. If output is already longer than this value before padding, then output is not padded. Ignored if padding = 0.

plus

Set to 1 if you want to display plus sign on positive numbers.

len

Pointer to dword variable, which will on return hold length of output (terminating zero not included). Ignored if zero.

Returns

CF=1 on error.

Errors

ERR_BUFFER_FULL

Destination buffer is not big enough. Only first destlen bytes of resulting string were written. String in destination buffer is NOT zero terminated. Variable pointed by len contains destlen

ERR_ZERO_SIZE

destlen=0. Variable pointed by len is set to 0.

ERR_INVALID_MODE

padding > 2, or plus > 1 Variable pointed by len is set to 0.

From Decimal

These procedures convert number from decimal string representation.

conv.dec_b

Description

Converts decimal string to unsigned byte (8bit) value.

Arguments

string

Pointer to string to convert.

buflen

Size of string's buffer. You can set this to -1 (FFFFFFFFh) if string is quaranteed to be properly zero-terminated.

Returns

CF=1 on error, otherwise EAX = value (AL zero extended to dword).

Errors

ERR_NOT_DECIMAL

First character of string is not decimal digit.

ERR_OUT_OF_RANGE

Value is > 255

ERR_ZERO_SIZE

strlen=0

Remarks

Note

This procedure converts digits until it reaches non-digit character, or until value overflows.

Note

To get number of converted characters, use extconv.dec_b .

conv.dec_w

Description

Converts decimal string to unsigned word (16bit) value.

Arguments

string

Pointer to string to convert.

buflen

Size of string's buffer. You can set this to -1 (FFFFFFFFh) if string is quaranteed to be properly zero-terminated.

Returns

CF=1 on error, otherwise EAX = value (AX zero extended to dword).

Errors

ERR_NOT_DECIMAL

First character of string is not decimal digit.

ERR_OUT_OF_RANGE

Value is > 65535

ERR_ZERO_SIZE

strlen=0

Remarks

Note

This procedure converts digits until it reaches non-digit character, or until value overflows.

Note

To get number of converted characters, use extconv.dec_w .

conv.dec_d

Description

Converts decimal string to unsigned dword (32bit) value.

Arguments

string

Pointer to string to convert.

buflen

Size of string's buffer. You can set this to -1 (FFFFFFFFh) if string is quaranteed to be properly zero-terminated.

Returns

CF=1 on error, otherwise EAX = value.

Errors

ERR_NOT_DECIMAL

First character of string is not decimal digit.

ERR_OUT_OF_RANGE

Value is > 4294967295.

ERR_ZERO_SIZE

strlen=0

Remarks

Note

This procedure converts digits until it reaches non-digit character, or until value overflows.

Note

To get number of converted characters, use extconv.dec_d .

conv.dec_q

Description

Converts decimal string to unsigned qword (64bit) value.

Arguments

string

Pointer to string to convert.

buflen

Size of string's buffer. You can set this to -1 (FFFFFFFFh) if string is quaranteed to be properly zero-terminated.

Returns

CF=1 on error, otherwise EDX:EAX = value.

Errors

ERR_NOT_DECIMAL

First character of string is not decimal digit.

ERR_OUT_OF_RANGE

Value is > 18446744073709551615.

ERR_ZERO_SIZE

strlen=0

Remarks

Note

This procedure converts digits until it reaches non-digit character, or until value overflows.

Note

To get number of converted characters, use extconv.dec_q .

conv.dec_ib

Description

Converts decimal string to signed byte (8bit) value.

Arguments

string

Pointer to string to convert.

buflen

Size of string's buffer. You can set this to -1 (FFFFFFFFh) if string is quaranteed to be properly zero-terminated.

Returns

CF=1 on error, otherwise EAX = value.

Errors

ERR_NOT_DECIMAL

First character of string is not decimal digit.

ERR_OUT_OF_RANGE

Value is greater than 127 or lesser than -128.

ERR_ZERO_SIZE

strlen=0

Remarks

Note

This procedure converts digits until it reaches non-digit character, or until value overflows.

Note

To get number of converted characters, use extconv.dec_ib .

conv.dec_iw

Description

Converts decimal string to signed word (16bit) value.

Arguments

string

Pointer to string to convert.

buflen

Size of string's buffer. You can set this to -1 (FFFFFFFFh) if string is quaranteed to be properly zero-terminated.

Returns

CF=1 on error, otherwise EAX = value.

Errors

ERR_NOT_DECIMAL

First character of string is not decimal digit.

ERR_OUT_OF_RANGE

Value is greater than 65535 or lesser than -65536.

ERR_ZERO_SIZE

strlen=0

Remarks

Note

This procedure converts digits until it reaches non-digit character, or until value overflows.

Note

To get number of converted characters, use extconv.dec_iw .

conv.dec_id

Description

Converts decimal string to signed dword (32bit) value.

Arguments

string

Pointer to string to convert.

buflen

Size of string's buffer. You can set this to -1 (FFFFFFFFh) if string is quaranteed to be properly zero-terminated.

Returns

CF=1 on error, otherwise EAX = value.

Errors

ERR_NOT_DECIMAL

First character of string is not decimal digit.

ERR_OUT_OF_RANGE

Value is greater than 2147483647 or lesser than -2147483648.

ERR_ZERO_SIZE

strlen=0

Remarks

Note

This procedure converts digits until it reaches non-digit character, or until value overflows.

Note

To get number of converted characters, use extconv.dec_id .

conv.dec_iq

Description

Converts decimal string to signed qword (64bit) value.

Arguments

string

Pointer to string to convert.

buflen

Size of string's buffer. You can set this to -1 (FFFFFFFFh) if string is quaranteed to be properly zero-terminated.

Returns

CF=1 on error, otherwise EAX = value.

Errors

ERR_NOT_DECIMAL

First character of string is not decimal digit.

ERR_OUT_OF_RANGE

Value is greater than 9223372036854775807 or lesser than -9223372036854775808.

ERR_ZERO_SIZE

strlen=0

Remarks

Note

This procedure converts digits until it reaches non-digit character, or until value overflows.

Note

To get number of converted characters, use extconv.dec_iq .

extconv.dec_b

Description

Converts decimal string to unsigned byte (8bit) value. This is extended version, for simpler version see conv.dec_b .

Arguments

string

Pointer to string to convert.

buflen

Size of string's buffer. You can set this to -1 (FFFFFFFFh) if string is quaranteed to be properly zero-terminated.

len

Pointer to dword variable, which will on return hold number of converted characters. Ignored if zero.

Returns

CF=1 on error, otherwise EAX = value (AL zero extended to dword).

Errors

ERR_NOT_DECIMAL

First character of string is not decimal digit.

ERR_OUT_OF_RANGE

Value is > 255

ERR_ZERO_SIZE

strlen=0

Remarks

Note

This procedure converts digits until it reaches non-digit character, or until value overflows.

extconv.dec_w

Description

Converts decimal string to unsigned word (16bit) value. This is extended version, for simpler version see conv.dec_w .

Arguments

string

Pointer to string to convert.

buflen

Size of string's buffer. You can set this to -1 (FFFFFFFFh) if string is quaranteed to be properly zero-terminated.

len

Pointer to dword variable, which will on return hold number of converted characters. Ignored if zero.

Returns

CF=1 on error, otherwise EAX = value (AX zero extended to dword).

Errors

ERR_NOT_DECIMAL

First character of string is not decimal digit.

ERR_OUT_OF_RANGE

Value is > 65536

ERR_ZERO_SIZE

strlen=0

Remarks

Note

This procedure converts digits until it reaches non-digit character, or until value overflows.

extconv.dec_d

Description

Converts decimal string to unsigned dword (32bit) value. This is extended version, for simpler version see conv.dec_d .

Arguments

string

Pointer to string to convert.

buflen

Size of string's buffer. You can set this to -1 (FFFFFFFFh) if string is quaranteed to be properly zero-terminated.

len

Pointer to dword variable, which will on return hold number of converted characters. Ignored if zero.

Returns

CF=1 on error, otherwise EAX = value.

Errors

ERR_NOT_DECIMAL

First character of string is not decimal digit.

ERR_OUT_OF_RANGE

Value is > 4294967295

ERR_ZERO_SIZE

strlen=0

Remarks

Note

This procedure converts digits until it reaches non-digit character, or until value overflows.

extconv.dec_q

Description

Converts decimal string to unsigned qword (64bit) value. This is extended version, for simpler version see conv.dec_q .

Arguments

string

Pointer to string to convert.

buflen

Size of string's buffer. You can set this to -1 (FFFFFFFFh) if string is quaranteed to be properly zero-terminated.

len

Pointer to dword variable, which will on return hold number of converted characters. Ignored if zero.

strlen

Returns

CF=1 on error, otherwise EDX:EAX = value.

Errors

ERR_NOT_DECIMAL

First character of string is not decimal digit.

ERR_OUT_OF_RANGE

Value is > 18446744073709551615.

ERR_ZERO_SIZE

strlen=0

Remarks

Note

This procedure converts digits until it reaches non-digit character, or until value overflows.

extconv.dec_ib

Description

Converts decimal string to signed byte (8bit) value. This is extended version, for simpler version see conv.dec_ib .

Arguments

string

Pointer to string to convert.

buflen

Size of string's buffer. You can set this to -1 (FFFFFFFFh) if string is quaranteed to be properly zero-terminated.

allowplus

If 1, explicit "+" sign before number is allowed.

len

Pointer to dword variable, which will on return hold number of converted characters. Ignored if zero.

Returns

CF=1 on error, otherwise EAX = value.

Errors

ERR_INVALID_MODE

allowplus > 1

ERR_NOT_DECIMAL

First character of string is not decimal digit.

ERR_OUT_OF_RANGE

Value is greater than 127 or lesser than -128.

ERR_ZERO_SIZE

strlen=0

Remarks

Note

This procedure converts digits until it reaches non-digit character, or until value overflows.

extconv.dec_iw

Description

Converts decimal string to signed word (16bit) value. This is extended version, for simpler version see conv.dec_iw .

Arguments

string

Pointer to string to convert.

buflen

Size of string's buffer. You can set this to -1 (FFFFFFFFh) if string is quaranteed to be properly zero-terminated.

allowplus

If 1, explicit "+" sign before number is allowed.

len

Pointer to dword variable, which will on return hold number of converted characters. Ignored if zero.

Returns

CF=1 on error, otherwise EAX = value.

Errors

ERR_INVALID_MODE

allowplus > 1

ERR_NOT_DECIMAL

First character of string is not decimal digit.

ERR_OUT_OF_RANGE

Value is greater than 32767 or lesser than -32768.

ERR_ZERO_SIZE

strlen=0

Remarks

Note

This procedure converts digits until it reaches non-digit character, or until value overflows.

extconv.dec_id

Description

Converts decimal string to signed dword (32bit) value. This is extended version, for simpler version see conv.dec_id .

Arguments

string

Pointer to string to convert.

buflen

Size of string's buffer. You can set this to -1 (FFFFFFFFh) if string is quaranteed to be properly zero-terminated.

allowplus

If 1, explicit "+" sign before number is allowed.

len

Pointer to dword variable, which will on return hold number of converted characters. Ignored if zero.

Returns

CF=1 on error, otherwise EAX = value.

Errors

ERR_INVALID_MODE

allowplus > 1

ERR_NOT_DECIMAL

First character of string is not decimal digit.

ERR_OUT_OF_RANGE

Value is greater than 2147483647 or lesser than -2147483648.

ERR_ZERO_SIZE

strlen=0

Remarks

Note

This procedure converts digits until it reaches non-digit character, or until value overflows.

extconv.dec_iq

Description

Converts decimal string to signed qword (64bit) value. This is extended version, for simpler version see conv.dec_iq .

Arguments

string

Pointer to string to convert.

buflen

Size of string's buffer. You can set this to -1 (FFFFFFFFh) if string is quaranteed to be properly zero-terminated.

allowplus

If 1, explicit "+" sign before number is allowed.

len

Pointer to dword variable, which will on return hold number of converted characters. Ignored if zero.

strlen

Returns

CF=1 on error, otherwise EDX:EAX = value.

Errors

ERR_INVALID_MODE

allowplus > 1

ERR_NOT_DECIMAL

First character of string is not decimal digit.

ERR_OUT_OF_RANGE

Value is greater than 9223372036854775807 or lesser than -9223372036854775808.

ERR_ZERO_SIZE

strlen=0

Remarks

Note

This procedure converts digits until it reaches non-digit character, or until value overflows.

To Hexadecimal

Following procedures convert to/from hexdecimal string representation.

conv.b_hex

Description

Converts unsigned byte (8bit) value to hexadecimal string. For more options use extconv.b_hex .

Arguments

dest

Pointer to destination string buffer.

destlen

Size of destination string buffer. Size 3 is always enough for this procedure.

value

Byte value to convert. Only low order byte of this dword is used, rest is ignored.

Returns

CF=1 on error.

Errors

ERR_BUFFER_FULL

Destination buffer is not big enough, must be at least 3 bytes. Only first destlen bytes of resulting string were written. String in destination buffer is NOT zero terminated.

ERR_ZERO_SIZE

destlen=0.


conv.w_hex

Description

Converts unsigned word (16bit) value to hexadecimal string. For more options use extconv.w_hex .

Arguments

dest

Pointer to destination string buffer.

destlen

Size of destination string buffer. Size 5 is always enough for this procedure.

value

Word value to convert. Only low order word of this dword is used, rest is ignored.

Returns

CF=1 on error.

Errors

ERR_BUFFER_FULL

Destination buffer is not big enough, must be at least 5 bytes. Only first destlen bytes of resulting string were written. String in destination buffer is NOT zero terminated.

ERR_ZERO_SIZE

destlen=0.


conv.d_hex

Description

Converts unsigned dword (32bit) value to hexadecimal string. For more options use extconv.d_hex .

Arguments

dest

Pointer to destination string buffer.

destlen

Size of destination string buffer. Size 9 is always enough for this procedure.

value

Dword value to convert.

Returns

CF=1 on error.

Errors

ERR_BUFFER_FULL

Destination buffer is not big enough, must be at least 9 bytes. Only first destlen bytes of resulting string were written. String in destination buffer is NOT zero terminated.

ERR_ZERO_SIZE

destlen=0.


conv.q_hex

Description

Converts unsigned qword (64bit) value to hexadecimal string. For more options use extconv.q_hex .

Arguments

dest

Pointer to destination string buffer.

destlen

Size of destination string buffer. Size 9 is always enough for this procedure.

valuelow

Low order dword of value to convert.

valuehigh

High order dword of value to convert.

Returns

CF=1 on error.

Errors

ERR_BUFFER_FULL

Destination buffer is not big enough (must be at least 17 bytes). Only first destlen bytes of resulting string were written. String in destination buffer is NOT zero terminated.

ERR_ZERO_SIZE

destlen=0.


conv.ib_hex

Description

Converts signed byte (8bit) value to hexadecimal string. For more options use extconv.ib_hex .

Arguments

dest

Pointer to destination string buffer.

destlen

Size of destination string buffer. Size 4 is always enough for this procedure.

value

Byte value to convert. Only low order byte of this dword is used, rest is ignored.

Returns

CF=1 on error.

Errors

ERR_BUFFER_FULL

Destination buffer is not big enough, must be at least 4 bytes. Only first destlen bytes of resulting string were written. String in destination buffer is NOT zero terminated.

ERR_ZERO_SIZE

destlen=0.


conv.iw_hex

Description

Converts signed word (16bit) value to hexadecimal string. For more options use extconv.iw_hex .

Arguments

dest

Pointer to destination string buffer.

destlen

Size of destination string buffer. Size 6 is always enough for this procedure.

value

Word value to convert. Only low order word of this dword is used, rest is ignored.

Returns

CF=1 on error.

Errors

ERR_BUFFER_FULL

Destination buffer is not big enough, must be at least 6 bytes. Only first destlen bytes of resulting string were written. String in destination buffer is NOT zero terminated.

ERR_ZERO_SIZE

destlen=0.


conv.id_hex

Description

Converts signed dword (32bit) value to decimal string. For more options use extconv.id_hex .

Arguments

dest

Pointer to destination string buffer.

destlen

Size of destination string buffer. Size 10 is always enough for this procedure.

value

Dword value to convert.

Returns

CF=1 on error.

Errors

ERR_BUFFER_FULL

Destination buffer is not big enough, must be at least 10 bytes. Only first destlen bytes of resulting string were written. String in destination buffer is NOT zero terminated.

ERR_ZERO_SIZE

destlen=0.


conv.iq_hex

Description

Converts signed qword (64bit) value to decimal string. For more options use extconv.iq_hex .

Arguments

dest

Pointer to destination string buffer.

destlen

Size of destination string buffer. Size 18 is always enough for this procedure.

valuelow

Low order dword of value to convert.

valuehigh

High order dword of value to convert.

Returns

CF=1 on error.

Errors

ERR_BUFFER_FULL

Destination buffer is not big enough, must be at least 18 bytes. Only first destlen bytes of resulting string were written. String in destination buffer is NOT zero terminated.

ERR_ZERO_SIZE

destlen=0.


extconv.b_hex

Description

Converts unsigned byte (8bit) value to hex string. Supports padding of output with spaces or zeroes. For simpler version see conv.b_hex .

Arguments

dest

Pointer to destination string buffer.

destlen

Size of destination string buffer.

value

Byte value to convert. Only low order byte of this dword is used, rest is ignored.

padding

Type of padding: type 0 is no padding, type 1 is prepending with spaces, type 2 is prepending with leading zeroes.

padlen

Length to which should output be padded. If output is already longer than this value before padding, then output is not padded. Ignored if padding = 0.

len

Pointer to dword variable, which will on return hold length of output (terminating zero not included). Ignored if zero.

Returns

CF=1 on error.

Errors

ERR_BUFFER_FULL

Destination buffer is not big enough. Only first destlen bytes of resulting string were written. String in destination buffer is NOT zero terminated. Variable pointed by len contains destlen

ERR_ZERO_SIZE

destlen=0. Variable pointed by len is set to 0.

ERR_INVALID_MODE

padding > 2. Variable pointed by len is set to 0.


extconv.w_hex

Description

Converts unsigned word (16bit) value to hex string. Supports padding of output with spaces or zeroes. For simpler version see conv.w_hex .

Arguments

dest

Pointer to destination string buffer.

destlen

Size of destination string buffer.

value

Word value to convert. Only low order word of this dword is used, rest is ignored.

padding

Type of padding: type 0 is no padding, type 1 is prepending with spaces, type 2 is prepending with leading zeroes.

padlen

Length to which should output be padded. If output is already longer than this value before padding, then output is not padded. Ignored if padding = 0.

len

Pointer to dword variable, which will on return hold length of output (terminating zero not included). Ignored if zero.

Returns

CF=1 on error.

Errors

ERR_BUFFER_FULL

Destination buffer is not big enough. Only first destlen bytes of resulting string were written. String in destination buffer is NOT zero terminated. Variable pointed by len contains destlen

ERR_ZERO_SIZE

destlen=0. Variable pointed by len is set to 0.

ERR_INVALID_MODE

padding > 2. Variable pointed by len is set to 0.


extconv.d_hex

Description

Converts unsigned dword (32bit) value to hex string. Supports padding of output with spaces or zeroes. For simpler version see conv.d_hex .

Arguments

dest

Pointer to destination string buffer.

destlen

Size of destination string buffer.

value

Dword value to convert.

padding

Type of padding: type 0 is no padding, type 1 is prepending with spaces, type 2 is prepending with leading zeroes.

padlen

Length to which should output be padded. If output is already longer than this value before padding, then output is not padded. Ignored if padding = 0.

len

Pointer to dword variable, which will on return hold length of output (terminating zero not included). Ignored if zero.

Returns

CF=1 on error.

Errors

ERR_BUFFER_FULL

Destination buffer is not big enough. Only first destlen bytes of resulting string were written. String in destination buffer is NOT zero terminated. Variable pointed by len contains destlen

ERR_ZERO_SIZE

destlen=0. Variable pointed by len is set to 0.

ERR_INVALID_MODE

padding > 2. Variable pointed by len is set to 0.


extconv.q_hex

Description

Converts unsigned qword (64bit) value to hex string. Supports padding of output with spaces or zeroes. For simpler version see conv.q_hex .

Arguments

dest

Pointer to destination string buffer.

destlen

Size of destination string buffer.

valuelow

Low order dword of value to convert.

valuehigh

High order dword of value to convert.

padding

Type of padding: type 0 is no padding, type 1 is prepending with spaces, type 2 is prepending with leading zeroes.

padlen

Length to which should output be padded. If output is already longer than this value before padding, then output is not padded. Ignored if padding = 0.

len

Pointer to dword variable, which will on return hold length of output (terminating zero not included). Ignored if zero.

Returns

CF=1 on error.

Errors

ERR_BUFFER_FULL

Destination buffer is not big enough. Only first destlen bytes of resulting string were written. String in destination buffer is NOT zero terminated. Variable pointed by len contains destlen

ERR_ZERO_SIZE

destlen=0. Variable pointed by len is set to 0.

ERR_INVALID_MODE

padding > 2. Variable pointed by len is set to 0.


extconv.ib_hex

Description

Converts signed byte (8bit) value to hex string. Supports padding of output with spaces or zeroes, and explicit plus sign. For simpler version see conv.ib_hex .

Arguments

dest

Pointer to destination string buffer.

destlen

Size of destination string buffer.

value

Byte value to convert. Only low order byte of this dword is used, rest is ignored.

padding

Type of padding: Type 0 is no padding. Type 1 is prepending with spaces, and sign counts into padding size. Type 2 is prepending with leading zeroes. In this type padlen specifies number digits displayed. One more character is always printed as sign (' ', '+' or '-').

padlen

Length to which should output be padded. If output is already longer than this value before padding, then output is not padded. Ignored if padding = 0.

plus

Set to 1 if you want to display plus sign on positive numbers.

len

Pointer to dword variable, which will on return hold length of output (terminating zero not included). Ignored if zero.

Returns

CF=1 on error.

Errors

ERR_BUFFER_FULL

Destination buffer is not big enough. Only first destlen bytes of resulting string were written. String in destination buffer is NOT zero terminated. Variable pointed by len contains destlen

ERR_ZERO_SIZE

destlen=0. Variable pointed by len is set to 0.

ERR_INVALID_MODE

padding > 2, or plus > 1 Variable pointed by len is set to 0.


extconv.iw_hex

Description

Converts signed word (16bit) value to hex string. Supports padding of output with spaces or zeroes, and explicit plus sign. For simpler version see conv.iw_hex .

Arguments

dest

Pointer to destination string buffer.

destlen

Size of destination string buffer.

value

Word value to convert. Only low order word of this dword is used, rest is ignored.

padding

Type of padding: Type 0 is no padding. Type 1 is prepending with spaces, and sign counts into padding size. Type 2 is prepending with leading zeroes. In this type padlen specifies number of digits displayed. One more character is always printed as sign (' ', '+' or '-').

padlen

Length to which should output be padded. If output is already longer than this value before padding, then output is not padded. Ignored if padding = 0.

plus

Set to 1 if you want to display plus sign on positive numbers.

len

Pointer to dword variable, which will on return hold length of output (terminating zero not included). Ignored if zero.

Returns

CF=1 on error.

Errors

ERR_BUFFER_FULL

Destination buffer is not big enough. Only first destlen bytes of resulting string were written. String in destination buffer is NOT zero terminated. Variable pointed by len contains destlen

ERR_ZERO_SIZE

destlen=0. Variable pointed by len is set to 0.

ERR_INVALID_MODE

padding > 2, or plus > 1 Variable pointed by len is set to 0.


extconv.id_hex

Description

Converts signed dword (32bit) value to hex string. Supports padding of output with spaces or zeroes, and explicit plus sign. For simpler version see conv.id_hex .

Arguments

dest

Pointer to destination string buffer.

destlen

Size of destination string buffer.

value

Dword value to convert.

padding

Type of padding: Type 0 is no padding. Type 1 is prepending with spaces, and sign counts into padding size. Type 2 is prepending with leading zeroes. In this type padlen specifies number digits displayed. One more character is always printed as sign (' ', '+' or '-').

padlen

Length to which should output be padded. If output is already longer than this value before padding, then output is not padded. Ignored if padding = 0.

plus

Set to 1 if you want to display plus sign on positive numbers.

len

Pointer to dword variable, which will on return hold length of output (terminating zero not included). Ignored if zero.

Returns

CF=1 on error.

Errors

ERR_BUFFER_FULL

Destination buffer is not big enough. Only first destlen bytes of resulting string were written. String in destination buffer is NOT zero terminated. Variable pointed by len contains destlen

ERR_ZERO_SIZE

destlen=0. Variable pointed by len is set to 0.

ERR_INVALID_MODE

padding > 2, or plus > 1 Variable pointed by len is set to 0.


extconv.iq_hex

Description

Converts signed qword (64bit) value to hex string. Supports padding of output with spaces or zeroes, and explicit plus sign. For simpler version see conv.iq_hex .

Arguments

dest

Pointer to destination string buffer.

destlen

Size of destination string buffer.

valuelow

Low order dword of value to convert.

valuehigh

High order dword of value to convert.

padding

Type of padding: Type 0 is no padding. Type 1 is prepending with spaces, and sign counts into padding size. Type 2 is prepending with leading zeroes. In this type padlen specifies number digits displayed. One more character is always printed as sign (' ', '+' or '-').

padlen

Length to which should output be padded. If output is already longer than this value before padding, then output is not padded. Ignored if padding = 0.

plus

Set to 1 if you want to display plus sign on positive numbers.

len

Pointer to dword variable, which will on return hold length of output (terminating zero not included). Ignored if zero.

Returns

CF=1 on error.

Errors

ERR_BUFFER_FULL

Destination buffer is not big enough. Only first destlen bytes of resulting string were written. String in destination buffer is NOT zero terminated. Variable pointed by len contains destlen

ERR_ZERO_SIZE

destlen=0. Variable pointed by len is set to 0.

ERR_INVALID_MODE

padding > 2, or plus > 1 Variable pointed by len is set to 0.

From Hexadecimal

Following procedures convert to/from hexdecimal string representation.

conv.hex_b

Description

Converts hexadecimal string to unsigned byte (8bit) value.

Arguments

string

Pointer to string to convert.

buflen

Size of string's buffer. You can set this to -1 (FFFFFFFFh) if string is quaranteed to be properly zero-terminated.

Returns

CF=1 on error, otherwise EAX = value (AL zero extended to dword).

Errors

ERR_NOT_HEXADECIMAL

First character of string is not hexadecimal digit.

ERR_OUT_OF_RANGE

Value is > FF

ERR_ZERO_SIZE

strlen=0

Remarks

Note

This procedure converts digits until it reaches non-digit character, or until value overflows.

Note

To get number of converted characters, use extconv.hex_b .

conv.hex_w

Description

Converts hexadecimal string to unsigned word (16bit) value.

Arguments

string

Pointer to string to convert.

buflen

Size of string's buffer. You can set this to -1 (FFFFFFFFh) if string is quaranteed to be properly zero-terminated.

Returns

CF=1 on error, otherwise EAX = value (AX zero extended to dword).

Errors

ERR_NOT_HEXADECIMAL

First character of string is not hexadecimal digit.

ERR_OUT_OF_RANGE

Value is > FFFF

ERR_ZERO_SIZE

strlen=0

Remarks

Note

This procedure converts digits until it reaches non-digit character, or until value overflows.

Note

To get number of converted characters, use extconv.hex_w .

conv.hex_d

Description

Converts hexadecimal string to unsigned dword (32bit) value.

Arguments

string

Pointer to string to convert.

buflen

Size of string's buffer. You can set this to -1 (FFFFFFFFh) if string is quaranteed to be properly zero-terminated.

Returns

CF=1 on error, otherwise EAX = value.

Errors

ERR_NOT_HEXADECIMAL

First character of string is not hexadecimal digit.

ERR_OUT_OF_RANGE

Value is > FFFFFFFF

ERR_ZERO_SIZE

strlen=0

Remarks

Note

This procedure converts digits until it reaches non-digit character, or until value overflows.

Note

To get number of converted characters, use extconv.hex_d .

conv.hex_q

Description

Converts hexadecimal string to unsigned qword (64bit) value.

Arguments

string

Pointer to string to convert.

buflen

Size of string's buffer. You can set this to -1 (FFFFFFFFh) if string is quaranteed to be properly zero-terminated.

Returns

CF=1 on error, otherwise EDX:EAX = value.

Errors

ERR_NOT_HEXADECIMAL

First character of string is not hexadecimal digit.

ERR_OUT_OF_RANGE

Value is > FFFFFFFFFFFFFFFF

ERR_ZERO_SIZE

strlen=0

Remarks

Note

This procedure converts digits until it reaches non-digit character, or until value overflows.

Note

To get number of converted characters, use extconv.hex_q .

conv.hex_ib

Description

Converts hexadecimal string to signed byte (8bit) value.

Arguments

string

Pointer to string to convert.

buflen

Size of string's buffer. You can set this to -1 (FFFFFFFFh) if string is quaranteed to be properly zero-terminated.

Returns

CF=1 on error, otherwise EAX = value.

Errors

ERR_NOT_HEXADECIMAL

First character of string is not hexadecimal digit.

ERR_OUT_OF_RANGE

Value is lesser than -80 or greater than 7F.

ERR_ZERO_SIZE

strlen=0

Remarks

Note

This procedure converts digits until it reaches non-digit character, or until value overflows.

Note

To get number of converted characters, use extconv.hex_ib .

conv.hex_iw

Description

Converts hexadecimal string to signed word (16bit) value.

Arguments

string

Pointer to string to convert.

buflen

Size of string's buffer. You can set this to -1 (FFFFFFFFh) if string is quaranteed to be properly zero-terminated.

Returns

CF=1 on error, otherwise EAX = value.

Errors

ERR_NOT_HEXADECIMAL

First character of string is not hexadecimal digit.

ERR_OUT_OF_RANGE

Value is lesser than -8000 or greater than 7FFF.

ERR_ZERO_SIZE

strlen=0

Remarks

Note

This procedure converts digits until it reaches non-digit character, or until value overflows.

Note

To get number of converted characters, use extconv.hex_iw .

conv.hex_id

Description

Converts hexadecimal string to signed dword (32bit) value.

Arguments

string

Pointer to string to convert.

buflen

Size of string's buffer. You can set this to -1 (FFFFFFFFh) if string is quaranteed to be properly zero-terminated.

Returns

CF=1 on error, otherwise EAX = value.

Errors

ERR_NOT_HEXADECIMAL

First character of string is not hexadecimal digit.

ERR_OUT_OF_RANGE

Value is lesser than -80000000 or greater than 7FFFFFFF.

ERR_ZERO_SIZE

strlen=0

Remarks

Note

This procedure converts digits until it reaches non-digit character, or until value overflows.

Note

To get number of converted characters, use extconv.hex_id .

conv.hex_iq

Description

Converts hexadecimal string to signed qword (64bit) value.

Arguments

string

Pointer to string to convert.

buflen

Size of string's buffer. You can set this to -1 (FFFFFFFFh) if string is quaranteed to be properly zero-terminated.

Returns

CF=1 on error, otherwise EAX = value.

Errors

ERR_NOT_HEXADECIMAL

First character of string is not hexadecimal digit.

ERR_OUT_OF_RANGE

Value is lesser than -8000000000000000 or greater than 7FFFFFFFFFFFFFFF.

ERR_ZERO_SIZE

strlen=0

Remarks

Note

This procedure converts digits until it reaches non-digit character, or until value overflows.

Note

To get number of converted characters, use extconv.hex_iq .

extconv.hex_b

Description

Converts hexadecimal string to unsigned byte (8bit) value. This is extended version, for simpler version see conv.hex_b .

Arguments

string

Pointer to string to convert.

buflen

Size of string's buffer. You can set this to -1 (FFFFFFFFh) if string is quaranteed to be properly zero-terminated.

len

Pointer to dword variable, which will on return hold number of converted characters. Ignored if zero.

Returns

CF=1 on error, otherwise EAX = value (AL zero extended to dword).

Errors

ERR_NOT_HEXADECIMAL

First character of string is not hexadecimal digit.

ERR_OUT_OF_RANGE

Value is > FF

ERR_ZERO_SIZE

strlen=0

Remarks

Note

This procedure converts digits until it reaches non-digit character, or until value overflows.

extconv.hex_w

Description

Converts hexadecimal string to unsigned word (16bit) value. This is extended version, for simpler version see conv.hex_w .

Arguments

string

Pointer to string to convert.

buflen

Size of string's buffer. You can set this to -1 (FFFFFFFFh) if string is quaranteed to be properly zero-terminated.

len

Pointer to dword variable, which will on return hold number of converted characters. Ignored if zero.

Returns

CF=1 on error, otherwise EAX = value (AX zero extended to dword).

Errors

ERR_NOT_HEXADECIMAL

First character of string is not hexadecimal digit.

ERR_OUT_OF_RANGE

Value is > FFFF

ERR_ZERO_SIZE

strlen=0

Remarks

Note

This procedure converts digits until it reaches non-digit character, or until value overflows.

extconv.hex_d

Description

Converts hexadecimal string to unsigned dword (32bit) value. This is extended version, for simpler version see conv.hex_d .

Arguments

string

Pointer to string to convert.

buflen

Size of string's buffer. You can set this to -1 (FFFFFFFFh) if string is quaranteed to be properly zero-terminated.

len

Pointer to dword variable, which will on return hold number of converted characters. Ignored if zero.

Returns

CF=1 on error, otherwise EAX = value.

Errors

ERR_NOT_HEXADECIMAL

First character of string is not hexadecimal digit.

ERR_OUT_OF_RANGE

Value is > FFFFFFFF

ERR_ZERO_SIZE

strlen=0

Remarks

Note

This procedure converts digits until it reaches non-digit character, or until value overflows.

extconv.hex_q

Description

Converts hexadecimal string to unsigned qword (64bit) value. This is extended version, for simpler version see conv.hex_q .

Arguments

string

Pointer to string to convert.

buflen

Size of string's buffer. You can set this to -1 (FFFFFFFFh) if string is quaranteed to be properly zero-terminated.

len

Pointer to dword variable, which will on return hold number of converted characters. Ignored if zero.

strlen

Returns

CF=1 on error, otherwise EDX:EAX = value.

Errors

ERR_NOT_HEXADECIMAL

First character of string is not hexadecimal digit.

ERR_OUT_OF_RANGE

Value is > FFFFFFFFFFFFFFFF

ERR_ZERO_SIZE

strlen=0

Remarks

Note

This procedure converts digits until it reaches non-digit character, or until value overflows.

extconv.hex_ib

Description

Converts hexadecimal string to signed byte (8bit) value. This is extended version, for simpler version see conv.hex_ib .

Arguments

string

Pointer to string to convert.

buflen

Size of string's buffer. You can set this to -1 (FFFFFFFFh) if string is quaranteed to be properly zero-terminated.

allowplus

If 1, explicit "+" sign before number is allowed.

len

Pointer to dword variable, which will on return hold number of converted characters. Ignored if zero.

Returns

CF=1 on error, otherwise EAX = value.

Errors

ERR_NOT_HEXADECIMAL

First character of string is not hexadecimal digit.

ERR_OUT_OF_RANGE

Value is lesser than -80 or greater than 7F.

ERR_ZERO_SIZE

strlen=0

Remarks

Note

This procedure converts digits until it reaches non-digit character, or until value overflows.

extconv.hex_iw

Description

Converts hexadecimal string to signed word (16bit) value. This is extended version, for simpler version see conv.hex_iw .

Arguments

string

Pointer to string to convert.

buflen

Size of string's buffer. You can set this to -1 (FFFFFFFFh) if string is quaranteed to be properly zero-terminated.

allowplus

If 1, explicit "+" sign before number is allowed.

len

Pointer to dword variable, which will on return hold number of converted characters. Ignored if zero.

Returns

CF=1 on error, otherwise EAX = value.

Errors

ERR_NOT_HEXADECIMAL

First character of string is not hexadecimal digit.

ERR_OUT_OF_RANGE

Value is lesser than -8000 or greater than 7FFF.

ERR_ZERO_SIZE

strlen=0

Remarks

Note

This procedure converts digits until it reaches non-digit character, or until value overflows.

extconv.hex_id

Description

Converts hexadecimal string to signed dword (32bit) value. This is extended version, for simpler version see conv.hex_id .

Arguments

string

Pointer to string to convert.

buflen

Size of string's buffer. You can set this to -1 (FFFFFFFFh) if string is quaranteed to be properly zero-terminated.

allowplus

If 1, explicit "+" sign before number is allowed.

len

Pointer to dword variable, which will on return hold number of converted characters. Ignored if zero.

Returns

CF=1 on error, otherwise EAX = value.

Errors

ERR_NOT_HEXADECIMAL

First character of string is not hexadecimal digit.

ERR_OUT_OF_RANGE

Value is lesser than -80000000 or greater than 7FFFFFFF.

ERR_ZERO_SIZE

strlen=0

Remarks

Note

This procedure converts digits until it reaches non-digit character, or until value overflows.

extconv.hex_iq

Description

Converts hexadecimal string to signed qword (64bit) value. This is extended version, for simpler version see conv.hex_iq .

Arguments

string

Pointer to string to convert.

buflen

Size of string's buffer. You can set this to -1 (FFFFFFFFh) if string is quaranteed to be properly zero-terminated.

allowplus

If 1, explicit "+" sign before number is allowed.

len

Pointer to dword variable, which will on return hold number of converted characters. Ignored if zero.

strlen

Returns

CF=1 on error, otherwise EAX = value.

Errors

ERR_NOT_HEXADECIMAL

First character of string is not hexadecimal digit.

ERR_OUT_OF_RANGE

Value is lesser than -8000000000000000 or greater than 7FFFFFFFFFFFFFFF.

ERR_ZERO_SIZE

strlen=0

Remarks

Note

This procedure converts digits until it reaches non-digit character, or until value overflows.

Chapter 5. Memory Management

FASMLIB memory management provides you basic heap functions, like allocation, rellocation, getting size of block and releasing allocated block. Additionally, it provides functions to copy, fill, compare, and search blocks of memory. There is extensive checking for invalid pointers, invalid size and heap corruption in the code.

Functions working with memory allocation require you to initialize memory management before they can be used. After you are done with using these function, you should uninitialize memory management. During uninitialization, heap corruption and memory leaks are checked.

If OS provides heap management (win32) then this one is used. If OS doesn't provide heap management (linux) then FASMLIB uses it's own heap manager.

Manipulation

Following are procedures for manipulation with static memory.

mem.copy

Description

Copies contents block of memory of given size to another place. Supports overlapped copy (like "memmove" in C).

Arguments

dest

pointer to destination place, to where the block will be copied

src

pointer to source place, from where the block will be copied

size

number of bytes to copy

Returns

CF = 1 on error, otherwise EAX = dest

Errors

ERR_INVALID_POINTER

some of pointers point to inaccessible area

Remarks

Note

Supports overlapped copy, eg. case when src < dest < src+size.

Note

Does nothing when size=0

Note

Memory management doesn't have to be initalized for this to work

mem.fill

Description

Fills block of memory with given dword pattern.

Arguments

dest

Pointer to block which we will fill.

size

Size of block to fill. If size isn't multiple of 4, remaining bytes will be filled with according bytes of filler (little endian).

value

Dword value with which the block is filled.

Returns

CF = 1 on error, otherwise EAX = dest

Errors

ERR_INVALID_POINTER

dest points to inaccessible area

Remarks

Note

Does nothing when size=0

Note

Memory management doesn't have to be initalized for this to work

mem.cmp

Description

Compares contents of two blocks of memory. If they are different, returns offset of position where they are different. Additionally it says which block contents "is bigger", useful for sorting.

Arguments

block1

Pointer to beginning of first memory block

block2

Pointer to beginning of second memory block

size

Number of bytes to compare

Returns

CF = 1 on error, otherwise {flagscmp:flags set for signed conditional jumps}, and if ZF=0, EAX = offset in blocks (not pointer) where blocks differ

Errors

ERR_INVALID_POINTER

some of pointers point to inaccessible area

ERR_ZERO_SIZE

size=0

Remarks

Note

When ZF=1 (blocks are equal), EAX=size on return

Note

Memory management doesn't have to be initalized for this to work

mem.find

Description

Finds first occurence of given block of memory in another block of memory. Uses fast Horspool algorithm.

Arguments

block

Pointer to block in which we will search.

blocksize

Size of block in which we search.

pattern

Pointer to pattern which we are looking for.

patternsize

Size of pattern block.

Returns

CF = 1 on error, otherwise ZF = 1 if not found, otherwise EAX = offset (not pointer) in block, where the pattern was found

Errors

ERR_INVALID_POINTER

some of pointers point to inaccessible area

ERR_ZERO_SIZE

blocksize=0 or patternsize=0

+mem.fill
+mem.cmp

Remarks

Note

Returned EAX can be in range 0 to block+blocksize-patternsize

Note

Memory management doesn't have to be initalized for this to work

Heap

Heap is a standard way to provide flexible memory allocations. It allows you to easily allocate blocks of memory, resize them, and release them when they are no longer needed.

Procedures

This is list of FASMLIB procedures for manipulation with heap.

mem.init

Description

Initializes FASMLIB memory managent. You need to call this procedure to use any of following procedures: mem.alloc , mem.alloc0 , mem.realloc , mem.realloc0 , mem.free , mem.size .

Arguments

None

Returns

CF set on error

Errors

ERR_OUT_OF_MEM

Not enough memory

ERR_UNKNOWN

System returned error that wasn't translated to FASMLIB error. You can contact author about this, and translation can be added.

+mem.alloc_heap

Only on platforms where FASMLIB heap manager is used.

Remarks

Warning

Don't forget to always uninitialize memory management with mem.uninit !

Note

This procedure is called by fasmlib.init . You can use it for lazy initialization of entire library.

Note

If memory management is already initialized, this procedure does nothing

Note

This is platform-specific procedure

mem.uninit

Description

Unitializes FASMLIB memory managent. When module is not initialized, you cannot use following procedures: mem.alloc , mem.alloc0 , mem.realloc , mem.realloc0 , mem.free , mem.size . This procedure also checks for heap corruption and memory leaks .

Arguments

None

Returns

CF set on error

Errors

ERR_MEMORY_LEAK

You've got a memory leak . Check all places where you call mem.alloc or mem.alloc0 , whether you always release allocated block with mem.free . Also check if you didn't forget to uninitialize standard streams prior to calling this procedure.

ERR_HEAP_CORRUPT

Heap is corrupted . You was writing to memory outside of allocated block.

ERR_MODULE_NOT_INITIALIZED

Module is not initialized. Initialize module with mem.init first.

ERR_UNKNOWN

System returned error that wasn't translated to FASMLIB error. You can contact author about this, and translation can be added.

+mem.free_heap

Only on platforms where FASMLIB heap manager is used

Remarks

Note

This procedure is called by fasmlib.uninit . You can use it for lazy uninitialization of entire library.

Note

This is platform-specific procedure

mem.alloc

Description

Allocates block of memory.

Arguments

size

Size of block to allocate, in bytes.

Returns

CF set on error, otherwise EAX = pointer to allocated memory block

Errors

ERR_OUT_OF_MEM

Not enough memory

ERR_ZERO_SIZE

size = 0

ERR_OUT_OF_RANGE

size is negative (or larger than 7FFFFFFFh if viewed as unsigned)

ERR_HEAP_CORRUPT

Heap is corrupted . You was writing to memory outside of allocated block.

ERR_MODULE_NOT_INITIALIZED

Module is not initialized. Initialize module with mem.init to use this procedure.

ERR_UNKNOWN

System returned error that wasn't translated to FASMLIB error. You can contact author about this, and translation can be added.

+mem.realloc_heap

Only on platforms where FASMLIB heap manager is used.

Remarks

Warning

Don't forget to release allocated block with mem.free !

Warning

Contents of allocated memory are unknown (use mem.alloc0 to get block zeroed).

Note

Returned pointer is always >= 10000h to make it easily distinguishable from handles.

Note

Maximal allowed size is 7FFFFFFFh, to catch errors with negative values.

Note

Altough returned block may have bigger size than requested on some implementations, don't use this additional memory. mem.realloc doesn't preserve this memory.

Note

Memory management must be initialized for this procedure to work.

Note

This is platform-specific procedure

mem.alloc0

Description

Allocates block of memory, and fills it with zeroes.

Arguments

size

Size of memory to allocate

Returns

CF set on error, otherwise EAX = pointer to beginning of allocated memory block

Errors

ERR_OUT_OF_MEM

Not enough memory

ERR_ZERO_SIZE

size = 0

ERR_OUT_OF_RANGE

size is negative (or larger than 7FFFFFFFh if viewed as unsigned)

ERR_HEAP_CORRUPT

Heap is corrupted . You was writing to memory outside of allocated block.

ERR_MODULE_NOT_INITIALIZED

Module is not initialized. Initialize module with mem.init to use this procedure.

ERR_UNKNOWN

System returned error that wasn't translated to FASMLIB error. You can contact author about this, and translation can be added.

+mem.alloc
+mem.fill

Remarks

Warning

Don't forget to release allocated block with mem.free !

Note

returned pointer must be always >= 10000h

Note

Returned pointer is always >= 10000h to make it easily distinguishable from handles.

Note

Maximal allowed size is 7FFFFFFFh, to catch errors with negative values.

Note

Altough returned block may have bigger size than requested on some implementations, don't use this additional memory. It is not zeroes, an mem.realloc doesn't preserve this memory.

Note

Memory management must be initialized for this procedure to work.

Note

This is platform-specific procedure

mem.free

Description

Releases allocated block of memory returned from mem.alloc , mem.alloc0 , mem.realloc , or mem.realloc0 .

Arguments

blockptr

Pointer to allocated memory block. This must be same pointer as returned from allocation function, pointer into block is not enough.

Returns

CF set on error

Errors

ERR_INVALID_POINTER

Blockptr is not a valid allocated block pointer. This could also mean heap corruption , these two cases cannot be properly distinguished.

ERR_HEAP_CORRUPT

Heap is corrupted . You was writing to memory outside of allocated block.

ERR_MODULE_NOT_INITIALIZED

Module is not initialized. Initialize module with mem.init to use this procedure.

ERR_UNKNOWN

System returned error that wasn't translated to FASMLIB error. You can contact author about this, and translation can be added.

Remarks

Note

If this procedure returns error, consider block released, and don't use it anymore.

Note

Memory management must be initialized for this procedure to work.

Note

This is platform-specific procedure

mem.realloc

Description

Rellocates (resizes) block of memory returned from mem.alloc , mem.alloc0 , mem.realloc , or mem.realloc0 . Block can be moved during this process, so you need to update pointer(s) to it. Contents of block are preserved. If block is enlarging, contents of added space are unknown, use mem.realloc0 to have them zeroed.

Arguments

blockptr

Pointer to block to relocate. This must be same pointer as returned from allocation function, pointer into block is not enough.

newsize

New size of block, in bytes

Returns

CF set on error, orherwise EAX = pointer to reallocated memory block

Errors

ERR_INVALID_POINTER

Blockptr is not a valid allocated block pointer. This could also mean heap corruption , these two cases cannot be properly distinguished.

ERR_OUT_OF_MEM

Not enough memory

ERR_ZERO_SIZE

size = 0

ERR_OUT_OF_RANGE

size is negative (or larger than 7FFFFFFFh if viewed as unsigned)

ERR_HEAP_CORRUPT

Heap is corrupted . You was writing to memory outside of allocated block.

ERR_MODULE_NOT_INITIALIZED

Module is not initialized. Initialize module with mem.init to use this procedure.

ERR_UNKNOWN

System returned error that wasn't translated to FASMLIB error. You can contact author about this, and translation can be added.

+mem.realloc_heap

Only on platforms where FASMLIB heap manager is used.

Remarks

Warning

Block can be moved during realocation! If you had any pointers to block, they become invalid (so rather prefer using indexes to allocated blocks). If you saved block pointer in variable, you need to rewrite it with returned value.

Note

If block was enlarging, contents of added memory are unknown. Use mem.realloc0 to have them zeroed.

Note

Returned pointer is always >= 10000h to make it easily distinguishable from handles.

Note

Maximal allowed newsize is 7FFFFFFFh, to catch errors with negative values.

Note

Altough returned block may have bigger size than requested on some implementations, don't use this additional memory. mem.realloc doesn't preserve this memory.

Note

Memory management must be initialized for this procedure to work.

Note

This is platform-specific procedure

mem.realloc0

Description

Rellocates (resizes) block of memory. Block can be moved during this process, so you need to update pointer(s) to it. Contents of block are preserved. If block is enlarging, contents of added space are filled with zeroes.

Arguments

blockptr

Pointer to block to relocate. This must be same pointer as returned from allocation function, pointer into block is not enough.

newsize

New size of block, in bytes

Returns

CF set on error, orherwise EAX = pointer to reallocated memory block

Errors

ERR_INVALID_POINTER

Blockptr is not a valid allocated block pointer. This could also mean heap corruption , these two cases cannot be properly distinguished.

ERR_OUT_OF_MEM

Not enough memory

ERR_ZERO_SIZE

size = 0

ERR_OUT_OF_RANGE

size is negative (or larger than 7FFFFFFFh if viewed as unsigned)

ERR_HEAP_CORRUPT

Heap is corrupted . You was writing to memory outside of allocated block.

ERR_MODULE_NOT_INITIALIZED

Module is not initialized. Initialize module with mem.init to use this procedure.

ERR_UNKNOWN

System returned error that wasn't translated to FASMLIB error. You can contact author about this, and translation can be added.

+mem.realloc_heap

Only on platforms where FASMLIB heap manager is used.

+mem.size
+mem.realloc
+mem.fill

Remarks

Warning

Block can be moved during realocation! If you had any pointers to block, they become invalid (so rather prefer using indexes to allocated blocks). If you saved block pointer in variable, you need to rewrite it with returned value.

Note

Returned pointer is always >= 10000h to make it easily distinguishable from handles.

Note

Maximal allowed newsize is 7FFFFFFFh, to catch errors with negative values.

Note

Altough returned block may have bigger size than requested on some implementations, don't use this additional memory. mem.realloc doesn't preserve this memory.

Note

Memory management must be initialized for this procedure to work.

Note

This is platform-specific procedure

mem.size

Description

Returns size of memory block allocated by mem.alloc , mem.alloc0 , mem.realloc , or mem.realloc0 .

Arguments

blockptr

Pointer to allocated memory block. This must be same pointer as returned from allocation function, pointer into block is not enough.

Returns

CF set on error, otherwise EAX = size of allocated block

Errors

ERR_INVALID_POINTER

Blockptr is not a valid allocated block pointer. This could also mean heap corruption , these two cases cannot be properly distinguished.

ERR_HEAP_CORRUPT

Heap is corrupted . You was writing to memory outside of allocated block.

ERR_MODULE_NOT_INITIALIZED

Module is not initialized. Initialize module with mem.init to use this procedure.

ERR_UNKNOWN

System returned error that wasn't translated to FASMLIB error. You can contact author about this, and translation can be added.

Remarks

Note

Memory management must be initialized for this procedure to work.

Note

This is platform-specific procedure

Internal Procedures

These are internal procedures of FASMLIB heap manager. These procedures may not be present at all. FASMLIB heap manager is used only when OS doesn't provide heap functions.

mem.alloc_heap

Description

This is internal procedure of heap manager, that handles platform-dependent aspect of allocating entire heap. Do not call this procedure.

Arguments

size

Initial size of heap to allocate.

Returns

CF set on error, otherwise EAX = pointer to allocated memory block

Errors

ERR_OUT_OF_MEM

Not enough memory

ERR_ZERO_SIZE

size = 0

ERR_OUT_OF_RANGE

size is negative (or larger than 7FFFFFFFh if viewed as unsigned)

ERR_UNKNOWN

System returned error that wasn't translated to FASMLIB error. You can contact author about this, and translation can be added.

Remarks

Warning

Don't call this procedure!

Note

Returned pointer is always >= 10000h to make it easily distinguishable from handles.

Note

This procedure is used only on platforms where FASM heap manager is used.

mem.realloc_heap

Description

This is internal procedure of heap manager, that handles platform-dependent aspect of resizing entire heap. Do not call this procedure.

Arguments

heapptr

Pointer to heap block returned by mem.alloc_heap or by this procedure.

oldsize

Current size of heap. Must be provided by caller.

newsize

Desired size of heap.

Returns

CF set on error, otherwise EAX = heapptr

Errors

ERR_INVALID_POINTER

Heap pointer is invalid

ERR_OUT_OF_MEM

Not enough memory

ERR_ZERO_SIZE

newsize = 0

ERR_OUT_OF_RANGE

size is negative (or larger than 7FFFFFFFh if viewed as unsigned)

ERR_UNKNOWN

System returned error that wasn't translated to FASMLIB error. You can contact author about this, and translation can be added.

Remarks

Warning

Don't call this procedure!

Warning

Heap cannot be moved during resizing.

Note

Data in heap must be preserved.

Note

If block is enlarging, then contents of added memory are unknown

mem.free_heap

Description

This is internal procedure of heap manager, that handles platform-dependent aspect of deallocating entire heap. Do not call this procedure.

Arguments

heapptr

Pointer to heap, returned by mem.alloc_heap or mem.realloc_heap .

heapsize

Current size of heap. Must be provided by caller.

Returns

Nothing

Errors

ERR_INVALID_POINTER

Heap pointer is invalid

ERR_UNKNOWN

System returned error that wasn't translated to FASMLIB error. You can contact author about this, and translation can be added.

Heap - How it works

Term Heap usually means area of memory containing all allocated blocks.

Term Heap Manager is used for routine that takes care of managing heap.

First, heap is initialized. This means heap manager allocates block of memory that will act as heap.

Heap is divided into blocks of varying size. Each block can be used (allocated) or unused. Consectutive unused blocks are merged into one. During allocation, heap manager searches blocks until it finds unused large enough block, and returns it. It can also split remaining unused space from block to create new block.

After long-term usage of heap, allocated blocks are spread among entire heap, not grouped together. There are small unused spaces between blocks, unlikely to be large enough for most allocations. This wastes memory, but it is never completely avoidable. This is called Heap Fragmentation.

One way how FASMLIB's heap manager prevents heap fragmentation is aligning block size to some higher value (64 by default, can be changed). Block still beheaves to caller as if it was smaller, but it's real size in heap is multiple of 64bytes. This makes small increases in size of block much faster, and prevents creation of very small blocks.

Every heap block is prepended by Block Header. Block header holds all info that heap manager needs about block. Problem pops out when user mistakenly overwrites this block header. Then, it is impossible to properly manage heap, and heap-managing procedure cannot continue to work. After this is detected, all heap procedures return ERR_HEAP_CORRUPT until you call mem.uninit to destroy heap.

Sometimes it is not possible for procedure to distinguish invalid pointer from corrupted heap. This can result in returning ERR_INVALID_POINTER instead of ERR_HEAP_CORRUPT. Anyway, both these errors are internal problem of your application, and should be investigated and solved.

Memory Leak

Memory Leak is state, when you allocate some memory, and forget to release it. Such memory, even if not used anymore by code that allocated it, cannot be used, until memory management is uninitialized (usually at application exit). We say such memory is leaked.

Some people argue that memory is freed anyway as the application exits. This may be true, but still it isn't "right" way to do things. Also, if application is designed to be running for longer time, and it has code causing memory leak in it's looping part, then application's memory usage keeps growing, just by running. This is definitively bad.

Preventing memory leaks is not always so easy. In simplest case, each time you allocate block of memory, you immediately write the code to release it too. But sometimes you need to return allocated block to caller, and he must take care of releasing. So, when calling procedure that returns allocated block, be just as cautious as when allocating it yourself, and think lot if the block is released in every case.

FASMLIB helps you catching memory leaks as soon as your application producing them ends. If your application leaks some memory, it returns error ERR_MEMORY_LEAK when you call mem.uninit. FASMLIB finds memory leak by very simple mechanism: it counts all successful allocations, and if number of releasing isn't same, it's memory leak.

If mem.uninit returns you ERR_MEMORY_LEAK, you should browse through all your allocations, and check if allocated block is released in all cases. Most probably problem will be in recently added allocations, if you wasn't getting ERR_MEMORY_LEAK before.

Chapter 6. File I/O

FASMLIB provides several procedures to access files.

These routines are just wrappers of system procedures, and provide only basic access to files. You may want to use file streams instead.

Filesystem routines (directory access, disk enumeration, ...) are not supported yet.

fileio.create

Description

Creates new file, and returns handle to it.

Arguments

name

Name of file to create.

overwr

Sets behavior if file already exists: 1 = overwrites file, 0 = returns ERR_FILE_EXISTS.

mode

Sets access mode to file: 1 = write only, 2 = read/write

Returns

CF = 1 on error, otherwise EAX = file handle

Errors

ERR_FILE_EXISTS

File with given name already exists (only returned if mode=0)

ERR_CANT_OPEN_FILE

File can't be created.

ERR_INVALID_MODE

mode is not 0 or 1.

ERR_UNKNOWN

Platform-specific error during creating file.

Remarks

Warning

Don't forget to close returned handle with fileio.close !

Note

This is platform-dependent procedure

fileio.open

Description

Opens existing file.

Arguments

name

Pointer to name of file to open. Must be zero-terminated string.

mode

Access mode to file: 0=read only, 1=write only, 2=read/write.

Returns

CF = 1 on error, otherwise EAX = file handle

Errors

ERR_FILE_NOT_FOUND

File with specified name wasn't found.

ERR_CANT_OPEN_FILE

File exists, but couldn't be opened.

ERR_INVALID_MODE

mode > 2.

ERR_UNKNOWN

Platform-specific error during opening file.

Remarks

Warning

Don't forget to close returned handle with fileio.close !

Note

This is platform-dependent procedure

fileio.append

Description

Opens existing file for writing, and sets pointer to end of file.

Arguments

name

Pointer to name of file to open. Must be zero-terminated string.

create

Specifies whether to create file if it doesn't exist. 1=create, 0=don't create.

mode

Access mode to file: 1=write only, 2=read/write.

Returns

CF = 1 on error, otherwise EAX = file handle

Errors

ERR_FILE_NOT_FOUND

File with specified name wasn't found. Only returned when create=0.

ERR_CANT_OPEN_FILE

File exists, but couldn't be opened.

ERR_INVALID_MODE

mode=0, or mode>2, or create>1.

ERR_UNKNOWN

Platform-specific error during opening file.

+fileio.open
+fileio.create
+fileio.seek
+fileio.close

Remarks

Warning

Don't forget to close returned handle with fileio.close !

Note

This is platform-dependent procedure

fileio.read

Description

Reads data from file.

Arguments

handle

File handle (returned by fileio.open , fileio.create or fileio.append ).

buffer

Pointer to buffer where to read data.

count

Number of bytes to read.

Returns

CF set on error, otherwise EAX = number of bytes readen, and OF set if EOF was reached (less than count bytes read)

Errors

ERR_INVALID_HANDLE

Invalid handle.

ERR_ZERO_SIZE

count=0.

ERR_UNKNOWN

Platform-specific error.

Remarks

Note

This is platform-dependent procedure

fileio.write

Description

Writes data to file.

Arguments

handle

File handle (returned by fileio.open , fileio.create or fileio.append ).

buffer

Pointer to data to write.

count

Size of daata to write. Procedure does nothing if this is zero.

Returns

CF set on error

Errors

ERR_INVALID_HANDLE

Invalid handle.

ERR_UNKNOWN

Platform-specific error.

Remarks

Note

This is platform-dependent procedure

fileio.seek

Description

Moves file pointer to given position in file. Distance to move is 64bit value.

Arguments

handle

File handle (returned by fileio.open , fileio.create or fileio.append ).

distlow

Low order dword of distance to move.

disthigh

High order dword of distance to move.

mode

Mode of seeking. 0 = seek from beginning. 1 = seek relative distance from current position. 2 = seek from end (distance should be negative value).

Returns

CF set on error

Errors

ERR_NEGATIVE_SEEK

Seek to negative file offset.

ERR_INVALID_HANDLE

Invalid file handle.

ERR_OUT_OF_RANGE

dist<0 when mode=0.

ERR_INVALID_MODE

mode>2.

ERR_UNKNOWN

Remarks

Note

This procedure doesn't return new position in file. Use fileio.tell to get current position in file.

Note

Seeking behind end of file is platform-dependant. On win32 it is allowed, but file doesn't increase until you write something to it. TODO - check this on linux.

Note

This is platform-dependent procedure

fileio.tell

Description

Returns current position in file. Position is 64bit value.

Arguments

handle

File handle (returned by fileio.open , fileio.create or fileio.append ).

Returns

CF set on error, otherwise EDX:EAX = current position in file

Errors

ERR_INVALID_HANDLE

Invalid file handle.

ERR_UNKNOWN

Remarks

Note

This is platform-dependent procedure

fileio.size

Description

Returns size of opened file. Returned value is 64bit value.

Arguments

handle

File handle (returned by fileio.open , fileio.create or fileio.append ).

Returns

CF set on error, otherwise EDX:EAX = size of file in bytes

Errors

ERR_INVALID_HANDLE

Invalid file handle.

ERR_UNKNOWN

+fileio.tell
+fileio.seek

Remarks

Note

This is platform-dependent procedure

fileio.close

Description

Closes file handle.

Arguments

handle

File handle (returned by fileio.open , fileio.create or fileio.append ).

Returns

CF set on error

Errors

ERR_INVALID_HANDLE

Invalid handle passed

ERR_UNKOWN

Platform-specific error.

Remarks

Note

This is platform-dependent procedure

Chapter 7. Process Management

FASMLIB process management isn't very rich yet :)

process.exit

Description

exits application

Arguments

code

System exit code. 0 usually means everything okay, and higher codes means error. Use ascending values (1,2,3...), not -1, because bitwidth of exit code is less than 32bits on some systems.

Returns

Well... in theory CF is set on error, otherwise it doesn't return. Don't mind...

Errors

None

Chapter 8. Streams

FASMLIB Stream is just simply some thing, that you can write to and/or read from. Purpose of stream, is that they put everything that can behave this way under single interface. That means, if you have file, memory, and console as streams, then you can access them with exacly same code. It is slower than specialized code, but it prevents lot of code duplication.

Like every abstraction, streams are not good for everything. Using streams is slower and gives you less possibilities. But there is couple of things where streams are very useful.

Examples of what can be represented of stream:

  • Console is natural stream, for both reading and writing.

  • File is typical stream, and it also allows you to seek any position within file.

  • Block of memory can act as stream, for both reading and writing, and is seekable too.

  • Dynamic memory block is useful as stream for writing, because it can be enlarged any time to needed size, and you don't need to worry about buffer overflow.

  • Socket (network connection) is another typical stream.

Anoter advantage of stream, is that you can nest them. This means that one stream can write it's output to another stream. This way you can write flexible routines, like:

  • Text converter (EOL converter, locale converter).

  • Some types of data conversion.

  • Most types of encryption.

And, these routines can be reused on anything that is represented as stream. They can also be combined to use more such streams at once. For example, you can create chain of streams: create file stream, overload with base64 conversion, overload with compression, and overload with AES encryption. Then, when you write to topmost stream, actual data written to file will be encrypted with AES, compressed, converted to base64 and stored. When you want to write this data to socket, instead of file, you just replace file stream with socket stream. When you want different compression, you just replace that stream. So as you see, streams can be pretty useful, for some things.

Stream interface

Following is description of interface of FASMLIB streams. You don't need to understand most of following information, unless you want to create your own stream.

FASMLIB streams are implemented as typical objects, like ones from C++ or COM. Every stream object is structure stored in memory. First member of structure is pointer to virtual table. Virtual table holds addresses of methods associated with that object. Other members of stream structure are data of stream. Stream handle is just a pointer to stream object.

Users of library don't call methods directly, from virtual table. They use method wrapper procedures instead.

Stream Object

Structure of stream object is defined as STREAM in FASMLIB. Every stream object must have this structure, and it can have some additional data behind this structure. In OOP terms, STREAM is a base class.

Stream object consists of fields: (order of fields is different in actual structure)

DWORD vtab

Pointer to virtual table of this object. Virtual table holds pointers to methods used with this object.

BYTE allocated

Says whether stream object was allocated, and should be released on close, or if it is in static memory. If this is 1, then stream object memory would be freed with mem.free when stream.close is called.

BYTE wbuf.type

Type of write buffering. 0 means no buffering, 1 means static buffer, 2 means dynamic buffer.

DWORD wbuf

Pointer to beginning of write buffer. Can be 0, if no buffer is currently associated with stream.

DWORD wbuf.size

Size of read buffer.

DWORD wbuf.pos

Position of data inside write buffer. Only valid when wbuf.cnt is nonzero. This is index inside buffer, not pointer. Must be 0 if read buffer is disabled.

DWORD wbuf.cnt

Number of bytes stored in write buffer. When zero, buffer is empty. Must be 0 if read buffer is disabled.

BYTE rbuf.type

Type of read buffering. 0 means no buffering, 1 means static buffer, 2 means dynamic buffer.

DWORD rbuf

Pointer to beginning of read buffer. Can be 0, if no buffer is currently associated with stream.

DWORD rbuf.size

Size of read buffer

DWORD rbuf.pos

Position of data inside read buffer. Only valid when rbuf.cnt is nonzero. This is index inside buffer, not pointer. Must be 0 if read buffer is disabled.

DWORD rbuf.cnt

Number of bytes stored in buffer. When zero, buffer is empty. Must be 0 if read buffer is disabled.

BYTE rbuf.eof

Indicates that EOF was reached behind data that is in buffer.

Stream Virtual Table

Stream virtual table holds pointers to methods. Every stream class (file stream, stdout stream, ...) has it's own virtual table. Every stream object of that class points to it's virtual table.

Every stream virtual table starts with signature dword 'STRM'. This helps catching invalid pointers to stream objects.

Following signature, stream virtual table consists of pointers to these methods:

Methods

These are stream methods. Stream methods are just procedures with particular interface, that implement some functionality of stream.

Stream may or may not have each method implemented. Methods which are implemented are pointed by virtual table of given stream. Methods that are not implemented have zero pointer in virtual table.

These methods aren't called directly, you use method wrappers instead.

stream close method

Description

Contains additional tasks which must be done when stream is closing

Arguments

stream

Stream handle to close.

Returns

CF set on error.


stream write method

Description

Write method writes data to stream.

Arguments

stream

Handle of stream to which we write.

buffer

Pointer to data to write.

count

Number of bytes to write. Procedure does nothing if count=0.

Returns

CF set on error

Errors

ERR_INVALID_HANDLE

Not a valid stream handle.

ERR_STREAM_NOT_WRITABLE

Stream is not writeable.


stream read method

Description

Reads data from stream to specified buffer. Blocks until enough data is read, or EOF occurs. Returns OF, if EOF occurs before requested ammount of bytes is read.

Arguments

stream

Handle of stream from which to read.

buffer

Pointer to buffer where data will be stored.

count

Number of bytes to read. Cannot be 0.

readbuf

Pointer to procedure that does actual reading. Procedure recieves pointer to memory where to read, and number of bytes to read.

Returns

CF set on error, otherwise OF set if EOF was reached, and EAX = number of bytes readen. If OF=0, then EAX=count.


stream peek method

Description

Pre-reads data from stream, and returns you pointer to them. Data still remain in stream, and will be readen by subsequent reads. Returned pointer is only valid until next operation with stream. Blocks until there is enough data available.

Arguments

stream

Handle of stream.

count

Number of bytes to peek.

readlen

Pointer to variable, which will hold number of chars in returned buffer. Only needed when function returns OF, otherwise it's equal to count. Ignored if 0.

Returns

CF set on error, otherwise OF set if EOF was reached (less than count bytes readen), and EAX = pointer to buffer (READ ONLY, do not write there)

Remarks

Warning

Pointer to buffer becomes invalid after next operation with stream.

stream skip method

Description

Skips data from stream input. Skipping is like reading from stream, without actually storing readen data anywhere. Can be implemented with seeking forward.

Arguments

stream

Handle of stream to skip from.

count

Number of bytes to skip. Procedure does nothing if this is 0.

Returns

CF set on error, otherwise OF set if EOF was reached, and EAX = number of bytes skipped. If OF=0, then EAX=count.


stream seek method

Description

Moves data pointer to given position. Distance to move is 64bit value.

Arguments

stream

Handle of stream.

distlow

Low order dword of distance to move.

disthigh

High order dword of distance to move.

mode

Mode of seeking. 0 = seek from beginning. 1 = seek relative distance from current position. 2 = seek from end (distance should be negative value).

Returns

CF set on error

Remarks

Note

Seek method is quaranteed to be called with proper mode. Check is done in stream.seek.

stream tell method

Description

Returns current position in stream. Position is 64 bit number.

Arguments

stream

Handle of stream.

Returns

CF set on error, otherwise EDX:EAX = new position in file

Method Wrappers

Listed procedures are wrappers, which allow calling stream methods like normal procedures. They hide OOP aspect of streams from users of library.

stream.create

Description

Creates stream object. This call allows you to create static objects, dynamic object with static buffer, or dynamic objects with dynamic buffer.

Arguments

objbuf

Pointer to buffer to hold stream object. size of buffer must be at least "sizeof.STREAM". Set to 0 if you want procedure to allocate stream.

size

Number of additional bytes to allocate with object. These can be used to store additional data for methods. This value must be 0, if objbuf is nonzero (static stream object).

vtab

Points to object's virtual table . If readbuf=0, then peek method in virtual table must be 0.

readbuf

Pointer to read buffer. 0 if none, 1 for dynamic buffer. Must be 0 if read method pointer is 0 in vtab.

rbuflen

Size of read buffer. If readbuf=0, ignored. If readbuf=1, initial size of read buffer (allocated at creation). If readbuf=pointer, size of buffer. Must be 0 if read method pointer is 0 in vtab.

writebuf

Pointer to write buffer, 0 if none, 1 for dynamic buffer. Must be 0 if write method pointer is 0 in vtab.

wbuflen

Size of write buffer. If writebuf=0, ignored. If writebuf=1, initial size of buffer (allocated at creation). If writebuf=pointer, size of buffer. Must be 0 if write method pointer is 0 in vtab.

Returns

CF=1 on error, otherwise EAX = pointer to created stream object (eg. handle of stream).

Errors

ERR_HANDLE_NOT_READABLE

read=0 and some of peek, skip, readbug, rbuflen is non-zero.

ERR_OUT_OF_RANGE

size<0.

+mem.alloc0

When pointer=0.

+mem.alloc

When readbuf=1 or writebuf=1.

+mem.fill
+mem.free

Remarks

Warning

Don't forget to close stream with stream.close

Warning

If you disable read buffering (rbuf=0), then you can't use peek , or any procedures that require peek. Most text reading procedures will fail.

Note

When pointer=0 and size>0, then additional memory is filled with zeroes.

Note

To create default (completely dynamic) stream, set objbuf=0, readbuf=1, rbuflen=0, writebuf=1, wbuflen=0.

stream.close

Description

Closes stream handle. If stream object was allocated, or it's buffers were allocated, they are deallocated.

Arguments

stream

Stream handle to close.

Returns

CF set on error.

Errors

ERR_INVALID_HANDLE

Not a valid stream handle.

ERR_HANDLE_CORRUPT

Handle is corrupt. Probably you have overwriten stream object in memory. This might also be a FASMLIB bug.

+mem.free
+stream close method

stream.write

Description

Writes data from buffer to stream.

Arguments

stream

Handle of stream to which we write.

buffer

Pointer to data to write.

count

Number of bytes to write. Procedure does nothing if count=0.

Returns

CF set on error

Errors

ERR_INVALID_HANDLE

Not a valid stream handle.

ERR_STREAM_NOT_WRITABLE

Stream is not writeable.

+stream write method

stream.write.byte

Description

Writes one byte to stream.

Arguments

stream

Handle of stream to which we write.

value

Byte value to write. Only low order byte of this dword is used, rest is ignored.

Returns

CF set on error

Errors

ERR_INVALID_HANDLE

Not a valid stream handle.

ERR_STREAM_NOT_WRITABLE

Stream is not writeable.

+stream.write

Remarks

Note

This is just a helper procedure to call stream write method .

stream.write.word

Description

Writes one word (2 bytes) to stream.

Arguments

stream

Handle of stream to which we write.

value

Word value to write. Only low order word of this dword is used, rest is ignored.

Returns

CF set on error

Errors

ERR_INVALID_HANDLE

Not a valid stream handle.

ERR_STREAM_NOT_WRITABLE

Stream is not writeable.

+stream.write

Remarks

Note

This is just a helper procedure to call stream write method .

stream.write.dword

Description

Writes one dword (4 bytes) to stream.

Arguments

stream

Handle of stream to which we write.

value

Dword value to write.

Returns

CF set on error

Errors

ERR_INVALID_HANDLE

Not a valid stream handle.

ERR_STREAM_NOT_WRITABLE

Stream is not writeable.

+stream.write

Remarks

Note

This is just a helper procedure to call stream write method .

stream.read

Description

Reads data from stream to buffer. Blocks until enough data is read, or EOF occurs. Returns OF, if EOF occurs before requested ammount of bytes is read.

Arguments

stream

Handle of stream from which to read.

buffer

Pointer to buffer where data will be stored.

count

Number of bytes to read. Cannot be 0.

readbuf

Pointer to procedure that does actual reading. Procedure recieves pointer to memory where to read, and number of bytes to read.

Returns

CF set on error, otherwise OF set if EOF was reached, and EAX = number of bytes readen. If OF=0, then EAX=count.

Errors

ERR_INVALID_HANDLE

Invalid stream handle.

ERR_STREAM_NOT_READABLE

Stream is not readable.

ERR_ZERO_SIZE

count=0.

ERR_HANDLE_CORRUPT

Stream is corrupt. Either you are overwriting stream object somewhere, or it is an error in FASMLIB.

+stream read method

stream.read.byte

Description

Reads one byte from stream. Returns OF if EOF is occured before reading byte.

Arguments

stream

Handle of stream to read from.

Returns

CF = 1 on error, otherwise OF = 1 if we are on EOF, otherwise AL = byte from stream


stream.peek

Description

Pre-reads data from stream, and returns you pointer to them. Data still remain in stream, and will be readen by subsequent reads. Returned pointer is only valid until next operation with stream. Blocks until there is enough data available.

Arguments

stream

Handle of stream.

count

Minimal number of bytes to peek.

readlen

Pointer to variable, which will hold number of chars in returned buffer. When function returns OF=0, this number is greater or equal to count. When function returns OF=1, this number is less than than count. You can set this pointer to 0.

Returns

CF set on error, otherwise OF set if EOF was reached (less than count bytes readen), and EAX = pointer to buffer (READ ONLY, do not write there)

Errors

ERR_ZERO_SIZE

Count=0

ERR_INVALID_HANDLE

Not a stream handle.

ERR_HANDLE_NO_BUFFER

Stream doesn't have read buffer associated, nor peek method supported.

ERR_HANDLE_NOT_PEEKABLE

Stream is not peekable.

ERR_BUFFER_FULL

Handle is associated with static buffer, with length smaller than count. Nothing was read from stream.

ERR_HANDLE_CORRUPT

Stream is corrupt, you are overwriting stream object somewhere (or it's error in FASMLIB).

+stream peek method

Remarks

Warning

Pointer to buffer becomes invalid after next operation with stream.

Warning

On OF=1, do not read buffer behind number of bytes returned in readlen variable. If you passed 0 as readlen, don't read from buffer at all.

Note

Stream must have peek method supported, or sufficently large read buffer.

stream.peek.byte

Description

Pre-reads byte from stream.. Returned byte still remain in stream, and will be readen by subsequent read. Blocks, if there is no data available.

Arguments

stream

Handle of stream.

Returns

CF set on error, otherwise OF set if EOF was reached, otherwise EAX = byte, zero extended to dword.

Errors

ERR_INVALID_HANDLE

Not a stream handle.

ERR_HANDLE_NO_BUFFER

Stream doesn't have read buffer associated, nor peek method supported.

ERR_HANDLE_NOT_PEEKABLE

Stream is not peekable.

ERR_HANDLE_CORRUPT

Stream is corrupt, you are overwriting stream object somewhere (or it's error in FASMLIB).

+stream.peek

Remarks

Note

Stream must have peek method supported, or read buffer.

stream.skip

Description

Skips data from stream input. Skipping is like reading from stream, without actually storing readen data anywhere.

Arguments

stream

Handle of stream to skip from.

count

Number of bytes to skip. Procedure does nothing if this is 0.

Returns

CF set on error, otherwise OF set if EOF was reached, and EAX = number of bytes skipped. If OF=0, then EAX=count.

Errors

ERR_INVALID_HANDLE

Invalid stream handle passed.

ERR_HANDLE_NOT_READABLE

Stream is not readable.

+stream skip method
+stream read method

Used when stream doesn't have a skip method.

Remarks

Warning

Don't use skip method to seek forward long distances. There is stream.seek for that. Skipping should be only used for small amount of data, and on streams that don't support seeking.

stream.seek

Description

Moves data pointer to given position. Distance to move is 64bit value.

Arguments

stream

Handle of stream.

distlow

Low order dword of distance to move.

disthigh

High order dword of distance to move.

mode

Mode of seeking. 0 = seek from beginning. 1 = seek relative distance from current position. 2 = seek from end (distance should be negative value).

Returns

CF set on error

Errors

ERR_NEGATIVE_SEEK

Seek to negative offset.

ERR_INVALID_MODE

mode > 2

ERR_HANDLE_NOT_SEEKABLE

This type of stream doesn't support seeking.

+stream seek method

Remarks

Note

This procedure doesn't return new position in file. Use stream.tell to find out new position.

stream.tell

Description

Returns current position in stream. Position is 64bit value.

Arguments

stream

Handle of stream.

Returns

CF set on error, otherwise EDX:EAX = current position in file.

Errors

ERR_HANDLE_NOT_SEEKABLE

This type of stream doesn't support seeking.

+stream tell method

Standard I/O Streams

On most today systems, there are three default streams present. They are STDIN (standard input), STDOUT (standard output) and STDERR (standard error).

FASMLIB contains predefined stream objects for these streams. They are called stdin, stdout and stderr. They are defined as static global variables.

stdin

stdin is read-only stream. When program tries to read from it, program enters "line editing mode", where user can edit one line of text.

If user types more characters than program requested to read, rest of input is saved, and is returned by subsequent reads. These reads do not issue "line editing mode" if enough characters are saved from previous read.

If user types less characters than program requested to read, then program enters line editing mode again, and lets him type another line, until there are enough characters.

stdin can be, and often is, redirected from file (or pipe). That means that data readen from stdin are not entered by user in console, as usually. Because of that, calling application must always be ready to handle EOF (end of file) coming from stdin.

Following procedures are wrappers for some other stream procedures. They use stdin stream by default. Other arguments remain same as in original procedures.

stdin.read.char

Description

This is just a call wrapper to text.read.char . It specifies stdin as stream, and passes rest of arguments.


stdin.read.line

Description

This is just a call wrapper to text.read.line . It specifies stdin as stream, and passes rest of arguments.


stdin.read.chars

Description

This is just a call wrapper to text.read.chars . It specifies stdin as stream, and passes rest of arguments.


stdin.read.until

Description

This is just a call wrapper to text.read.until . It specifies stdin as stream, and passes rest of arguments.


stdin.read.dec

Description

This is just a call wrapper to text.read.dec . It specifies stdin as stream, and passes rest of arguments.


stdin.read.dec_b

Description

This is just a call wrapper to text.read.dec_b . It specifies stdin as stream, and passes rest of arguments.


stdin.read.dec_w

Description

This is just a call wrapper to text.read.dec_w . It specifies stdin as stream, and passes rest of arguments.


stdin.read.dec_d

Description

This is just a call wrapper to text.read.dec_d . It specifies stdin as stream, and passes rest of arguments.


stdin.read.dec_q

Description

This is just a call wrapper to text.read.dec_q . It specifies stdin as stream, and passes rest of arguments.


stdin.read.idec

Description

This is just a call wrapper to text.read.idec . It specifies stdin as stream, and passes rest of arguments.


stdin.read.dec_ib

Description

This is just a call wrapper to text.read.dec_ib . It specifies stdin as stream, and passes rest of arguments.


stdin.read.dec_iw

Description

This is just a call wrapper to text.read.dec_iw . It specifies stdin as stream, and passes rest of arguments.


stdin.read.dec_id

Description

This is just a call wrapper to text.read.dec_id . It specifies stdin as stream, and passes rest of arguments.


stdin.read.dec_iq

Description

This is just a call wrapper to text.read.dec_iq . It specifies stdin as stream, and passes rest of arguments.


stdin.read.hex

Description

This is just a call wrapper to text.read.hex . It specifies stdin as stream, and passes rest of arguments.


stdin.read.hex_b

Description

This is just a call wrapper to text.read.hex_b . It specifies stdin as stream, and passes rest of arguments.


stdin.read.hex_w

Description

This is just a call wrapper to text.read.hex_w . It specifies stdin as stream, and passes rest of arguments.


stdin.read.hex_d

Description

This is just a call wrapper to text.read.hex_d . It specifies stdin as stream, and passes rest of arguments.


stdin.read.hex_q

Description

This is just a call wrapper to text.read.hex_q . It specifies stdin as stream, and passes rest of arguments.


stdin.read.ihex

Description

This is just a call wrapper to text.read.ihex . It specifies stdin as stream, and passes rest of arguments.


stdin.read.hex_ib

Description

This is just a call wrapper to text.read.hex_ib . It specifies stdin as stream, and passes rest of arguments.


stdin.read.hex_iw

Description

This is just a call wrapper to text.read.hex_iw . It specifies stdin as stream, and passes rest of arguments.


stdin.read.hex_id

Description

This is just a call wrapper to text.read.hex_id . It specifies stdin as stream, and passes rest of arguments.


stdin.read.hex_iq

Description

This is just a call wrapper to text.read.hex_iq . It specifies stdin as stream, and passes rest of arguments.


stdin.fetch

Description

This is just a call wrapper to text.fetch . It specifies stdin as stream, and passes rest of arguments.


stdin.fetch.char

Description

This is just a call wrapper to text.fetch.char . It specifies stdin as stream, and passes rest of arguments.


stdin.fetch.str

Description

This is just a call wrapper to text.fetch.str . It specifies stdin as stream, and passes rest of arguments.


stdin.skip.chars

Description

This is just a call wrapper to text.skip.chars . It specifies stdin as stream, and passes rest of arguments.


stdin.skip.until

Description

This is just a call wrapper to text.skip.until . It specifies stdin as stream, and passes rest of arguments.


stdin.extread.line

Description

This is just a call wrapper to text.extread.line . It specifies stdin as stream, and passes rest of arguments.


stdin.extread.chars

Description

This is just a call wrapper to text.extread.chars . It specifies stdin as stream, and passes rest of arguments.


stdin.extread.until

Description

This is just a call wrapper to text.extread.until . It specifies stdin as stream, and passes rest of arguments.


stdin.extread.dec

Description

This is just a call wrapper to text.extread.dec . It specifies stdin as stream, and passes rest of arguments.


stdin.extread.dec_b

Description

This is just a call wrapper to text.extread.dec_b . It specifies stdin as stream, and passes rest of arguments.


stdin.extread.dec_w

Description

This is just a call wrapper to text.extread.dec_w . It specifies stdin as stream, and passes rest of arguments.


stdin.extread.dec_d

Description

This is just a call wrapper to text.extread.dec_d . It specifies stdin as stream, and passes rest of arguments.


stdin.extread.dec_q

Description

This is just a call wrapper to text.extread.dec_q . It specifies stdin as stream, and passes rest of arguments.


stdin.extread.idec

Description

This is just a call wrapper to text.extread.idec . It specifies stdin as stream, and passes rest of arguments.


stdin.extread.dec_ib

Description

This is just a call wrapper to text.extread.dec_ib . It specifies stdin as stream, and passes rest of arguments.


stdin.extread.dec_iw

Description

This is just a call wrapper to text.extread.dec_iw . It specifies stdin as stream, and passes rest of arguments.


stdin.extread.dec_id

Description

This is just a call wrapper to text.extread.dec_id . It specifies stdin as stream, and passes rest of arguments.


stdin.extread.dec_iq

Description

This is just a call wrapper to text.extread.dec_iq . It specifies stdin as stream, and passes rest of arguments.


stdin.extread.hex

Description

This is just a call wrapper to text.extread.hex . It specifies stdin as stream, and passes rest of arguments.


stdin.extread.hex_b

Description

This is just a call wrapper to text.extread.hex_b . It specifies stdin as stream, and passes rest of arguments.


stdin.extread.hex_w

Description

This is just a call wrapper to text.extread.hex_w . It specifies stdin as stream, and passes rest of arguments.


stdin.extread.hex_d

Description

This is just a call wrapper to text.extread.hex_d . It specifies stdin as stream, and passes rest of arguments.


stdin.extread.hex_q

Description

This is just a call wrapper to text.extread.hex_q . It specifies stdin as stream, and passes rest of arguments.


stdin.extread.ihex

Description

This is just a call wrapper to text.extread.ihex . It specifies stdin as stream, and passes rest of arguments.


stdin.extread.hex_ib

Description

This is just a call wrapper to text.extread.hex_ib . It specifies stdin as stream, and passes rest of arguments.


stdin.extread.hex_iw

Description

This is just a call wrapper to text.extread.hex_iw . It specifies stdin as stream, and passes rest of arguments.


stdin.extread.hex_id

Description

This is just a call wrapper to text.extread.hex_id . It specifies stdin as stream, and passes rest of arguments.


stdin.extread.hex_iq

Description

This is just a call wrapper to text.extread.hex_iq . It specifies stdin as stream, and passes rest of arguments.


stdin.extskip.chars

Description

This is just a call wrapper to text.extskip.chars . It specifies stdin as stream, and passes rest of arguments.


stdin.extskip.until

Description

This is just a call wrapper to text.extskip.until . It specifies stdin as stream, and passes rest of arguments.

stdout

stdout is write-only stream. Anything you write to this stream is displayed on console.

Optionally, stdout can be redirected to file by parent application, but that doesn't matter to you.

Following procedures are wrappers for some other stream procedures. They use stdout stream by default. Other arguments remain same as in original procedures.

stdout.write

Description

This is just a call wrapper to text.write . It specifies stdout as stream, and passes rest of arguments.


stdout.write.char

Description

This is just a call wrapper to text.write.char . It specifies stdout as stream, and passes rest of arguments.


stdout.write.str

Description

This is just a call wrapper to text.write.str . It specifies stdout as stream, and passes rest of arguments.


stdout.write.format

Description

This is just a call wrapper to text.write.format . It specifies stdout as stream, and passes rest of arguments.


stdout.write.dec

Description

This is just a call wrapper to text.write.dec . It specifies stdout as stream, and passes rest of arguments.


stdout.write.b_dec

Description

This is just a call wrapper to text.write.b_dec . It specifies stdout as stream, and passes rest of arguments.


stdout.write.w_dec

Description

This is just a call wrapper to text.write.w_dec . It specifies stdout as stream, and passes rest of arguments.


stdout.write.d_dec

Description

This is just a call wrapper to text.write.d_dec . It specifies stdout as stream, and passes rest of arguments.


stdout.write.q_dec

Description

This is just a call wrapper to text.write.q_dec . It specifies stdout as stream, and passes rest of arguments.


stdout.write.idec

Description

This is just a call wrapper to text.write.idec . It specifies stdout as stream, and passes rest of arguments.


stdout.write.ib_dec

Description

This is just a call wrapper to text.write.ib_dec . It specifies stdout as stream, and passes rest of arguments.


stdout.write.iw_dec

Description

This is just a call wrapper to text.write.iw_dec . It specifies stdout as stream, and passes rest of arguments.


stdout.write.id_dec

Description

This is just a call wrapper to text.write.id_dec . It specifies stdout as stream, and passes rest of arguments.


stdout.write.iq_dec

Description

This is just a call wrapper to text.write.iq_dec . It specifies stdout as stream, and passes rest of arguments.


stdout.write.hex

Description

This is just a call wrapper to text.write.hex . It specifies stdout as stream, and passes rest of arguments.


stdout.write.b_hex

Description

This is just a call wrapper to text.write.b_hex . It specifies stdout as stream, and passes rest of arguments.


stdout.write.w_hex

Description

This is just a call wrapper to text.write.w_hex . It specifies stdout as stream, and passes rest of arguments.


stdout.write.d_hex

Description

This is just a call wrapper to text.write.d_hex . It specifies stdout as stream, and passes rest of arguments.


stdout.write.q_hex

Description

This is just a call wrapper to text.write.q_hex . It specifies stdout as stream, and passes rest of arguments.


stdout.write.ihex

Description

This is just a call wrapper to text.write.ihex . It specifies stdout as stream, and passes rest of arguments.


stdout.write.ib_hex

Description

This is just a call wrapper to text.write.ib_hex . It specifies stdout as stream, and passes rest of arguments.


stdout.write.iw_hex

Description

This is just a call wrapper to text.write.iw_hex . It specifies stdout as stream, and passes rest of arguments.


stdout.write.id_hex

Description

This is just a call wrapper to text.write.id_hex . It specifies stdout as stream, and passes rest of arguments.


stdout.write.iq_hex

Description

This is just a call wrapper to text.write.iq_hex . It specifies stdout as stream, and passes rest of arguments.


stdout.extwrite.dec

Description

This is just a call wrapper to text.extwrite.dec . It specifies stdout as stream, and passes rest of arguments.


stdout.extwrite.b_dec

Description

This is just a call wrapper to text.extwrite.b_dec . It specifies stdout as stream, and passes rest of arguments.


stdout.extwrite.w_dec

Description

This is just a call wrapper to text.extwrite.w_dec . It specifies stdout as stream, and passes rest of arguments.


stdout.extwrite.d_dec

Description

This is just a call wrapper to text.extwrite.d_dec . It specifies stdout as stream, and passes rest of arguments.


stdout.extwrite.q_dec

Description

This is just a call wrapper to text.extwrite.q_dec . It specifies stdout as stream, and passes rest of arguments.


stdout.extwrite.idec

Description

This is just a call wrapper to text.extwrite.idec . It specifies stdout as stream, and passes rest of arguments.


stdout.extwrite.ib_dec

Description

This is just a call wrapper to text.extwrite.ib_dec . It specifies stdout as stream, and passes rest of arguments.


stdout.extwrite.iw_dec

Description

This is just a call wrapper to text.extwrite.iw_dec . It specifies stdout as stream, and passes rest of arguments.


stdout.extwrite.id_dec

Description

This is just a call wrapper to text.extwrite.id_dec . It specifies stdout as stream, and passes rest of arguments.


stdout.extwrite.iq_dec

Description

This is just a call wrapper to text.extwrite.iq_dec . It specifies stdout as stream, and passes rest of arguments.


stdout.extwrite.hex

Description

This is just a call wrapper to text.extwrite.hex . It specifies stdout as stream, and passes rest of arguments.


stdout.extwrite.b_hex

Description

This is just a call wrapper to text.extwrite.b_hex . It specifies stdout as stream, and passes rest of arguments.


stdout.extwrite.w_hex

Description

This is just a call wrapper to text.extwrite.w_hex . It specifies stdout as stream, and passes rest of arguments.


stdout.extwrite.d_hex

Description

This is just a call wrapper to text.extwrite.d_hex . It specifies stdout as stream, and passes rest of arguments.


stdout.extwrite.q_hex

Description

This is just a call wrapper to text.extwrite.q_hex . It specifies stdout as stream, and passes rest of arguments.


stdout.extwrite.ihex

Description

This is just a call wrapper to text.extwrite.ihex . It specifies stdout as stream, and passes rest of arguments.


stdout.extwrite.ib_hex

Description

This is just a call wrapper to text.extwrite.ib_hex . It specifies stdout as stream, and passes rest of arguments.


stdout.extwrite.iw_hex

Description

This is just a call wrapper to text.extwrite.iw_hex . It specifies stdout as stream, and passes rest of arguments.


stdout.extwrite.id_hex

Description

This is just a call wrapper to text.extwrite.id_hex . It specifies stdout as stream, and passes rest of arguments.


stdout.extwrite.iq_hex

Description

This is just a call wrapper to text.extwrite.iq_hex . It specifies stdout as stream, and passes rest of arguments.

stderr

stderr is write-only stream. Anything you write to this stream is either displayed on console, or can be redirected to separate file.

You should write all normal output to stdout, and all error output to stderr. This allows to easily filter out error messages from normal output, just by redirecting stderr.

Following procedures are wrappers for some other stream procedures. They use stderr stream by default. Other arguments remain same as in original procedures.

stderr.write

Description

This is just a call wrapper to text.write . It specifies stderr as stream, and passes rest of arguments.


stderr.write.char

Description

This is just a call wrapper to text.write.char . It specifies stderr as stream, and passes rest of arguments.


stderr.write.str

Description

This is just a call wrapper to text.write.str . It specifies stderr as stream, and passes rest of arguments.


stderr.write.format

Description

This is just a call wrapper to text.write.format . It specifies stderr as stream, and passes rest of arguments.


stderr.write.dec

Description

This is just a call wrapper to text.write.dec . It specifies stderr as stream, and passes rest of arguments.


stderr.write.b_dec

Description

This is just a call wrapper to text.write.b_dec . It specifies stderr as stream, and passes rest of arguments.


stderr.write.w_dec

Description

This is just a call wrapper to text.write.w_dec . It specifies stderr as stream, and passes rest of arguments.


stderr.write.d_dec

Description

This is just a call wrapper to text.write.d_dec . It specifies stderr as stream, and passes rest of arguments.


stderr.write.q_dec

Description

This is just a call wrapper to text.write.q_dec . It specifies stderr as stream, and passes rest of arguments.


stderr.write.idec

Description

This is just a call wrapper to text.write.idec . It specifies stderr as stream, and passes rest of arguments.


stderr.write.ib_dec

Description

This is just a call wrapper to text.write.ib_dec . It specifies stderr as stream, and passes rest of arguments.


stderr.write.iw_dec

Description

This is just a call wrapper to text.write.iw_dec . It specifies stderr as stream, and passes rest of arguments.


stderr.write.id_dec

Description

This is just a call wrapper to text.write.id_dec . It specifies stderr as stream, and passes rest of arguments.


stderr.write.iq_dec

Description

This is just a call wrapper to text.write.iq_dec . It specifies stderr as stream, and passes rest of arguments.


stderr.write.hex

Description

This is just a call wrapper to text.write.hex . It specifies stderr as stream, and passes rest of arguments.


stderr.write.b_hex

Description

This is just a call wrapper to text.write.b_hex . It specifies stderr as stream, and passes rest of arguments.


stderr.write.w_hex

Description

This is just a call wrapper to text.write.w_hex . It specifies stderr as stream, and passes rest of arguments.


stderr.write.d_hex

Description

This is just a call wrapper to text.write.d_hex . It specifies stderr as stream, and passes rest of arguments.


stderr.write.q_hex

Description

This is just a call wrapper to text.write.q_hex . It specifies stderr as stream, and passes rest of arguments.


stderr.write.ihex

Description

This is just a call wrapper to text.write.ihex . It specifies stderr as stream, and passes rest of arguments.


stderr.write.ib_hex

Description

This is just a call wrapper to text.write.ib_hex . It specifies stderr as stream, and passes rest of arguments.


stderr.write.iw_hex

Description

This is just a call wrapper to text.write.iw_hex . It specifies stderr as stream, and passes rest of arguments.


stderr.write.id_hex

Description

This is just a call wrapper to text.write.id_hex . It specifies stderr as stream, and passes rest of arguments.


stderr.write.iq_hex

Description

This is just a call wrapper to text.write.iq_hex . It specifies stderr as stream, and passes rest of arguments.


stderr.extwrite.dec

Description

This is just a call wrapper to text.extwrite.dec . It specifies stderr as stream, and passes rest of arguments.


stderr.extwrite.b_dec

Description

This is just a call wrapper to text.extwrite.b_dec . It specifies stderr as stream, and passes rest of arguments.


stderr.extwrite.w_dec

Description

This is just a call wrapper to text.extwrite.w_dec . It specifies stderr as stream, and passes rest of arguments.


stderr.extwrite.d_dec

Description

This is just a call wrapper to text.extwrite.d_dec . It specifies stderr as stream, and passes rest of arguments.


stderr.extwrite.q_dec

Description

This is just a call wrapper to text.extwrite.q_dec . It specifies stderr as stream, and passes rest of arguments.


stderr.extwrite.idec

Description

This is just a call wrapper to text.extwrite.idec . It specifies stderr as stream, and passes rest of arguments.


stderr.extwrite.ib_dec

Description

This is just a call wrapper to text.extwrite.ib_dec . It specifies stderr as stream, and passes rest of arguments.


stderr.extwrite.iw_dec

Description

This is just a call wrapper to text.extwrite.iw_dec . It specifies stderr as stream, and passes rest of arguments.


stderr.extwrite.id_dec

Description

This is just a call wrapper to text.extwrite.id_dec . It specifies stderr as stream, and passes rest of arguments.


stderr.extwrite.iq_dec

Description

This is just a call wrapper to text.extwrite.iq_dec . It specifies stderr as stream, and passes rest of arguments.


stderr.extwrite.hex

Description

This is just a call wrapper to text.extwrite.hex . It specifies stderr as stream, and passes rest of arguments.


stderr.extwrite.b_hex

Description

This is just a call wrapper to text.extwrite.b_hex . It specifies stderr as stream, and passes rest of arguments.


stderr.extwrite.w_hex

Description

This is just a call wrapper to text.extwrite.w_hex . It specifies stderr as stream, and passes rest of arguments.


stderr.extwrite.d_hex

Description

This is just a call wrapper to text.extwrite.d_hex . It specifies stderr as stream, and passes rest of arguments.


stderr.extwrite.q_hex

Description

This is just a call wrapper to text.extwrite.q_hex . It specifies stderr as stream, and passes rest of arguments.


stderr.extwrite.ihex

Description

This is just a call wrapper to text.extwrite.ihex . It specifies stderr as stream, and passes rest of arguments.


stderr.extwrite.ib_hex

Description

This is just a call wrapper to text.extwrite.ib_hex . It specifies stderr as stream, and passes rest of arguments.


stderr.extwrite.iw_hex

Description

This is just a call wrapper to text.extwrite.iw_hex . It specifies stderr as stream, and passes rest of arguments.


stderr.extwrite.id_hex

Description

This is just a call wrapper to text.extwrite.id_hex . It specifies stderr as stream, and passes rest of arguments.


stderr.extwrite.iq_hex

Description

This is just a call wrapper to text.extwrite.iq_hex . It specifies stderr as stream, and passes rest of arguments.

stdstream.init

Description

Initializes three standard streams: stdin , stdout and stderr . You should call this procedure before using these streams.

Arguments

None

Returns

CF set on error

Errors

None

Remarks

Note

If standard streams are already initialized, this procedure does nothing.

Note

This procedure is called by fasmlib.init . You can use it for lazy initialization of entire library.

stdstream.uninit

Description

Uninitializes standard streams: stdin , stdout , stderr . You should call this procedure after you are done using these streams.

Arguments

None

Returns

CF set on error

Errors

ERR_MODULE_NOT_INITIALIZED

Module wasn't initialized. Initialize module with stdstream.init first.

+stream.close

Remarks

Warning

If you don't call this procedure, you may recieve ERR_MEMORY_LEAK from mem.uninit , because stream buffers will still be allocated.

Note

This procedure is called by fasmlib.uninit . You can use it for lazy uninitialization of entire library.

Note

stderr is not uninitialized, so it can be always used to print error. It also doesn't need to be initialized, because it is static data, and without buffering

Memory Stream

Memory streams put blocks of memory under stream interface.

Advantage of memory streams is that you can use text processing features of FASMLIB to work with memory.

Warning

If you want to use data in buffer as string, after filling it with text.write calls, you should also write zero byte to stream. "text" procedures don't write any zero bytes. Use stream.write.byte.

Methods

These are description of memory stream method specifics.

These methods aren't called directly, you use stream method wrappers instead.

mstream._write

Description

This is write method of memory stream . Don't call this procedure directly, use stream.write instead.

Arguments

stream

Handle of memory stream.

buffer

Pointer to data which we want to write.

count

Number of bytes to write.

Returns

CF set on error, otherwise OF set if EOF was reached (less than count bytes readen), and EAX = number of bytes readon.

Errors

ERR_BUFFER_FULL

Memory buffer is full. No more place to write.

ERR_ZERO_SIZE

count = 0.

+mem.copy

mstream._read

Description

This is read method of memory stream . Don't call this procedure directly, use stream.read instead.

Arguments

stream

Handle of memory stream.

buffer

Pointer to buffer where to store readen data.

count

Number of bytes to read.

Returns

CF set on error, otherwise OF set if EOF was reached (less than count bytes readen), and EAX = number of bytes readon.

Errors

ERR_ZERO_SIZE

count = 0.

+mem.copy

mstream._peek

Description

This is peek method of memory stream . Don't call this procedure directly, use stream.peek instead.

Arguments

stream

Handle of memory stream.

count

Number of bytes to peek.

readlen

Pointer to variable, which will hold number of chars in returned buffer. Always returns all bytes up to end of buffer.

Returns

CF set on error, otherwise OF set if EOF was reached (less than count bytes readen), and EAX = number of bytes readon.

Errors

ERR_ZERO_SIZE

count = 0.


mstream._seek

Description

This is seek method of file stream . Don't call this procedure directly, use stream.seek instead.

Arguments

stream

Handle of stream.

distlow

Low order dword of distance to move.

disthigh

High order dword of distance to move.

mode

Mode of seeking. 0 = seek from beginning. 1 = seek relative distance from current position. 2 = seek from end (distance should be negative value).

Returns

CF set on error

Errors

ERR_NEGATIVE_SEEK

Seek to negative file offset.


mstream._tell

Description

This is tell method of file stream . Don't call this procedure directly, use file.tell instead.

Arguments

stream

Handle of stream.

Returns

CF set on error, otherwise EDX:EAX = new position in file

Errors

None


mstream._skip

Description

This is skip method of memory stream . Don't call this procedure directly, use stream.skip instead.

Arguments

stream

Handle of memory stream.

count

Number of bytes to skip.

Returns

CF set on error, otherwise OF set if EOF was reached (less than count bytes skipped), and EAX = number of bytes skipped.

Errors

None

mstream.create

Description

Creates new memory stream . This is simple version. For more options see mstream.extcreate

Arguments

buffer

Pointer to buffer where memory stream begins

bufsz

Size of buffer of memory stream.

Returns

CF set on error, otherwise EAX = stream handle

Remarks

Warning

Don't forget to close stream with stream.close .

Warning

Don't access buffer directly while it is used by stream.

Note

If you try to write data behind end of buffer, write method returns ERR_BUFFER_FULL.

mstream.extcreate

Description

Creates new memory stream . This is extended version. For simpler usage see mstream.create

Arguments

objbuf

Pointer to buffer for MSTREAM object. If 0, object is allocated.

buffer

Pointer to buffer where memory stream begins

bufsz

Size of buffer of memory stream.

Returns

CF set on error, otherwise EAX = stream handle

Remarks

Warning

Don't forget to close stream with stream.close .

Warning

Don't access buffer directly while it is used by stream.

Note

If you try to write data behind end of buffer, write method returns ERR_BUFFER_FULL.

File Stream

File streams put file I/O under stream interface.

Advantage of file streams is that you can use other procedures that operate on streams, namely text processing features of FASMLIB. There is also better buffering support planned for future.

Methods

These are description of fstream method specifics.

These methods aren't called directly, you use stream method wrappers instead.

fstream._close

Description

This is close method of file stream . Don't call this procedure directly, use file.close instead.

Arguments

stream

Handle of file stream to write to.

Returns

CF set on error

Errors

ERR_HANDLE_CORRUPT

Stream is corrupted. This can happen if you close file handle used by stream. This can also happen if you overwrite stream object.

ERR_UNKNOWN

Platform-specific error.

+fileio.close

fstream._write

Description

This is write method of file stream . Don't call this procedure directly, use file.write instead.

Arguments

stream

Handle of file stream to write to.

buffer

Pointer to data which we want to write.

count

Number of bytes to write.

Returns

CF set on error.

Errors

ERR_HANDLE_CORRUPT

Stream is corrupted. This can happen if you close file handle used by stream. This can also happen if you overwrite stream object.

ERR_HANDLE_NOT_WRITEABLE

Stream is not readable.

ERR_UNKNOWN

Platform-specific error during writing to file.

+fileio.seek
+fileio.write

fstream._read

Description

This is read method of file stream . Don't call this procedure directly, use file.read instead.

Arguments

stream

Handle of file stream to read from.

buffer

Pointer to buffer where we want to read data.

count

Number of bytes to read.

Returns

CF set on error, otherwise OF set if EOF was reached (less than count bytes readen), and EAX = number of bytes readon.

Errors

ERR_HANDLE_CORRUPT

Stream is corrupted. This can happen if you close file handle used by stream. This can also happen if you overwrite stream object.

ERR_HANDLE_NOT_READABLE

Stream is not readable.

ERR_ZERO_SIZE

count = 0.

ERR_UNKNOWN

Platform-specific error during writing to file.


fstream._peek

Description

This is peek method of file stream . Don't call this procedure directly, use file.peek instead.

Arguments

stream

Handle of file stream to write to.

count

Number of bytes to peek.

readlen

Pointer to variable, which will hold number of chars in returned buffer. Only needed when function returns OF, otherwise it's equal to count. You can set this to 0, when you don't want handle case with OF=1.

Returns

CF set on error, otherwise OF set if EOF was reached (less than count bytes readen), and EAX = pointer to buffer (READ ONLY, do not write there)

Errors

ERR_HANDLE_CORRUPT

Stream is corrupted. This can happen if you close file handle used by stream. This can also happen if you overwrite stream object.

ERR_HANDLE_NOT_READABLE

Stream is not readable.

ERR_UNKNOWN

Platform-specific error during reading file.


fstream._seek

Description

This is seek method of file stream . Don't call this procedure directly, use file.seek instead.

Arguments

stream

Handle of file stream.

distlow

Low order dword of distance to move.

disthigh

High order dword of distance to move.

mode

Mode of seeking. 0 = seek from beginning. 1 = seek relative distance from current position. 2 = seek from end (distance should be negative value).

Returns

CF set on error

Errors

ERR_HANDLE_CORRUPT

Stream is corrupted. This can happen if you close file handle used by stream. This can also happen if you overwrite stream object.

ERR_UNKNOWN

Platform-specific error.

+fileio.seek

fstream._tell

Description

This is tell method of file stream . Don't call this procedure directly, use file.tell instead.

Arguments

stream

Handle of stream.

Returns

CF set on error, otherwise EDX:EAX = new position in file

Errors

ERR_HANDLE_CORRUPT

Stream is corrupted. This can happen if you close file handle used by stream. This can also happen if you overwrite stream object.

ERR_UNKNOWN

Platform-specific error.

+fileio.tell

Aliases

These are just some aliases for those who like file.read more than stream.read...

file.close

Description

This is alias for stream.close


file.write

Description

This is alias for stream.write


file.write.byte

Description

This is alias for stream.write.byte


file.write.word

Description

This is alias for stream.write.word


file.write.dword

Description

This is alias for stream.write.dword


file.read

Description

This is alias for stream.read


file.read.byte

Description

This is alias for stream.read.byte


file.peek

Description

This is alias for stream.peek


file.peek.byte

Description

This is alias for stream.peek.byte


file.seek

Description

This is alias for stream.seek


file.tell

Description

This is alias for stream.tell

file.create

Description

Creates new file, and returns stream handle.

Arguments

name

Name of file to create

overwr

Sets behavior if file already exists: 1 = overwrites file, 0 = returns ERR_FILE_EXISTS

mode

Sets access mode: 1 = write only, 2 = read/write

Returns

CF = 1 on error, otherwise EAX = stream handle

Errors

ERR_FILE_EXISTS

File with given name already exists (only returned if overwr=0)

ERR_CANT_OPEN_FILE

File can't be created.

ERR_INVALID_MODE

mode = 0, or mode > 2, or overwr > 1

ERR_UNKNOWN

Platform-specific error during creating file.

+file.extcreate

Remarks

Warning

Don't forget to close returned file stream with stream.close !

Note

This is simple version, see file.extcreate for more options.

Note

Opens file as stream, if you want direct file I/O use fileio.create .

file.extcreate

Description

Creates new file, and returns stream handle.

Arguments

objbuf

Pointer to buffer for FSTREAM object. If 0, object is allocated.

name

Name of file to create

overwr

Sets behavior if file already exists: 1 = overwrites file, 0 = returns ERR_FILE_EXISTS

mode

Sets access mode: 1 = write only, 2 = read/write

wbuf

RESERVED, must be 0

wbuflen

RESERVED, must be 0

rbuf

Pointer to read buffer. If 1, buffer will be allocated, and wbuflen holds initial size. If 0, read buffering is disabled. Must be 0 if mode = 1.

rbuflen

If rbuf=pointer, this is size of buffer. If rbuf=1, this is initial size of buffer. If rbuf=0, ignored. Must be 0 if mode = 1.

Returns

CF = 1 on error, otherwise EAX = stream handle

Errors

ERR_FILE_EXISTS

File with given name already exists (only returned if overwr=0)

ERR_CANT_OPEN_FILE

File can't be created.

ERR_INVALID_MODE

mode = 0, or mode > 2, or overwr > 1

ERR_UNKNOWN

Platform-specific error during creating file.

+fileio.create
+stream.create
+fileio.close

Remarks

Warning

Don't forget to close returned file stream with stream.close !

Note

This is extended version, see file.create for simpler usage.

Note

Opens file as stream, if you want direct file I/O use fileio.create .

file.open

Description

Opens existing file as stream.

Arguments

name

Pointer to name of file to open. Must be zero-terminated string.

mode

Access mode to file: 0=read only, 1=write only, 2=read/write.

Returns

CF = 1 on error, otherwise EAX = stream handle

Errors

ERR_FILE_NOT_FOUND

File with specified name wasn't found.

ERR_CANT_OPEN_FILE

File exists, but couldn't be opened.

ERR_INVALID_MODE

mode > 2.

ERR_UNKNOWN

Platform-specific error during opening file.

+file.extopen

Remarks

Warning

Don't forget to close returned file stream with stream.close !

Warning

Do not use original handle while it is used by stream.

Note

This is simple version, see file.extopen for more options.

Note

Opens file as stream, if you want direct file I/O use fileio.open .

file.extopen

Description

Opens existing file as stream.

Arguments

objbuf

Pointer to buffer for FSTREAM object. If 0, object is allocated.

name

Pointer to name of file to open. Must be zero-terminated string.

mode

Access mode to file: 0=read only, 1=write only, 2=read/write.

wbuf

RESERVED, must be 0

wbuflen

RESERVED, must be 0

rbuf

Pointer to read buffer. If 1, buffer will be allocated, and wbuflen holds initial size. If 0, read buffering is disabled.

rbuflen

If rbuf=pointer, this is size of buffer. If rbuf=1, this is initial size of buffer. If rbuf=0, ignored.

Returns

CF = 1 on error, otherwise EAX = stream handle

Errors

ERR_FILE_NOT_FOUND

File with specified name wasn't found.

ERR_CANT_OPEN_FILE

File exists, but couldn't be opened.

ERR_INVALID_MODE

mode > 2.

ERR_UNKNOWN

Platform-specific error during opening file.

+fileio.open
+stream.create
+fileio.close

Remarks

Warning

Don't forget to close returned file stream with stream.close !

Warning

If you disable read buffering (rbuf=0), then you can't use stream.peek , or any procedures that require peek. Most text reading procedures will fail.

Note

This is extended version, see file.open for simpler usage.

Note

Opens file as stream, if you want direct file I/O use fileio.open .

file.append

Description

Opens existing file for writing, and sets pointer to end of file.

Arguments

name

Name of file to create

create

Specifies whether to create file if it doesn't exist. 1=create, 0=don't create.

mode

Access mode to file: 1=write only, 2=read/write.

Returns

CF = 1 on error, otherwise EAX = stream handle

Errors

ERR_FILE_NOT_FOUND

File with given name wasn't found. Only returned when create=0.

ERR_CANT_OPEN_FILE

File can't be created.

ERR_INVALID_MODE

mode = 0, or mode > 2, or overwr > 1.

ERR_UNKNOWN

Platform-specific error during creating file.

+file.extappend

Remarks

Warning

Don't forget to close returned file stream with stream.close !

Note

This is simpler version, see file.append for more options.

Note

Opens file as stream, if you want direct file I/O use fileio.append .

file.extappend

Description

Opens existing file for writing, and sets pointer to end of file.

Arguments

objbuf

Pointer to buffer for FSTREAM object. If 0, object is allocated.

name

Name of file to create

create

Specifies whether to create file if it doesn't exist. 1=create, 0=don't create.

mode

Access mode to file: 1=write only, 2=read/write.

wbuf

RESERVED, must be 0

wbuflen

RESERVED, must be 0

rbuf

Pointer to read buffer. If 1, buffer will be allocated, and wbuflen holds initial size. If 0, read buffering is disabled. Must be 0 if mode = 1.

rbuflen

If rbuf=pointer, this is size of buffer. If rbuf=1, this is initial size of buffer. If rbuf=0, ignored. Must be 0 if mode = 1.

Returns

CF = 1 on error, otherwise EAX = stream handle

Errors

ERR_FILE_NOT_FOUND

File with given name wasn't found. Only returned when create=0.

ERR_CANT_OPEN_FILE

File can't be created.

ERR_INVALID_MODE

mode = 0, or mode > 2, or overwr > 1, or rbuf is nonzero when mode=1, or rbuflen is nonzero when mode=1.

ERR_UNKNOWN

Platform-specific error during creating file.

+fileio.append
+stream.create
+fileio.close

Remarks

Warning

Don't forget to close returned file stream with stream.close !

Note

This is extended version, see file.append for simpler usage.

Note

Opens file as stream, if you want direct file I/O use fileio.append .

file.open.handle

Description

Opens file handle as file stream.

Arguments

objbuf

Pointer to buffer for FSTREAM object. If 0, object is allocated.

handle

File handle returned by fileio.open , fileio.create , or fileio.append .

mode

Access mode to file: 0=read only, 1=write only, 2=read/write. This mode should be same as one specified when opening handle. If mode for handle was 2, this can be 0 or 1, but not otherwise.

Returns

CF = 1 on error, otherwise EAX = stream handle

Errors

ERR_INVALID_HANDLE

Invalid file handle passed

ERR_INVALID_MODE

mode > 2.

ERR_UNKNOWN

Platform-specific error during opening file.

+file.extopen.handle

Remarks

Warning

Don't forget to close returned file stream with stream.close !

Warning

Do not use original handle while it is used by stream.

Warning

When you close file stream created with this procedure, file handle still remains open and must be closed with fileio.close .

Note

This is simple version, see file.extopen.handle for more options.

file.extopen.handle

Description

Opens file handle as file stream.

Arguments

objbuf

Pointer to buffer for FSTREAM object. If 0, object is allocated.

handle

File handle returned by fileio.open , fileio.create , or fileio.append .

mode

Access mode to file: 0=read only, 1=write only, 2=read/write. This mode should be same as one specified when opening handle. If mode for handle was 2, this can be 0 or 1, but not otherwise.

wbuf

RESERVED, must be 0

wbuflen

RESERVED, must be 0

rbuf

Pointer to read buffer. If 1, buffer will be allocated, and wbuflen holds initial size. If 0, read buffering is disabled.

rbuflen

If rbuf=pointer, this is size of buffer. If rbuf=1, this is initial size of buffer. If rbuf=0, ignored.

Returns

CF = 1 on error, otherwise EAX = stream handle

Errors

ERR_INVALID_HANDLE

Invalid file handle passed

ERR_INVALID_MODE

mode > 2.

ERR_UNKNOWN

Platform-specific error during opening file.

+stream.create
+fileio.close

Remarks

Warning

Don't forget to close returned file stream with stream.close !

Warning

When you close file stream created with this procedure, file handle still remains open and must be closed with fileio.close .

Warning

If you disable read buffering (rbuf=0), then you can't use stream.peek , or any procedures that require peek. Most text reading procedures will fail.

Note

This is extended version, see file.open.handle for simpler usage.

Chapter 9. Text Processing

FASMLIB provides set of procedures for ASCII text processing.

These procedures operate on streams.

Write procedures

Procedures for writing ASCII text to streams.

Decimal

Procedures for writing decimal numbers to streams.

text.write.dec

Description

This is alias for text.write.d_dec .


text.write.b_dec

Description

Writes unsigned byte (8 bit) to stream as ASCII decimal string.

Arguments

stream

Handle of stream to write to.

value

Low order byte of this dword is value to write.

Returns

CF set on error

Remarks

Note

This is simpler version of procedure, for extended version see text.extwrite.b_dec .

Note

For signed version, see text.write.ib_dec .

text.write.w_dec

Description

Writes unsigned word (16 bit) to stream as ASCII decimal string.

Arguments

stream

Handle of stream to write to.

value

Low order word of this dword is value to write.

Returns

CF set on error

Remarks

Note

This is simpler version of procedure, for extended version see text.extwrite.w_dec .

Note

For signed version, see text.write.iw_dec .

text.write.d_dec

Description

Writes unsigned dword (32 bit) to stream as ASCII decimal string.

Arguments

stream

Handle of stream to write to.

value

Dword value to write.

Returns

CF set on error

Remarks

Note

This is simpler version of procedure, for extended version see text.extwrite.d_dec .

Note

For signed version, see text.write.id_dec .

text.write.q_dec

Description

Writes unsigned qword (64 bit) to stream as ASCII decimal string.

Arguments

stream

Handle of stream to write to.

valuelow

Low order dword of value to write.

valuehigh

High order dword of value to write.

Returns

CF set on error

Remarks

Note

This is simpler version of procedure, for extended version see text.extwrite.q_dec .

Note

For signed version, see text.write.iq_dec .

text.write.idec

Description

This is alias for text.write.id_dec .


text.write.ib_dec

Description

Writes signed byte (8 bit) to stream as ASCII decimal string. This is simpler version of procedure, for extended version see text.extwrite.b_dec . For unsigned version, see text.write.b_dec .

Arguments

stream

Handle of stream to write to.

value

Low order byte of this dword is value to write.

Returns

CF set on error


text.write.iw_dec

Description

Writes signed word (16 bit) to stream as ASCII decimal string. This is simpler version of procedure, for extended version see text.extwrite.iw_dec . For unsigned version, see text.write.w_dec .

Arguments

stream

Handle of stream to write to.

value

Low order word of this dword is value to write.

Returns

CF set on error


text.write.id_dec

Description

Writes signed dword (32 bit) to stream as ASCII decimal string. This is simpler version of procedure, for extended version see text.extwrite.id_dec . For unsigned version, see text.write.d_dec .

Arguments

stream

Handle of stream to write to.

value

Dword value to write.

Returns

CF set on error


text.write.iq_dec

Description

Writes signed qword (64 bit) to stream as ASCII decimal string. This is simpler version of procedure, for extended version see text.extwrite.iq_dec . For unsigned version, see text.write.q_dec .

Arguments

stream

Handle of stream to write to.

valuelow

Low order dword of value to write.

valuehigh

High order dword of value to write.

Returns

CF set on error


text.extwrite.dec

Description

This is alias for text.extwrite.d_dec .


text.extwrite.b_dec

Description

Write unsigned byte to stream as decimal string.

Arguments

stream

Handle of stream to write to.

value

Value to write as decimal string. Only low order word of this dword is used, rest is ignored.

padding

Type of padding: type 0 is no padding, type 1 is prepending with spaces, type 2 is prepending with leading zeroes.

padlen

Length to which should output be padded. If output is already longer than this value before padding, then output is not padded. Ignored if padding = 0.

Returns

CF=1 on error.

Errors

ERR_INVALID_MODE

padding > 2

ERR_OUT_OF_RANGE

padlen > 4096

+text.extwrite.d_dec

Remarks

Note

This is extended version of procedure, for simpler usage see text.write.b_dec .

Note

For signed version of this procedure, see text.extwrite.ib_dec .

text.extwrite.w_dec

Description

Write unsigned word to stream as decimal string.

Arguments

stream

Handle of stream to write to.

value

Value to write as decimal string. Only low order word of this dword is used, rest is ignored.

padding

Type of padding: type 0 is no padding, type 1 is prepending with spaces, type 2 is prepending with leading zeroes.

padlen

Length to which should output be padded. If output is already longer than this value before padding, then output is not padded. Ignored if padding = 0.

Returns

CF=1 on error.

Errors

ERR_INVALID_MODE

padding > 2

ERR_OUT_OF_RANGE

padlen > 4096

+text.extwrite.d_dec

Remarks

Note

This is extended version of procedure, for simpler usage see text.write.w_dec .

Note

For signed version of this procedure, see text.extwrite.iw_dec .

text.extwrite.d_dec

Description

Write unsigned dword to stream as decimal string.

Arguments

stream

Handle of stream to write to.

value

Value to write as decimal string.

padding

Type of padding: type 0 is no padding, type 1 is prepending with spaces, type 2 is prepending with leading zeroes.

padlen

Length to which should output be padded. If output is already longer than this value before padding, then output is not padded. Ignored if padding = 0.

Returns

CF=1 on error.

Errors

ERR_INVALID_MODE

padding > 2

ERR_OUT_OF_RANGE

padlen > 4096

+extconv.d_dec
+stream.write

Remarks

Note

This is extended version of procedure, for simpler usage see text.write.d_dec .

Note

For signed version of this procedure, see text.extwrite.id_dec .

text.extwrite.q_dec

Description

Write unsigned qword to stream as decimal string.

Arguments

stream

Handle of stream to write to.

valuelow

Low order dword of value to write.

valuehigh

High order dword of value to write.

padding

Type of padding: type 0 is no padding, type 1 is prepending with spaces, type 2 is prepending with leading zeroes.

padlen

Length to which should output be padded. If output is already longer than this value before padding, then output is not padded. Ignored if padding = 0.

Returns

CF=1 on error.

Errors

ERR_INVALID_MODE

padding > 2

ERR_OUT_OF_RANGE

padlen > 4096

+extconv.q_dec
+stream.write

Remarks

Note

This is extended version of procedure, for simpler usage see text.write.q_dec .

Note

For signed version of this procedure, see text.extwrite.iq_dec .

text.extwrite.idec

Description

This is alias for text.extwrite.id_dec .


text.extwrite.ib_dec

Description

Write signed byte to stream as decimal string.

Arguments

stream

Handle of stream to write to.

value

Value to write as decimal string. Only low order byte of this dword is used, rest is ignored.

padding

Type of padding: Type 0 is no padding. Type 1 is prepending with spaces, and sign counts into padding size. Type 2 is prepending with leading zeroes. In this type padlen specifies number digits displayed. One more character is always printed as sign (' ', '+' or '-').

padlen

Length to which should output be padded. If output is already longer than this value before padding, then output is not padded. Ignored if padding = 0.

plus

Set to 1 if you want to display plus sign on positive numbers.

Returns

CF=1 on error.

Errors

ERR_OUT_OF_RANGE

padlen > 4096

ERR_INVALID_MODE

padding > 2, or plus > 1

+text.extwrite.id_dec

Remarks

Note

This is extended version of procedure, for simpler usage see text.write.ib_dec .

Note

For unsigned version of this procedure, see text.extwrite.b_dec .

text.extwrite.iw_dec

Description

Write signed word to stream as decimal string.

Arguments

stream

Handle of stream to write to.

value

Value to write as decimal string. Only low order word of this dword is used, rest is ignored.

padding

Type of padding: Type 0 is no padding. Type 1 is prepending with spaces, and sign counts into padding size. Type 2 is prepending with leading zeroes. In this type padlen specifies number digits displayed. One more character is always printed as sign (' ', '+' or '-').

padlen

Length to which should output be padded. If output is already longer than this value before padding, then output is not padded. Ignored if padding = 0.

plus

Set to 1 if you want to display plus sign on positive numbers.

Returns

CF=1 on error.

Errors

ERR_OUT_OF_RANGE

padlen > 4096

ERR_INVALID_MODE

padding > 2, or plus > 1

+text.extwrite.id_dec

Remarks

Note

This is extended version of procedure, for simpler usage see text.write.iw_dec .

Note

For unsigned version of this procedure, see text.extwrite.w_dec .

text.extwrite.id_dec

Description

Write signed dword to stream as decimal string.

Arguments

stream

Handle of stream to write to.

value

Value to write as decimal string.

padding

Type of padding: Type 0 is no padding. Type 1 is prepending with spaces, and sign counts into padding size. Type 2 is prepending with leading zeroes. In this type padlen specifies number digits displayed. One more character is always printed as sign (' ', '+' or '-').

padlen

Length to which should output be padded. If output is already longer than this value before padding, then output is not padded. Ignored if padding = 0.

plus

Set to 1 if you want to display plus sign on positive numbers.

Returns

CF=1 on error.

Errors

ERR_OUT_OF_RANGE

padlen > 4096

ERR_INVALID_MODE

padding > 2, or plus > 1

+extconv.id_dec
+stream.write

Remarks

Note

This is extended version of procedure, for simpler usage see text.write.id_dec .

Note

For unsigned version of this procedure, see text.extwrite.d_dec .

text.extwrite.iq_dec

Description

Write signed qword to stream as decimal string.

Arguments

stream

Handle of stream to write to.

valuelow

Low order dword of value to write.

valuehigh

High order dword of value to write.

padding

Type of padding: Type 0 is no padding. Type 1 is prepending with spaces, and sign counts into padding size. Type 2 is prepending with leading zeroes. In this type padlen specifies number digits displayed. One more character is always printed as sign (' ', '+' or '-').

padlen

Length to which should output be padded. If output is already longer than this value before padding, then output is not padded. Ignored if padding = 0.

plus

Set to 1 if you want to display plus sign on positive numbers.

Returns

CF=1 on error.

Errors

ERR_OUT_OF_RANGE

padlen > 4096

ERR_INVALID_MODE

padding > 2, or plus > 1

+extconv.iq_dec
+stream.write

Remarks

Note

This is extended version of procedure, for simpler usage see text.write.iq_dec .

Note

For unsigned version of this procedure, see text.extwrite.q_dec .

Hexadecimal

Procedures for writing hexadecimal numbers to streams.

text.write.hex

Description

This is alias for text.write.d_hex .


text.write.b_hex

Description

Writes unsigned byte (8 bit) to stream as ASCII hexadecimal string.

Arguments

stream

Handle of stream to write to.

value

Low order byte of this dword is value to write.

Returns

CF set on error

Remarks

Note

This is simpler version of procedure, for extended version see text.extwrite.b_hex .

Note

For signed version, see text.write.ib_hex .

text.write.w_hex

Description

Writes unsigned word (16 bit) to stream as ASCII hexadecimal string.

Arguments

stream

Handle of stream to write to.

value

Low order word of this dword is value to write.

Returns

CF set on error

Remarks

Note

This is simpler version of procedure, for extended version see text.extwrite.w_hex .

Note

For signed version, see text.write.iw_hex .

text.write.d_hex

Description

Writes unsigned dword (32 bit) to stream as ASCII hexadecimal string.

Arguments

stream

Handle of stream to write to.

value

Dword value to write.

Returns

CF set on error

Remarks

Note

This is simpler version of procedure, for extended version see text.extwrite.d_hex .

Note

For signed version, see text.write.id_hex .

text.write.q_hex

Description

Writes unsigned qword (64 bit) to stream as ASCII hexadecimal string.

Arguments

stream

Handle of stream to write to.

valuelow

Low order dword of value to write.

valuehigh

High order dword of value to write.

Returns

CF set on error

Remarks

Note

This is simpler version of procedure, for extended version see text.extwrite.q_hex .

Note

For signed version, see text.write.iq_hex .

text.write.ihex

Description

This is alias for text.write.id_hex .


text.write.ib_hex

Description

Writes signed byte (8 bit) to stream as ASCII hexadecimal string. This is simpler version of procedure, for extended version see text.extwrite.b_hex . For unsigned version, see text.write.b_hex .

Arguments

stream

Handle of stream to write to.

value

Low order byte of this dword is value to write.

Returns

CF set on error


text.write.iw_hex

Description

Writes signed word (16 bit) to stream as ASCII hexadecimal string. This is simpler version of procedure, for extended version see text.extwrite.iw_hex . For unsigned version, see text.write.w_hex .

Arguments

stream

Handle of stream to write to.

value

Low order word of this dword is value to write.

Returns

CF set on error


text.write.id_hex

Description

Writes signed dword (32 bit) to stream as ASCII hexadecimal string. This is simpler version of procedure, for extended version see text.extwrite.id_hex . For unsigned version, see text.write.d_hex .

Arguments

stream

Handle of stream to write to.

value

Dword value to write.

Returns

CF set on error


text.write.iq_hex

Description

Writes signed qword (64 bit) to stream as ASCII hexadecimal string. This is simpler version of procedure, for extended version see text.extwrite.iq_hex . For unsigned version, see text.write.q_hex .

Arguments

stream

Handle of stream to write to.

valuelow

Low order dword of value to write.

valuehigh

High order dword of value to write.

Returns

CF set on error


text.extwrite.hex

Description

This is alias for text.extwrite.d_hex .


text.extwrite.b_hex

Description

Write unsigned byte to stream as hexadecimal string.

Arguments

stream

Handle of stream to write to.

value

Value to write as hexadecimal string. Only low order byte of this dword is used, rest is ignored.

padding

Type of padding: type 0 is no padding, type 1 is prepending with spaces, type 2 is prepending with leading zeroes.

padlen

Length to which should output be padded. If output is already longer than this value before padding, then output is not padded. Ignored if padding = 0.

Returns

CF=1 on error.

Errors

ERR_INVALID_MODE

padding > 2

ERR_OUT_OF_RANGE

padlen > 4096

+text.extwrite.d_hex

Remarks

Note

This is extended version of procedure, for simpler usage see text.write.b_hex .

Note

For signed version of this procedure, see text.extwrite.ib_hex .

text.extwrite.w_hex

Description

Write unsigned word to stream as hexadecimal string.

Arguments

stream

Handle of stream to write to.

value

Value to write as hexadecimal string. Only low order word of this dword is used, rest is ignored.

padding

Type of padding: type 0 is no padding, type 1 is prepending with spaces, type 2 is prepending with leading zeroes.

padlen

Length to which should output be padded. If output is already longer than this value before padding, then output is not padded. Ignored if padding = 0.

Returns

CF=1 on error.

Errors

ERR_INVALID_MODE

padding > 2

ERR_OUT_OF_RANGE

padlen > 4096

+text.extwrite.d_hex

Remarks

Note

This is extended version of procedure, for simpler usage see text.write.w_hex .

Note

For signed version of this procedure, see text.extwrite.iw_hex .

text.extwrite.d_hex

Description

Write unsigned dword to stream as hexadecimal string.

Arguments

stream

Handle of stream to write to.

value

Value to write as hexadecimal string.

padding

Type of padding: type 0 is no padding, type 1 is prepending with spaces, type 2 is prepending with leading zeroes.

padlen

Length to which should output be padded. If output is already longer than this value before padding, then output is not padded. Ignored if padding = 0.

Returns

CF=1 on error.

Errors

ERR_INVALID_MODE

padding > 2

ERR_OUT_OF_RANGE

padlen > 4096

+extconv.d_hex
+stream.write

Remarks

Note

This is extended version of procedure, for simpler usage see text.write.d_hex .

Note

For signed version of this procedure, see text.extwrite.id_hex .

text.extwrite.q_hex

Description

Write unsigned qword to stream as hexadecimal string.

Arguments

stream

Handle of stream to write to.

valuelow

Low order dword of value to write.

valuehigh

High order dword of value to write.

padding

Type of padding: type 0 is no padding, type 1 is prepending with spaces, type 2 is prepending with leading zeroes.

padlen

Length to which should output be padded. If output is already longer than this value before padding, then output is not padded. Ignored if padding = 0.

Returns

CF=1 on error.

Errors

ERR_INVALID_MODE

padding > 2

ERR_OUT_OF_RANGE

padlen > 4096

+extconv.q_hex
+stream.write

Remarks

Note

This is extended version of procedure, for simpler usage see text.write.d_hex .

Note

For signed version of this procedure, see text.extwrite.id_hex .

text.extwrite.ihex

Description

This is alias for text.extwrite.id_hex .


text.extwrite.ib_hex

Description

Write signed byte to stream as hexadecimal string.

Arguments

stream

Handle of stream to write to.

value

Value to write as hexadecimal string. Only low order byte of this dword is used, rest is ignored.

padding

Type of padding: Type 0 is no padding. Type 1 is prepending with spaces, and sign counts into padding size. Type 2 is prepending with leading zeroes. In this type padlen specifies number digits displayed. One more character is always printed as sign (' ', '+' or '-').

padlen

Length to which should output be padded. If output is already longer than this value before padding, then output is not padded. Ignored if padding = 0.

plus

Set to 1 if you want to display plus sign on positive numbers.

Returns

CF=1 on error.

Errors

ERR_OUT_OF_RANGE

padlen > 4096

ERR_INVALID_MODE

padding > 2, or plus > 1

+text.extwrite.id_hex

Remarks

Note

This is extended version of procedure, for simpler usage see text.write.ib_hex .

Note

For unsigned version of this procedure, see text.extwrite.b_hex .

text.extwrite.iw_hex

Description

Write signed word to stream as hexadecimal string.

Arguments

stream

Handle of stream to write to.

value

Value to write as hexadecimal string. Only low order word of this dword is used, rest is ignored.

padding

Type of padding: Type 0 is no padding. Type 1 is prepending with spaces, and sign counts into padding size. Type 2 is prepending with leading zeroes. In this type padlen specifies number digits displayed. One more character is always printed as sign (' ', '+' or '-').

padlen

Length to which should output be padded. If output is already longer than this value before padding, then output is not padded. Ignored if padding = 0.

plus

Set to 1 if you want to display plus sign on positive numbers.

Returns

CF=1 on error.

Errors

ERR_OUT_OF_RANGE

padlen > 4096

ERR_INVALID_MODE

padding > 2, or plus > 1

+text.extwrite.id_hex

Remarks

Note

This is extended version of procedure, for simpler usage see text.write.iw_hex .

Note

For unsigned version of this procedure, see text.extwrite.w_hex .

text.extwrite.id_hex

Description

Write signed dword to stream as hexadecimal string.

Arguments

stream

Handle of stream to write to.

value

Value to write as hexadecimal string.

padding

Type of padding: Type 0 is no padding. Type 1 is prepending with spaces, and sign counts into padding size. Type 2 is prepending with leading zeroes. In this type padlen specifies number digits displayed. One more character is always printed as sign (' ', '+' or '-').

padlen

Length to which should output be padded. If output is already longer than this value before padding, then output is not padded. Ignored if padding = 0.

plus

Set to 1 if you want to display plus sign on positive numbers.

Returns

CF=1 on error.

Errors

ERR_OUT_OF_RANGE

padlen > 4096

ERR_INVALID_MODE

padding > 2, or plus > 1

+extconv.id_hex
+stream.write

Remarks

Note

This is extended version of procedure, for simpler usage see text.write.id_hex .

Note

For unsigned version of this procedure, see text.extwrite.d_hex .

text.extwrite.iq_hex

Description

Write signed qword to stream as hexadecimal string.

Arguments

stream

Handle of stream to write to.

valuelow

Low order dword of value to write.

valuehigh

High order dword of value to write.

padding

Type of padding: Type 0 is no padding. Type 1 is prepending with spaces, and sign counts into padding size. Type 2 is prepending with leading zeroes. In this type padlen specifies number digits displayed. One more character is always printed as sign (' ', '+' or '-').

padlen

Length to which should output be padded. If output is already longer than this value before padding, then output is not padded. Ignored if padding = 0.

plus

Set to 1 if you want to display plus sign on positive numbers.

Returns

CF=1 on error.

Errors

ERR_OUT_OF_RANGE

padlen > 4096

ERR_INVALID_MODE

padding > 2, or plus > 1

+extconv.iq_hex
+stream.write

Remarks

Note

This is extended version of procedure, for simpler usage see text.write.iq_hex .

Note

For unsigned version of this procedure, see text.extwrite.q_hex .

text.write

Description

Writes null-terminated ASCII string to stream . This function should be only used with constant string argument. Use text.fetch.str for non-constant strings.

Arguments

stream

Handle of stream to write to. For standard streams, you can use stdout.write or stderr.write .

string

Pointer to string.

Returns

CF set on error

Remarks

Warning

Only use this if string is guaranteed to be null terminated. Otherwise, use text.write.str .

text.write.char

Description

This is alias for stream.write.byte .


text.write.format

Description

Writes formatted output to stream. That means, displays format string with special % values substituted by converted values of additional arguments.

Arguments

stream

Stream to write to. For standard streams, you can use stdout.write or stderr.write .

format

Format string. See output format string for more information.

<arguments>

Remaining arguments depend on format string. Arguments are pushed on stack normally like with any other procedure. All arguments are removed from stack by this procedure, no extra code needed.

Returns

CF set on error

Errors

ERR_FORMAT_STRING

Incorrect format string. Check output format string .


text.write.str

Description

Writes string to stream . If string is guaranteed to be null terminated, you can use text.write instead.

Arguments

stream

Handle of stream to write to. For standard streams, you can use stdout.write.str or stderr.write.str .

string

Pointer to string.

buflen

Length of string buffer.

Returns

CF set on error

Read procedures

Procedures for reading ASCII text from streams.

Decimal

Procedures for reading decimal numbers from streams.

text.read.dec

Description

This is alias text.read.dec_d .


text.read.dec_b

Description

Reads unsigned decimal byte from stream. This is simple version, for more options see text.extread.dec_b . Reads decimal digit characters ('0'-'9') until it reaches non-digit, EOF, or until resulting value overflows.

Arguments

stream

Handle of stream from which to read.

Returns

CF set on error, otherwise EAX = readen byte zero-extended to dword

Errors

ERR_HANDLE_EOF

EOF reached.

ERR_OUT_OF_RANGE

value > 255. In this case all digit characters remain on stream.

ERR_NOT_DECIMAL

First character is not decimal digit. Character remains on stream.

Remarks

Note

Skips inital blank characters (space, tab, EOL).

Note

Stream must have a read buffer.

Note

If stream has static read buffer, it must be big enough to hold all digits of number.

text.read.dec_w

Description

Reads unsigned decimal word from stream. This is simple version, for more options see text.extread.dec_w . Reads decimal digit characters ('0'-'9') until it reaches non-digit, EOF, or until resulting value overflows.

Arguments

stream

Handle of stream from which to read.

Returns

CF set on error, otherwise EAX = readen word zero-extended to dword

Errors

ERR_HANDLE_EOF

EOF reached.

ERR_OUT_OF_RANGE

value > 65536. In this case all digit characters remain on stream.

ERR_NOT_DECIMAL

First character is not decimal digit. Character remains on stream.

Remarks

Note

Skips inital blank characters (space, tab, EOL).

Note

Stream must have a read buffer.

Note

If stream has static read buffer, it must be big enough to hold all digits of number.

text.read.dec_d

Description

Reads unsigned decimal dword from stream. This is simple version, for more options see text.extread.dec_d . Reads decimal digit characters ('0'-'9') until it reaches non-digit, EOF, or until resulting value overflows.

Arguments

stream

Handle of stream from which to read.

Returns

CF set on error, otherwise EAX = readen dword

Errors

ERR_HANDLE_EOF

EOF reached.

ERR_OUT_OF_RANGE

value > 4294967295. In this case all digit characters remain on stream.

ERR_NOT_DECIMAL

First character is not decimal digit. Character remains on stream.

Remarks

Note

Skips inital blank characters (space, tab, EOL).

Note

Stream must have a read buffer.

Note

If stream has static read buffer, it must be big enough to hold all digits of number.

text.read.dec_q

Description

Reads unsigned decimal qword from stream. This is simple version, for more options see text.extread.dec_q . Reads decimal digit characters ('0'-'9') until it reaches non-digit, EOF, or until resulting value overflows.

Arguments

stream

Handle of stream from which to read.

Returns

CF set on error, otherwise EDX:EAX = readen qword

Errors

ERR_HANDLE_EOF

EOF reached.

ERR_OUT_OF_RANGE

value > 18446744073709551615. In this case all digit characters remain on stream.

ERR_NOT_DECIMAL

First character is not decimal digit. Character remains on stream.

+text.extread.dec_q

Remarks

Note

Skips inital blank characters (space, tab, EOL).

Note

Stream must have a read buffer.

Note

If stream has static read buffer, it must be big enough to hold all digits of number.

text.read.idec

Description

This is alias text.read.dec_id .


text.read.dec_ib

Description

Reads signed decimal byte from stream. This is simple version, for more options see text.extread.dec_ib . Reads optional sign ('-' or '+') and decimal digit characters ('0'-'9') until it reaches non-digit, EOF, or until resulting value overflows.

Arguments

stream

Handle of stream from which to read.

Returns

CF set on error, otherwise EAX = readen byte, sign-extended to dword.

Errors

ERR_HANDLE_EOF

EOF reached.

ERR_OUT_OF_RANGE

value < -128 or value > 127. In this case sign character and all digit characters remain on stream.

ERR_NOT_DECIMAL

First character (after sign) is not decimal digit. Character remains on stream.

Remarks

Note

Skips inital blank characters (space, tab, EOL).

Note

Stream must have a read buffer.

Note

If stream has static read buffer, it must be big enough to hold all digits of number.

text.read.dec_iw

Description

Reads signed decimal word from stream. This is simple version, for more options see text.extread.dec_iw . Reads optional sign ('-' or '+') and decimal digit characters ('0'-'9') until it reaches non-digit, EOF, or until resulting value overflows.

Arguments

stream

Handle of stream from which to read.

Returns

CF set on error, otherwise EAX = readen word, sign-extended to dword.

Errors

ERR_HANDLE_EOF

EOF reached.

ERR_OUT_OF_RANGE

value < -32768 or value > 32767. In this case sign character and all digit characters remain on stream.

ERR_NOT_DECIMAL

First character (after sign) is not decimal digit. Character remains on stream.

Remarks

Note

Skips inital blank characters (space, tab, EOL).

Note

Stream must have a read buffer.

Note

If stream has static read buffer, it must be big enough to hold all digits of number.

text.read.dec_id

Description

Reads signed decimal dword from stream. This is simple version, for more options see text.extread.dec_id . Reads optional sign ('-' or '+') and decimal digit characters ('0'-'9') until it reaches non-digit, EOF, or until resulting value overflows.

Arguments

stream

Handle of stream from which to read.

Returns

CF set on error, otherwise EAX = readen dword

Errors

ERR_HANDLE_EOF

EOF reached.

ERR_OUT_OF_RANGE

value < -2147483648 or value > 2147483647. In this case sign character and all digit characters remain on stream.

ERR_NOT_DECIMAL

First character (after sign) is not decimal digit. Character remains on stream.

Remarks

Note

Skips inital blank characters (space, tab, EOL).

Note

Stream must have a read buffer.

Note

If stream has static read buffer, it must be big enough to hold all digits of number.

text.read.dec_iq

Description

Reads signed decimal qword from stream. This is simple version, for more options see text.extread.dec_iq . Reads optional sign ('-' or '+') and decimal digit characters ('0'-'9') until it reaches non-digit, EOF, or until resulting value overflows.

Arguments

stream

Handle of stream from which to read.

Returns

CF set on error, otherwise EDX:EAX = readen qword

Errors

ERR_HANDLE_EOF

EOF reached.

ERR_OUT_OF_RANGE

value < -9223372036854775808 or value > 9223372036854775807. In this case sign character and all digit characters remain on stream.

ERR_NOT_DECIMAL

First character (after sign) is not decimal digit. Character remains on stream.

+text.extread.dec_iq

Remarks

Note

Skips inital blank characters (space, tab, EOL).

Note

Stream must have a read buffer.

Note

If stream has static read buffer, it must be big enough to hold all digits of number.

text.extread.dec

Description

This is alias text.extread.dec_d .


text.extread.dec_b

Description

Reads unsigned decimal byte from stream. This is extended version, for simpler usage see text.read.dec_b . Reads decimal digit characters ('0'-'9') until it reaches non-digit, EOF, or until resulting value overflows.

Arguments

stream

Handle of stream from which to read.

maxlen

Maximum number of digits to read. 0 if not specified.

skipbl

If 1, procedure first skips initial blank characters (space, tab, EOL). These characters don't count into maxlen size.

len

Pointer to dword variable, that will be set to number of digits read. Ignored if 0. When skipbl=1, skipped initial blank characters don't count.

Returns

CF set on error, otherwise EAX = readen byte zero-extended to dword

Errors

ERR_HANDLE_EOF

EOF reached. len is set to 0.

ERR_OUT_OF_RANGE

value > 255. In this case all digit characters remain on stream. len contains number of characters readen until overflow.

ERR_NOT_DECIMAL

First character is not decimal digit. Character remains on stream. len is set to 0.

ERR_ZERO_VALUE

maxlen=0. len is set to 0.

ERR_INVALID_MODE

skipbl > 1. len is set to 0.

Remarks

Note

Stream must have a read buffer.

Note

If stream has static read buffer, it must be big enough to hold all digits of number.

text.extread.dec_w

Description

Reads unsigned decimal word from stream. This is extended version, for simpler usage see text.read.dec_w . Reads decimal digit characters ('0'-'9') until it reaches non-digit, EOF, or until resulting value overflows.

Arguments

stream

Handle of stream from which to read.

maxlen

Maximum number of digits to read. 0 if not specified.

skipbl

If 1, procedure first skips initial blank characters (space, tab, EOL). These characters don't count into maxlen size.

len

Pointer to dword variable, that will be set to number of digits read. Ignored if 0. When skipbl=1, skipped initial blank characters don't count.

Returns

CF set on error, otherwise EAX = readen word zero-extended to dword

Errors

ERR_HANDLE_EOF

EOF reached. len is set to 0.

ERR_OUT_OF_RANGE

value > 65535. In this case all digit characters remain on stream. len contains number of characters readen until overflow.

ERR_NOT_DECIMAL

First character is not decimal digit. Character remains on stream. len is set to 0.

ERR_ZERO_VALUE

maxlen=0. len is set to 0.

ERR_INVALID_MODE

skipbl > 1. len is set to 0.

Remarks

Note

Stream must have a read buffer.

Note

If stream has static read buffer, it must be big enough to hold all digits of number.

text.extread.dec_d

Description

Reads unsigned decimal dword from stream. This is extended version, for simpler usage see text.read.dec_d . Reads decimal digit characters ('0'-'9') until it reaches non-digit, EOF, or until resulting value overflows.

Arguments

stream

Handle of stream from which to read.

maxlen

Maximum number of digits to read. 0 if not specified.

skipbl

If 1, procedure first skips initial blank characters (space, tab, EOL). These characters don't count into maxlen size.

len

Pointer to dword variable, that will be set to number of digits read. Ignored if 0. When skipbl=1, skipped initial blank characters don't count.

Returns

CF set on error, otherwise EAX = readen dword value.

Errors

ERR_HANDLE_EOF

EOF reached. len is set to 0.

ERR_OUT_OF_RANGE

value > 4294967295. In this case all digit characters remain on stream. len contains number of characters readen until overflow.

ERR_NOT_DECIMAL

First character is not decimal digit. Character remains on stream. len is set to 0.

ERR_ZERO_VALUE

maxlen=0. len is set to 0.

ERR_INVALID_MODE

skipbl > 1. len is set to 0.

Remarks

Note

Stream must have a read buffer.

Note

If stream has static read buffer, it must be big enough to hold all digits of number.

text.extread.dec_q

Description

Reads unsigned decimal qword from stream. This is extended version, for simpler usage see text.read.dec_q . Reads decimal digit characters ('0'-'9') until it reaches non-digit, EOF, or until resulting value overflows.

Arguments

stream

Handle of stream from which to read.

maxlen

Maximum number of digits to read. 0 if not specified.

skipbl

If 1, procedure first skips initial blank characters (space, tab, EOL). These characters don't count into maxlen size.

len

Pointer to dword variable, that will be set to number of digits read. Ignored if 0. When skipbl=1, skipped initial blank characters don't count.

Returns

CF set on error, otherwise EDX:EAX = readen qword value.

Errors

ERR_HANDLE_EOF

EOF reached. len is set to 0.

ERR_OUT_OF_RANGE

value > 18446744073709551615. In this case all digit characters remain on stream. len contains number of characters readen until overflow.

ERR_NOT_DECIMAL

First character is not decimal digit. Character remains on stream. len is set to 0.

ERR_ZERO_VALUE

maxlen=0. len is set to 0.

ERR_INVALID_MODE

skipbl > 1. len is set to 0.

+text.skip.chars
+stream.peek.byte
+stream.peek
+stream.skip

Remarks

Note

Stream must have a read buffer.

Note

If stream has static read buffer, it must be big enough to hold all digits of number.

text.extread.idec

Description

This is alias text.extread.dec_id .


text.extread.dec_ib

Description

Reads signed decimal byte from stream. This is extended version, for simpler usage see text.read.dec_ib . Reads decimal digit characters ('0'-'9') until it reaches non-digit, EOF, or until resulting value overflows.

Arguments

stream

Handle of stream from which to read.

maxlen

Maximum number of characters to read, including sign. 0 if not specified.

skipbl

If 1, procedure first skips initial blank characters (space, tab, EOL). These characters don't count into maxlen size. These characters do not remain on stream in case of error.

allowplus

If 1, plus sign "+" is accepted.

len

Pointer to dword variable, that will be set to number of digits read. Ignored if 0. When skipbl=1, skipped initial blank characters don't count.

Returns

CF set on error, otherwise EAX = readen byte value, sign-extended to dword.

Errors

ERR_HANDLE_EOF

EOF reached. len is set to 0.

ERR_OUT_OF_RANGE

value < -128 or value > 127. In this case sign character and all digit characters remain on stream. len contains number of characters readen until overflow.

ERR_NOT_DECIMAL

First character (after sign) is not a decimal digit. Characters remains on stream. len is set to 0.

ERR_ZERO_VALUE

maxlen=0. len is set to 0.

ERR_INVALID_MODE

skipbl > 1. len is set to 0.

Remarks

Note

Stream must have a read buffer.

Note

If stream has static read buffer, it must be big enough to hold all characters of number.

text.extread.dec_iw

Description

Reads signed decimal word from stream. This is extended version, for simpler usage see text.read.dec_iw . Reads decimal digit characters ('0'-'9') until it reaches non-digit, EOF, or until resulting value overflows.

Arguments

stream

Handle of stream from which to read.

maxlen

Maximum number of characters to read, including sign. 0 if not specified.

skipbl

If 1, procedure first skips initial blank characters (space, tab, EOL). These characters don't count into maxlen size. These characters do not remain on stream in case of error.

allowplus

If 1, plus sign "+" is accepted.

len

Pointer to dword variable, that will be set to number of digits read. Ignored if 0. When skipbl=1, skipped initial blank characters don't count.

Returns

CF set on error, otherwise EAX = readen word value, sign-extended to dword.

Errors

ERR_HANDLE_EOF

EOF reached. len is set to 0.

ERR_OUT_OF_RANGE

value < -32768 or value > 32767. In this case sign character and all digit characters remain on stream. len contains number of characters readen until overflow.

ERR_NOT_DECIMAL

First character (after sign) is not a decimal digit. Characters remains on stream. len is set to 0.

ERR_ZERO_VALUE

maxlen=0. len is set to 0.

ERR_INVALID_MODE

skipbl > 1. len is set to 0.

Remarks

Note

Stream must have a read buffer.

Note

If stream has static read buffer, it must be big enough to hold all characters of number.

text.extread.dec_id

Description

Reads signed decimal dword from stream. This is extended version, for simpler usage see text.read.dec_id . Reads decimal digit characters ('0'-'9') until it reaches non-digit, EOF, or until resulting value overflows.

Arguments

stream

Handle of stream from which to read.

maxlen

Maximum number of characters to read, including sign. 0 if not specified.

skipbl

If 1, procedure first skips initial blank characters (space, tab, EOL). These characters don't count into maxlen size. These characters do not remain on stream in case of error.

allowplus

If 1, plus sign "+" is accepted.

len

Pointer to dword variable, that will be set to number of digits read. Ignored if 0. When skipbl=1, skipped initial blank characters don't count.

Returns

CF set on error, otherwise EAX = readen dword value.

Errors

ERR_HANDLE_EOF

EOF reached. len is set to 0.

ERR_OUT_OF_RANGE

value < -2147483648 or value > 2147483647. In this case sign character and all digit characters remain on stream. len contains number of characters readen until overflow.

ERR_NOT_DECIMAL

First character (after sign) is not a decimal digit. Characters remains on stream. len is set to 0.

ERR_ZERO_VALUE

maxlen=0. len is set to 0.

ERR_INVALID_MODE

skipbl > 1. len is set to 0.

Remarks

Note

Stream must have a read buffer.

Note

If stream has static read buffer, it must be big enough to hold all characters of number.

text.extread.dec_iq

Description

Reads signed decimal qword from stream. This is extended version, for simpler usage see text.read.dec_iq . Reads decimal digit characters ('0'-'9') until it reaches non-digit, EOF, or until resulting value overflows.

Arguments

stream

Handle of stream from which to read.

maxlen

Maximum number of characters to read, including sign. 0 if not specified.

skipbl

If 1, procedure first skips initial blank characters (space, tab, EOL). These characters don't count into maxlen size. These characters do not remain on stream in case of error.

allowplus

If 1, plus sign "+" is accepted.

len

Pointer to dword variable, that will be set to number of digits read. Ignored if 0. When skipbl=1, skipped initial blank characters don't count.

Returns

CF set on error, otherwise EDX:EAX = readen qword value.

Errors

ERR_HANDLE_EOF

EOF reached. len is set to 0.

ERR_OUT_OF_RANGE

value < -9223372036854775808 or value > 9223372036854775807. In this case sign character and all digit characters remain on stream. len contains number of characters readen until overflow.

ERR_NOT_DECIMAL

First character (after sign) is not a decimal digit. Characters remains on stream. len is set to 0.

ERR_ZERO_VALUE

maxlen=0. len is set to 0.

ERR_INVALID_MODE

skipbl > 1. len is set to 0.

+text.skip.chars
+stream.peek.byte
+stream.peek
+stream.skip

Remarks

Note

Stream must have a read buffer.

Note

If stream has static read buffer, it must be big enough to hold all characters of number.

Hexadecimal

Procedures for reading hexadecimal numbers from streams.

text.read.hex

Description

This is alias text.read.hex_d .


text.read.hex_b

Description

Reads unsigned hexadecimal byte from stream. This is simple version, for more options see text.extread.hex_b . Reads hexadecimal digit characters ('0'-'9','a'-'z','A'-'Z') until it reaches non-digit, EOF, or until resulting value overflows.

Arguments

stream

Handle of stream from which to read.

Returns

CF set on error, otherwise EAX = readen byte zero-extended to dword

Errors

ERR_HANDLE_EOF

EOF reached.

ERR_OUT_OF_RANGE

value > FF. In this case all digit characters remain on stream.

ERR_NOT_HEXADECIMAL

First character is not a hexadecimal digit. Character remains on stream.

Remarks

Note

Skips inital blank characters (space, tab, EOL).

Note

Stream must have a read buffer.

Note

If stream has static read buffer, it must be big enough to hold all digits of number.

text.read.hex_w

Description

Reads unsigned hexadecimal word from stream. This is simple version, for more options see text.extread.hex_w . Reads hexadecimal digit characters ('0'-'9','a'-'z','A'-'Z') until it reaches non-digit, EOF, or until resulting value overflows.

Arguments

stream

Handle of stream from which to read.

Returns

CF set on error, otherwise EAX = readen word zero-extended to dword

Errors

ERR_HANDLE_EOF

EOF reached.

ERR_OUT_OF_RANGE

value > FFFF. In this case all digit characters remain on stream.

ERR_NOT_HEXADECIMAL

First character is not a hexadecimal digit. Character remains on stream.

Remarks

Note

Skips inital blank characters (space, tab, EOL).

Note

Stream must have a read buffer.

Note

If stream has static read buffer, it must be big enough to hold all digits of number.

text.read.hex_d

Description

Reads unsigned hexadecimal dword from stream. This is simple version, for more options see text.extread.hex_d . Reads hexadecimal digit characters ('0'-'9','a'-'z','A'-'Z') until it reaches non-digit, EOF, or until resulting value overflows.

Arguments

stream

Handle of stream from which to read.

Returns

CF set on error, otherwise EAX = readen dword

Errors

ERR_HANDLE_EOF

EOF reached.

ERR_OUT_OF_RANGE

value > FFFFFFFF. In this case all digit characters remain on stream.

ERR_NOT_HEXADECIMAL

First character is not a hexadecimal digit. Character remains on stream.

Remarks

Note

Skips inital blank characters (space, tab, EOL).

Note

Stream must have a read buffer.

Note

If stream has static read buffer, it must be big enough to hold all digits of number.

text.read.hex_q

Description

Reads unsigned hexadecimal qword from stream. This is simple version, for more options see text.extread.hex_q . Reads hexadecimal digit characters ('0'-'9','a'-'z','A'-'Z') until it reaches non-digit, EOF, or until resulting value overflows.

Arguments

stream

Handle of stream from which to read.

Returns

CF set on error, otherwise EDX:EAX = readen qword

Errors

ERR_HANDLE_EOF

EOF reached.

ERR_OUT_OF_RANGE

value > FFFFFFFFFFFFFFFF. In this case all digit characters remain on stream.

ERR_NOT_HEXADECIMAL

First character is not a hexadecimal digit. Character remains on stream.

+text.extread.hex_q

Remarks

Note

Skips inital blank characters (space, tab, EOL).

Note

Stream must have a read buffer.

Note

If stream has static read buffer, it must be big enough to hold all digits of number.

text.read.ihex

Description

This is alias text.read.hex_id .


text.read.hex_ib

Description

Reads signed hexadecimal byte from stream. This is simple version, for more options see text.extread.hex_ib . Reads optional sign ('-' or '+') and hexadecimal digit characters ('0'-'9','a'-'f','A'-'F') until it reaches non-digit, EOF, or until resulting value overflows.

Arguments

stream

Handle of stream from which to read.

Returns

CF set on error, otherwise EAX = readen byte, signed-extended to dword

Errors

ERR_HANDLE_EOF

EOF reached.

ERR_OUT_OF_RANGE

value < -80 or value > 7F. In this case sign character and all digit characters remain on stream.

ERR_NOT_HEXADECIMAL

First character (after sign) is not hexadecimal digit. Character remains on stream.

Remarks

Note

Skips inital blank characters (space, tab, EOL).

Note

Stream must have a read buffer.

Note

If stream has static read buffer, it must be big enough to hold all digits of number.

text.read.hex_iw

Description

Reads signed hexadecimal word from stream. This is simple version, for more options see text.extread.hex_iw . Reads optional sign ('-' or '+') and hexadecimal digit characters ('0'-'9','a'-'f','A'-'F') until it reaches non-digit, EOF, or until resulting value overflows.

Arguments

stream

Handle of stream from which to read.

Returns

CF set on error, otherwise EAX = readen word, sign-extended to dword

Errors

ERR_HANDLE_EOF

EOF reached.

ERR_OUT_OF_RANGE

value < -8000 or value > 7FFF. In this case sign character and all digit characters remain on stream.

ERR_NOT_HEXADECIMAL

First character (after sign) is not hexadecimal digit. Character remains on stream.

Remarks

Note

Skips inital blank characters (space, tab, EOL).

Note

Stream must have a read buffer.

Note

If stream has static read buffer, it must be big enough to hold all digits of number.

text.read.hex_id

Description

Reads signed hexadecimal dword from stream. This is simple version, for more options see text.extread.hex_id . Reads optional sign ('-' or '+') and hexadecimal digit characters ('0'-'9','a'-'f','A'-'F') until it reaches non-digit, EOF, or until resulting value overflows.

Arguments

stream

Handle of stream from which to read.

Returns

CF set on error, otherwise EAX = readen dword

Errors

ERR_HANDLE_EOF

EOF reached.

ERR_OUT_OF_RANGE

value < -80000000 or value > 7FFFFFFF. In this case sign character and all digit characters remain on stream.

ERR_NOT_HEXADECIMAL

First character (after sign) is not hexadecimal digit. Character remains on stream.

Remarks

Note

Skips inital blank characters (space, tab, EOL).

Note

Stream must have a read buffer.

Note

If stream has static read buffer, it must be big enough to hold all digits of number.

text.read.hex_iq

Description

Reads signed hexadecimal qword from stream. This is simple version, for more options see text.extread.hex_iq . Reads optional sign ('-' or '+') and hexadecimal digit characters ('0'-'9','a'-'f','A'-'F') until it reaches non-digit, EOF, or until resulting value overflows.

Arguments

stream

Handle of stream from which to read.

Returns

CF set on error, otherwise EDX:EAX = readen qword

Errors

ERR_HANDLE_EOF

EOF reached.

ERR_OUT_OF_RANGE

value < -8000000000000000 or value > 7FFFFFFFFFFFFFFF. In this case sign character and all digit characters remain on stream.

ERR_NOT_HEXADECIMAL

First character (after sign) is not hexadecimal digit. Character remains on stream.

+text.extread.hex_iq

Remarks

Note

Skips inital blank characters (space, tab, EOL).

Note

Stream must have a read buffer.

Note

If stream has static read buffer, it must be big enough to hold all digits of number.

text.extread.hex

Description

This is alias text.extread.hex_d .


text.extread.hex_b

Description

Reads unsigned hexadecimal byte from stream. This is extended version, for simpler usage see text.read.hex_b . Reads hexadecimal digit characters ('0'-'9','a'-'f','A'-'F') until it reaches non-digit, EOF, or until resulting value overflows.

Arguments

stream

Handle of stream from which to read.

maxlen

Maximum number of digits to read. 0 if not specified.

skipbl

If 1, procedure first skips initial blank characters (space, tab, EOL). These characters don't count into maxlen size.

len

Pointer to dword variable, that will be set to number of digits read. Ignored if 0. When skipbl=1, skipped initial blank characters don't count.

Returns

CF set on error, otherwise EAX = readen byte zero-extended to dword

Errors

ERR_HANDLE_EOF

EOF reached. len is set to 0.

ERR_OUT_OF_RANGE

value > FF. In this case all digit characters remain on stream. len contains number of characters readen until overflow.

ERR_NOT_HEXADECIMAL

First character is not hexadecimal digit. Character remains on stream. len is set to 0.

ERR_ZERO_VALUE

maxlen=0. len is set to 0.

ERR_INVALID_MODE

skipbl > 1. len is set to 0.

Remarks

Note

Stream must have a read buffer.

Note

If stream has static read buffer, it must be big enough to hold all digits of number.

text.extread.hex_w

Description

Reads unsigned hexadecimal word from stream. This is extended version, for simpler usage see text.read.hex_w . Reads hexadecimal digit characters ('0'-'9','a'-'f','A'-'F') until it reaches non-digit, EOF, or until resulting value overflows.

Arguments

stream

Handle of stream from which to read.

maxlen

Maximum number of digits to read. 0 if not specified.

skipbl

If 1, procedure first skips initial blank characters (space, tab, EOL). These characters don't count into maxlen size.

len

Pointer to dword variable, that will be set to number of digits read. Ignored if 0. When skipbl=1, skipped initial blank characters don't count.

Returns

CF set on error, otherwise EAX = readen word zero-extended to dword

Errors

ERR_HANDLE_EOF

EOF reached. len is set to 0.

ERR_OUT_OF_RANGE

value > FFFF. In this case all digit characters remain on stream. len contains number of characters readen until overflow.

ERR_NOT_HEXADECIMAL

First character is not hexadecimal digit. Character remains on stream. len is set to 0.

ERR_ZERO_VALUE

maxlen=0. len is set to 0.

ERR_INVALID_MODE

skipbl > 1. len is set to 0.

Remarks

Note

Stream must have a read buffer.

Note

If stream has static read buffer, it must be big enough to hold all digits of number.

text.extread.hex_d

Description

Reads unsigned hexadecimal dword from stream. This is extended version, for simpler usage see text.read.hex_d . Reads hexadecimal digit characters ('0'-'9','a'-'f','A'-'F') until it reaches non-digit, EOF, or until resulting value overflows.

Arguments

stream

Handle of stream from which to read.

maxlen

Maximum number of digits to read. 0 if not specified.

skipbl

If 1, procedure first skips initial blank characters (space, tab, EOL). These characters don't count into maxlen size.

len

Pointer to dword variable, that will be set to number of digits read. Ignored if 0. When skipbl=1, skipped initial blank characters don't count.

Returns

CF set on error, otherwise EAX = readen dword

Errors

ERR_HANDLE_EOF

EOF reached. len is set to 0.

ERR_OUT_OF_RANGE

value > FFFFFFFF. In this case all digit characters remain on stream. len contains number of characters readen until overflow.

ERR_NOT_HEXADECIMAL

First character is not hexadecimal digit. Character remains on stream. len is set to 0.

ERR_ZERO_VALUE

maxlen=0. len is set to 0.

ERR_INVALID_MODE

skipbl > 1. len is set to 0.

Remarks

Note

Stream must have a read buffer.

Note

If stream has static read buffer, it must be big enough to hold all digits of number.

text.extread.hex_q

Description

Reads unsigned hexadecimal qword from stream. This is extended version, for simpler usage see text.read.hex_d . Reads hexadecimal digit characters ('0'-'9','a'-'f','A'-'F') until it reaches non-digit, EOF, or until resulting value overflows.

Arguments

stream

Handle of stream from which to read.

maxlen

Maximum number of digits to read. 0 if not specified.

skipbl

If 1, procedure first skips initial blank characters (space, tab, EOL). These characters don't count into maxlen size.

len

Pointer to dword variable, that will be set to number of digits read. Ignored if 0. When skipbl=1, skipped initial blank characters don't count.

Returns

CF set on error, otherwise EDX:EAX = readen qword

Errors

ERR_HANDLE_EOF

EOF reached. len is set to 0.

ERR_OUT_OF_RANGE

value > FFFFFFFFFFFFFFFF. In this case all digit characters remain on stream. len contains number of characters readen until overflow.

ERR_NOT_HEXADECIMAL

First character is not hexadecimal digit. Character remains on stream. len is set to 0.

ERR_ZERO_VALUE

maxlen=0. len is set to 0.

ERR_INVALID_MODE

skipbl > 1. len is set to 0.

+text.skip.chars
+stream.peek.byte
+stream.peek
+stream.skip

Remarks

Note

Stream must have a read buffer.

Note

If stream has static read buffer, it must be big enough to hold all digits of number.

text.extread.ihex

Description

This is alias text.extread.hex_id .


text.extread.hex_ib

Description

Reads signed hexadecimal byte from stream. This is extended version, for simpler usage see text.read.hex_ib . Reads hexadecimal digit characters ('0'-'9','a'-'f','A'-'F') until it reaches non-digit, EOF, or until resulting value overflows.

Arguments

stream

Handle of stream from which to read.

maxlen

Maximum number of characters to read, including sign. 0 if not specified.

skipbl

If 1, procedure first skips initial blank characters (space, tab, EOL). These characters don't count into maxlen size. These characters do not remain on stream in case of error.

allowplus

If 1, plus sign "+" is accepted.

len

Pointer to dword variable, that will be set to number of digits read. Ignored if 0. When skipbl=1, skipped initial blank characters don't count.

Returns

CF set on error, otherwise EAX = readen byte value, sign-extended to dword.

Errors

ERR_HANDLE_EOF

EOF reached. len is set to 0.

ERR_OUT_OF_RANGE

value < -80 or value > 7F. In this case sign character and all digit characters remain on stream. len contains number of characters readen until overflow.

ERR_NOT_HEXADECIMAL

First character (after sign) is not a hexadecimal digit. Characters remains on stream. len is set to 0.

ERR_ZERO_VALUE

maxlen=0. len is set to 0.

ERR_INVALID_MODE

skipbl > 1. len is set to 0.

Remarks

Note

Stream must have a read buffer.

Note

If stream has static read buffer, it must be big enough to hold all characters of number.

text.extread.hex_iw

Description

Reads signed hexadecimal word from stream. This is extended version, for simpler usage see text.read.hex_iw . Reads hexadecimal digit characters ('0'-'9','a'-'f','A'-'F') until it reaches non-digit, EOF, or until resulting value overflows.

Arguments

stream

Handle of stream from which to read.

maxlen

Maximum number of characters to read, including sign. 0 if not specified.

skipbl

If 1, procedure first skips initial blank characters (space, tab, EOL). These characters don't count into maxlen size. These characters do not remain on stream in case of error.

allowplus

If 1, plus sign "+" is accepted.

len

Pointer to dword variable, that will be set to number of digits read. Ignored if 0. When skipbl=1, skipped initial blank characters don't count.

Returns

CF set on error, otherwise EAX = readen word value, sign-extended to dword.

Errors

ERR_HANDLE_EOF

EOF reached. len is set to 0.

ERR_OUT_OF_RANGE

value < -8000 or value > 7FFF. In this case sign character and all digit characters remain on stream. len contains number of characters readen until overflow.

ERR_NOT_HEXADECIMAL

First character (after sign) is not a hexadecimal digit. Characters remains on stream. len is set to 0.

ERR_ZERO_VALUE

maxlen=0. len is set to 0.

ERR_INVALID_MODE

skipbl > 1. len is set to 0.

Remarks

Note

Stream must have a read buffer.

Note

If stream has static read buffer, it must be big enough to hold all characters of number.

text.extread.hex_id

Description

Reads signed hexadecimal dword from stream. This is extended version, for simpler usage see text.read.hex_id . Reads hexadecimal digit characters ('0'-'9','a'-'f','A'-'F') until it reaches non-digit, EOF, or until resulting value overflows.

Arguments

stream

Handle of stream from which to read.

maxlen

Maximum number of characters to read, including sign. 0 if not specified.

skipbl

If 1, procedure first skips initial blank characters (space, tab, EOL). These characters don't count into maxlen size. These characters do not remain on stream in case of error.

allowplus

If 1, plus sign "+" is accepted.

len

Pointer to dword variable, that will be set to number of digits read. Ignored if 0. When skipbl=1, skipped initial blank characters don't count.

Returns

CF set on error, otherwise EAX = readen dword value.

Errors

ERR_HANDLE_EOF

EOF reached. len is set to 0.

ERR_OUT_OF_RANGE

value < -80000000 or value > 7FFFFFFF. In this case sign character and all digit characters remain on stream. len contains number of characters readen until overflow.

ERR_NOT_HEXADECIMAL

First character (after sign) is not a hexadecimal digit. Characters remains on stream. len is set to 0.

ERR_ZERO_VALUE

maxlen=0. len is set to 0.

ERR_INVALID_MODE

skipbl > 1. len is set to 0.

Remarks

Note

Stream must have a read buffer.

Note

If stream has static read buffer, it must be big enough to hold all characters of number.

text.extread.hex_iq

Description

Reads signed hexadecimal qword from stream. This is extended version, for simpler usage see text.read.hex_iq . Reads hexadecimal digit characters ('0'-'9','a'-'f','A'-'F') until it reaches non-digit, EOF, or until resulting value overflows.

Arguments

stream

Handle of stream from which to read.

maxlen

Maximum number of characters to read, including sign. 0 if not specified.

skipbl

If 1, procedure first skips initial blank characters (space, tab, EOL). These characters don't count into maxlen size. These characters do not remain on stream in case of error.

allowplus

If 1, plus sign "+" is accepted.

len

Pointer to dword variable, that will be set to number of digits read. Ignored if 0. When skipbl=1, skipped initial blank characters don't count.

Returns

CF set on error, otherwise EDX:EAX = readen qword value.

Errors

ERR_HANDLE_EOF

EOF reached. len is set to 0.

ERR_OUT_OF_RANGE

value < -8000000000000000 or value > 7FFFFFFFFFFFFFFF. In this case sign character and all digit characters remain on stream. len contains number of characters readen until overflow.

ERR_NOT_HEXADECIMAL

First character (after sign) is not a hexadecimal digit. Characters remains on stream. len is set to 0.

ERR_ZERO_VALUE

maxlen=0. len is set to 0.

ERR_INVALID_MODE

skipbl > 1. len is set to 0.

+text.skip.chars
+stream.peek.byte
+stream.peek
+stream.skip

Remarks

Note

Stream must have a read buffer.

Note

If stream has static read buffer, it must be big enough to hold all characters of number.

text.read.char

Description

This is alias for stream.read.byte .


text.read.line

Description

Reads one line of text from stream to buffer. This is simpler version of procedure, for extended version see text.extread.line .

Arguments

stream

Stream to read characters from.

buffer

Pointer to destination buffer, where the characters will be stored.

buflen

Length of destination buffer.

Returns

CF=1 on error, otherwise EAX = number of characters readen, and ZF=1 if EAX=0 (no characters readen).

Errors

ERR_ZERO_SIZE

buflen=0.

ERR_BUFFER_FULL

Destiantion buffer is full. Only buflen characters readen, and string in destination buffer is NOT zero-terminated.

ERR_HANDLE_EOF

EOF reached without reading anything.

+text.extread.line

Remarks

Note

Supports both LF and CRLF end of line combinations.

Note

End of line character is not stored in resulting string.

text.read.chars

Description

Reads from stream to buffer all characters which are in given character list. This is simpler version of procedure, for extended version see text.extread.chars .

Arguments

stream

Stream to read characters from.

buffer

Pointer to destination buffer, where the characters will be stored.

buflen

Length of destination buffer.

charlist

Null-terminated string containing list of characters to read.

Returns

CF=1 on error, otherwise EAX = number of characters readen, and ZF=1 if EAX=0 (no characters readen).

Errors

ERR_ZERO_SIZE

buflen=0.

ERR_BUFFER_FULL

Destiantion buffer is full. Only buflen characters readen, and string in destination buffer is NOT zero-terminated.

ERR_HANDLE_EOF

EOF reached without reading anything.

+text.extread.chars

Remarks

Note

This function never reads character 0 from stream.

text.read.until

Description

Reads all characters from stream to buffer, until it hits character from given list of characters. This is simpler version of procedure, for extended version see text.extread.until .

Arguments

stream

Stream to read characters from.

buffer

Pointer to destination buffer, where the characters will be stored.

buflen

Length of destination buffer.

charlist

Null-terminated string containing list of characters which end reading.

Returns

CF=1 on error, otherwise EAX = number of characters readen, and ZF=1 if EAX=0 (no characters readen).

Errors

ERR_ZERO_SIZE

buflen=0.

ERR_BUFFER_FULL

Destiantion buffer is full. Only buflen characters readen, and string in destination buffer is NOT zero-terminated.

ERR_HANDLE_EOF

EOF reached without reading anything.

+text.extread.until

Remarks

Note

This function never reads character 0 from stream.

text.fetch

Description

Reads specified ASCII string off the stream. If there is another string on stream, then nothing is read and ZF=1 is returned. This procedure should be only used with constant string argument. Use text.fetch.str for non-constant strings.

Arguments

stream

Handle of stream to read from.

string

String to fetch from stream.

Returns

CF set on error, otherwise ZF set if the string was fetched

Errors

Remarks

Warning

Only use this if string is guaranteed to be null terminated. Otherwise, use text.fetch.str .

Note

For standard input, you can call stdin.fetch instead of passing stdin as argument.

text.fetch.char

Description

Reads specified ASCII character off the stream. If there is another character on stream, then nothing is read and ZF=1 is returned.

Arguments

stream

Handle of stream to read from.

char

Character to fetch from stream. Low order byte of this dword is used, rest is ignored.

Returns

CF set on error, otherwise ZF set if the character was fetched

Remarks

Note

For standard input, you can call stdin.fetch.char instead of passing stdin as argument.

text.fetch.str

Description

Reads specified ASCII string off the stream. If there is another string on stream, then nothing is read and ZF=1 is returned. If string is guaranteed to be null terminated, you can use text.fetch instead.

Arguments

stream

Handle of stream to read from.

string

String to fetch from stream.

buflen

Length of string buffer.

Returns

CF set on error, otherwise ZF set if the string was fetched

Remarks

Note

For standard input, you can call stdin.fetch.str instead of passing stdin as argument.

text.skip.chars

Description

Skips all characters which are in given character list from stream. This is simpler version of procedure, for extended version see text.extskip.chars .

Arguments

stream

Stream to skip characters from.

charlist

Null-terminated string containing list of characters to read.

Returns

CF=1 on error, otherwise OF=1 if we are on EOF, otherwise EAX = number of characters skipped

Remarks

Note

This function never skips character 0 from stream.

text.skip.until

Description

Skips all characters from stream, until it reaches character from given character list. This is simpler version of procedure, for extended version see text.extskip.until .

Arguments

stream

Stream to skip characters from.

charlist

Null-terminated string containing list of characters which not to skip.

Returns

CF=1 on error, otherwise OF=1 if we are on EOF, otherwise EAX = number of characters skipped

Remarks

Note

This function never skips character 0 from stream.

text.extread.line

Description

Reads one line of text from stream to buffer. This is extended version of procedure, for simpler version see text.read.line .

Arguments

stream

Stream to read characters from.

buffer

Pointer to destination buffer, where the characters will be stored.

buflen

Length of destination buffer.

maxlen

Maximum number of characters to read. Ignored if 0.

len

Pointer to dword variable, which on return holds number of characters readen. This is same value as one returned in EAX, and is only useful on ERR_BUFFER_FULL. Ignored if 0.

Returns

CF=1 on error, otherwise EAX = number of characters readen, and ZF=1 if EAX=0 (no characters readen).

Errors

ERR_ZERO_SIZE

buflen=0. len is set to 0.

ERR_BUFFER_FULL

Destiantion buffer is full. Only buflen characters readen, and string in destination buffer is NOT zero-terminated. len is set to buflen.

ERR_HANDLE_EOF

EOF reached without reading anything. len is set to 0.

+text.extread.until
+text.fetch.char

Remarks

Note

Supports both LF and CRLF end of line combinations.

Note

End of line character is not stored in resulting string.

text.extread.chars

Description

Reads from stream to buffer all characters which are in given character list. This is extended version of procedure, for simpler version see text.read.chars .

Arguments

stream

Stream to read characters from.

buffer

Pointer to destination buffer, where the characters will be stored.

buflen

Length of destination buffer.

charlist

Null-terminated string containing list of characters to read.

maxlen

Maximum number of characters to read. Ignored if 0.

len

Pointer to dword variable, which on return holds number of characters readen. This is same value as one returned in EAX, and is only useful on ERR_BUFFER_FULL. Ignored if 0.

Returns

CF=1 on error, otherwise EAX = number of characters readen, and ZF=1 if EAX=0 (no characters readen).

Errors

ERR_ZERO_SIZE

buflen=0. len is set to 0.

ERR_BUFFER_FULL

Destiantion buffer is full. Only buflen characters readen, and string in destination buffer is NOT zero-terminated. len is set to buflen.

ERR_HANDLE_EOF

EOF reached without reading anything. len is set to 0.

+stream.peek.byte
+str.poschar
+stream.skip

Remarks

Note

This function never reads character 0 from stream.

text.extread.until

Description

Reads all characters from stream to buffer, until it hits character from given list of characters. This is extended version of procedure, for simpler version see text.read.until .

Arguments

stream

Stream to read characters from.

buffer

Pointer to destination buffer, where the characters will be stored.

buflen

Length of destination buffer.

charlist

Null-terminated string containing list of characters which end reading.

maxlen

Maximum number of characters to read. Ignored if 0.

len

Pointer to dword variable, which on return holds number of characters readen. This is same value as one returned in EAX, and is only useful on ERR_BUFFER_FULL. Ignored if 0.

Returns

CF=1 on error, otherwise EAX = number of characters readen, and ZF=1 if EAX=0 (no characters readen).

Errors

ERR_ZERO_SIZE

buflen=0. len is set to 0.

ERR_BUFFER_FULL

Destiantion buffer is full. Only buflen characters readen, and string in destination buffer is NOT zero-terminated. len is set to buflen.

ERR_HANDLE_EOF

EOF reached without reading anything. len is set to 0.

+stream.peek.byte
+str.poschar
+stream.skip

Remarks

Note

This function never reads character 0 from stream.

text.extskip.chars

Description

Skips all characters which are in given character list from stream. This is extended version of procedure, for simpler version see text.skip.chars .

Arguments

stream

Stream to skip characters from.

charlist

Null-terminated string containing list of characters to read.

maxlen

Maximum number of characters to skip. Ignored if 0.

Returns

CF=1 on error, otherwise OF=1 if we are on EOF, otherwise EAX = number of characters skipped

Remarks

Note

This function never skips character 0 from stream.

text.extskip.until

Description

Skips all characters from stream, until it reaches character from given character list. This is extended version of procedure, for simpler version see text.skip.until .

Arguments

stream

Stream to skip characters from.

charlist

Null-terminated string containing list of characters which not to skip.

maxlen

Maximum number of characters to skip. Ignored if 0.

Returns

CF=1 on error, otherwise OF=1 if we are on EOF, otherwise EAX = number of characters skipped

Remarks

Note

This function never skips character 0 from stream.

Output Format String

Outpu Format String is string used in formatted text output functions to specify format of output. Best known example is printf function in C language. In FASMLIB, it is used in text.write.format.

For those unfamiliar with it, format string is just printed to output as-is, except when it contains special marker, usually started with "%" character. This marker is replaced by other string value in output. String by which marker is replaced is specified by type character following marker.

There can be modifiers between "%" and type character, which specify how to display value. For example "%d" displays decimal value, and "%8d" displays decimal value padded to 8 characters.

FASMLIB has it's own format string. Altough it's pretty unpopular to break compatibility with C format strings, these just aren't suitable for usage in assembly language.

FASMLIB format strings is printed as-is, except case when one of two special characters are found:

\

Backslash is used as escape character. It ensures that character following it is printed as-is. This is only useful to display "%" character. Backslash cannot be last character in string.

%

Percent sign is used to specify that value of variable is displayed. It is followed by optional modifiers, and type character. Allowed modifiers depend on type.

This is list of FASMLIB type characters:

c

Prints single character. Argument is dword, but only low-order byte of it is used.

Can be prefixed by "P". Then, argument is pointer to character which is printed. This is useful if pushing character extended to dword is problem.

s

Prints zero-terminated string. Argument is pointer to string.

Do not use if you aren't sure string is properly zero-terminated. If you aren't sure that string is zero terminated, use "S" instead, and specify buffer size.

Can be prefixed by decimal number, which sets padding length. Then, if string is shorter than padding length, after string is printed, additional spaces are printed to print given number of characters. This is useful to format output to columns.

Examples:

  • "%s" prints string as-is
  • "%10s" prints string, and pads it to 10 characters if it is shorter

S

Prints zero-terminated string from buffer of given size. If string isn't zero-terminated within buffer, then only part that is in buffer is printed. This takes two arguments, first is pointer to string, and second is size of string buffer.

If you are sure string is properly zero-terminated, you can use "s" type character instead.

Can be prefixed by decimal number, which sets padding length. Then, if string is shorter than padding length, after string is printed, additional spaces are printed to print given number of characters. This is useful to format output to columns.

Examples:

  • "%S" prints string as-is
  • "%10S" prints string, and pads it to 10 characters if it is shorter

h, x

Prints hexadecimal number. Argument is number to print.

Can be prefixed by decimal number, which sets padding length. Then, if number is shorter than padding length, it is padded with spaces. Number is aligned to right in the padding area. If padding length starts with "0", number is padded with "0" characters instead of spaces.

Optional "P" character may follow to specify argument is pointer to value, instead of value itself. This is useful mainly for non-dword sizes, which are harder to push.

Optional "B", "W", or "Q" can follow to override size of argument. "B" specifies byte, "W" specifies word, and "Q" specifies qword. Both byte and word must be still pushed as dwords, but only low-order portion of dword is taken as actual value. Qword must be pushed as two dwords (if not pointed, using "P"). Size override "D" (for dword) is allowed, but has no effect, it is default option.

Size overrides can be combined with "P", meaning argument is pointer to data of specified size.

Optional "i" character may follow to specify number should be printed as signed.

Examples:

  • "%h" prints unsigned hexadecimal dword
  • "%ih" prints signed hexadecimal dword
  • "%08h" prints unsigned hexadecimal dword in full 8 digits
  • "%Bh" prints unsigned hexadecimal byte
  • "%Bih" prints signed hexadecimal byte
  • "%PBh" prints unsigned hexadecimal byte pointed by argument
  • "%PBih" prints signed hexadecimal byte pointed by argument
  • "%04Wih" prints signed hexadecimal word pointed by argument, padded with zeroes to 4 characters
  • "%02PBih" print byte pointed by argument as signed hexadecimal number zero-padded to 2 characters

d

Prints decimal number. Argument is number to print.

Can be prefixed by decimal number, which sets padding length. Then, if number is shorter than padding length, it is padded with spaces. Number is aligned to right in the padding area. If padding length starts with "0", number is padded with "0" characters instead of spaces.

Optional "P" character may follow to specify argument is pointer to value, instead of value itself. This is useful mainly for non-dword sizes, which are harder to push.

Optional "i" character may follow to specify number should be printed as signed. If number is padded, positive numbers are padded by one additional space.

Optional "B", "W", or "Q" can follow to override size of argument. "B" specifies byte, "W" specifies word, and "Q" specifies qword. Both byte and word must be still pushed as dwords, but only low-order portion of dword is taken as actual value. Qword must be pushed as two dwords (if not pointed, using "P"). Size override "D" (for dword) is allowed, but has no effect, it is default option.

Size overrides can be combined with "P", meaning argument is pointer to data of specified size.

Examples:

  • "%d" prints unsigned decimal dword
  • "%id" prints signed decimal dword
  • "%10d" prints unsigned decimal dword padded to 10 characters
  • "%Bd" prints unsigned decimal byte
  • "%Bid" prints signed decimal byte
  • "%PBd" prints unsigned decimalbyte pointed by argument
  • "%PBid" prints signed decimal byte pointed by argument
  • "%02PBid" print byte pointed by argument as signed decimal number zero-padded to 2 characters

Chapter 10. Internal Features

When FASMLIB is included directly by sources, all it's internal features can be used by project that includes FASMLIB.

This chapter describes those features.

Data Macros

FASMLIB contains set of macros that collect data definitions from various places in source code, and then place them in one place (usually data segment).

There are two of these macros: idata and udata.

idata is used for initialized data. Initialized daat are those whose value is set at compile time.

udata is used for uninitialized data. Value of uninitialized data is unknown when program starts, and so they don't have to be present in executable.

You define these data, just like you would define any macro body:

	idata {
	  mystring db "my string",0
	  mylabel dd x+5
	}
	udata {
	  buffer rb 100 
	}
	

Even though udata blocks do allow having initialized data in them, value of data may not be initialized to desired value:

	udata {
	  variable dd 100  ;whooops
	}
	

To actually define all data collected with idata and udata, you use macros IncludeIData and IncludeUData, respectively. These macros must be used AFTER all idata and udata definitions.

IncludeIData must be used in writeable readable place, usually somewhere in data section.

IncludeUData must be used in writeable readable place too, but should be placed after all initialized data definitions. That way, uninitialized data won't waste space in executable. Best place is usually end of data section.

Data blocks are defined in reversed order as they appear in source, and every block is aligned to 4 bytes.

idata and udata blocks beheave like any macro definitions. That means, that if you want to use them inside another macro definition, you must escape { and } symbols:

	macro MyMacro {
	  idata \{
	    string db 'blah',0
	  \}
	}
	

idata and udata blocks are moved to IncludeIData and IncludeUData positions during preprocessing stage. That means you cannot enclose them assembly-time conditions:

	if 0
	  idata {
	    string db 'blah',0   ;data is defined anyway
	  }
	end if
	

proper way to do this is to place if inside idata block, so it is moved together with data:

	idata {
	  if 0
	    string db 'blah',0   ;data won't be defined
	  end if
	}	
	

Do not use labels local to namespace defined outside of block. It won't work:

	namespace:
	idata {
	  .a dd 0	;error
	}
	

You can use labels local to namespace defined inside block though:

	idata {
	  namespace:
	  .a dd 0	;okay
	}
	

idata and udata are just usual macro definitions, so you can use all macrofeatures inside them. But rather don't do it unless you are sure about what you are doing:

	idata {
	  local length  ; <-- macrofeature
	  pascal_style_string db length
	  db "this is a veeeery long string and i am lazy to count it's size"
	  length = $-pascal_style_string-1
	}
	

libcall

FASMLIB provides macro libcall for HLL-style calling of it's procedures. It can be used for calling other FASMLIB-style procedures too.

First, required, argument of libcall is name of procedure to call.

	libcall	fasmlib.init
	

Rest of arguments are pushed to stack in reversed order, so they act as arguments for called procedure.

Those arguments can be value pushable by "push dword" (label, number, memory-addressed dword, ...), or one of following:

If argument is in form qword value, qword [value], or qword ptr value, then two pushes are used to push value.

If argument is in form addr value, and value cannot be directly pushed (like ebp+8), then argument is loaded to register and pushed. In FASMLIB implementation (unlike many others) used register is preserved, so you can use constructs like this:

	libcall	proc1, eax, edx, addr local_variable
	

If argument is quoted string, or it is comma-separated list in brackets, argument is declared as zero-terminated string and its offset is pushed. String is declared in idata block, not directly in code.

	libcall	stdout.write, "Hello World"
	libcall	str.copy, buffer, BUFFER_SIZE, <"Hello World", 13, 10>, -1
	libcall	stdout.write, <10,"Usage:",10,"app.exe param1 param2",10>
	

It isn't possible to push string consisting of single byte, given by it's ASCII value, like this:

	libcall	stdout.write, <10>	;move to next line
	

This code will push dword value 10, instead of pushing offset of string that contains character 10. There must always be at least two values in brackets, for argument to be treated as string. Simple workaround:

	libcall	stdout.write, <"",10>	;move to next line
	

If argument is in form <libcall ...>, it is nested call. This call is done before pushing value of argument, and return value from call is pushed as argument. For example, following code:

	libcall	proc1, 1, <libcall proc2, 2>, 3	

becomes:

	push 3		;argument 3 for proc1
	push 2		;argument 1 for proc2
	call proc2
	push eax	;argument 2 for proc1
	push 1		;argument 1 for proc1
	call proc1
	

Additionally, because all FASMLIB procedures return error in CF, this macro allows checking errors on all nested calls with single jc, like this:

	libcall proc1, 1, <libcall proc2, 2>, 3
	jc .error	;this checks both error from proc1 and proc2
	

generated code looks like this:

	push dword 3	;for proc1
	push dword 2	;for proc2
	call proc2
	jnc ..noerr
	lea esp,[esp+4]	;restore stack
	jmp ..ret
	..noerr:
	push eax	;for proc1
	push dword 1	;for proc1
	call proc1
	..ret:
	

ifndef

Sometimes you need to know, if symbol is already defined previously in sources. Doing this in FASM is little tricky. There is "defined" operator, but it checks entire source, not only previous part of source. For example consider following code:

	if defined a
	  display 'defined'  ;this one will get assembled
	else
	  display 'not defined'
	end if
	a:
	

That also means following code can't be used:

	if ~defined a
	  a:
	end if	

this code is logical paradox (if 'a' is not defined, then 'a' is defined), and it's behavior cannot be clearly defined.

That's why there is ifndef macro. It checks whether symbol is defined previously in sources:

	a:
	ifndef a		;false
	  db 'a not defined'   
	end if
	ifndef b		;true
	  db 'b not defined'
	end if
	b:
	

Following construct is allowed aswell:

	ifndef a
	  a:
	end if
	

Argument can be any expression acceptable to defined operator, not just single symbol, see FASM manual for more info.

	ifndef (a+b/c)
	

disp

FASM has display directive to display compile-time output. Unfortunatelly, it is pretty hard to display values of numeric constant using it.

For that purpose, FASMLIB provides disp macro. It provides simple formatted compile-time output.

disp takes at least one argument. If argument is string literal, it is printed as-in.

If argument is in form dec value, then value is displayed as decimal number.

If argument is in form hex value, then value is displayed as hexadecimal number.

disp automatically ends line after printing all arguments.

Example of using disp:

	disp 'x=', dec x
	disp 'value of ABC is ', dec abc, ' (0x', hex ABC, ')'
	

Time/Date macros

FASM provides predefined constant %t, which is timedate stamp of compilation time. Turning timedate stamp to real time and date can be problematic tough.

For that reason, FASMLIB provides macro which loads current time and date into symbolic and numeric constants.

Following numeric constants are defined: SECOND (0-59), MINUTE (0-59), HOUR (0-23), DAY (1-31), MONTH (1-12), YEAR.

There are also two symbolic constants defined, to be used with db directive. TIME is day time in format hh:mm:ss. DATE is date in ISO format yyyy-mm-dd.

These symbolic constants are NOT strings. Getting string from %t is unfortunately not possible in FASM. They are just comma-separated byte values, which will compose string when used with db or du.

Branch Hints

Condition branch instruction (conditional jumps, je, jna, etc..) can be prefix with CS or DS prefix. These prefixes have special meaning for CPU's branch predicting. Jump prefixed with CS is likely not to be taken, and jump prefixed with DS is likely to be taken. These prefixes are called branch hints.

FASM allows to use form cs jcc somewhere and ds jcc somewhere (where jcc is conditional jump), but this form is not very readable, and you have to remember which prefix has which effect.

For that reason, FASMLIB overloads all conditional jump instructions (jc, jnc, jp, jnp, je, jz, ja, jb, jae, jbe, jg, jl, jge, jle, jne, jnz, jna, jnb, jnae, jnbe, jng, jnl, jnge, jnle, jo, jno) with macro that allows following form:

	jcc taken somewhere
	jcc untaken somewhere
	

Few examples:

	jc untaken error
	jnz taken loop_again
	

Compilation stopping macros

Interrupting FASM compilation is not as easy as it may seem. It is possible to interrupt compilation during preprocessing, during assembling pass, or during final pass.

FASMLIB provides three pseudo-directives to stop compilation: __preprocess_error, __pass_error, and __assembly_error.

You can place string literal with description of problem into same line behind these pseudo-opcode. It will display in error message then as part of instruction.

Chapter 11. File Layout

This chapter describes FASMLIB file layout. All paths are relative to FASMLIB directory.

src/

You can source code of FASMLIB here. There is a ".inc" file and a subdirectory for each module. These subdirectories contain platform-independent part of code.

src/_win32/, src/_linux/

These directories contain platform-specific part of code.

doc/

You can find TFM and tutorial here.

bin/

This directory contains FASMLIB compiled to binary object forms. You can link these to your project.

include/fasm/, include/masm/, include/nasm/

These directories contain includes to use FASMLIB from various assemblers. Includes in NASM directory also work in YASM.

examples/fasm/, examples/masm/, examples/nasm/

These directories contain examples of fasmlib usage. They may contain subdirectories "win32" and "linux" for platform-specific examples, and subdirectory "portable" for portable examples.

Chapter 12. Credits

Thanks goes to:

  • Tomasz Grysztar (Privalov) for FASM, the best assembler around
  • arafael for his linux syscalls reference
  • MazeGen for help with MASM port, and for some discussions on subject
  • Two of workmates for discussions on many involved subjects
  • Oleh Yuschuk for OllyDbg
  • Don Bailey (HyperVista) for lot of help to FASM community
  • WooDy, and czechoslovak gentoo community (IRC channel #gentoo.cs@freenode.org) for help with utilizing Linux testing.

FASMLIB was written mostly under Windows XP, using FASMW editor/compiler, debugged with OllyDbg. Linux version was tested and debugged mostly with strace on Gentoo linux.

Chapter 13. Help Wanted

FASMLIB project still needs lot of work. Any experienced assembly coder, and everyone who can help will be greatly appreaciated.

Please contact me if you are willing to help.

What I need most:

  • Someone for linux testing and/or developing. For now I only sport one distribution inside virtual machine. Especially people with security kernel patches, which may affect binary-level behavior of system.
  • Linux .a format.
  • Way to find out command line arguments on linux from anywhere (eg. not only from entry point).
  • More examples and tutorials.
  • More publicity :)

Chapter 14. Contact

For now, sole author of FASMLIB is me, Martin Mocko aka. vid. I am 21 years old, and I live in Slovak Republic.

If you have any questions, ideas, bugreports, complaints or anything regarding this library, send them to fasmlib@x86asm.net.

If you want to discuss some FASMLIB issue publicly, please notify me about it with e-mail. I will happily join the discussion.

Any feedback is welcomed.

Index

Symbols

%FASMLIB% (Environment Variable), Environment Variable FASMLIB

A

About FASMLIB, About FASMLIB
Assembler-Specific Usage, Assembler-Specific Usage

B

Branch Hints, Branch Hints

C

Checking for Error, Checking for Error
compilation stop macros, Compilation stopping macros
conv.b_dec, conv.b_dec
conv.b_hex, conv.b_hex
conv.d_dec, conv.d_dec
conv.d_hex, conv.d_hex
conv.dec_b, conv.dec_b
conv.dec_d, conv.dec_d
conv.dec_ib, conv.dec_ib
conv.dec_id, conv.dec_id
conv.dec_iq, conv.dec_iq
conv.dec_iw, conv.dec_iw
conv.dec_q, conv.dec_q
conv.dec_w, conv.dec_w
conv.hex_b, conv.hex_b
conv.hex_d, conv.hex_d
conv.hex_ib, conv.hex_ib
conv.hex_id, conv.hex_id
conv.hex_iq, conv.hex_iq
conv.hex_iw, conv.hex_iw
conv.hex_q, conv.hex_q
conv.hex_w, conv.hex_w
conv.ib_dec, conv.ib_dec
conv.ib_hex, conv.ib_hex
conv.id_dec, conv.id_dec
conv.id_hex, conv.id_hex
conv.iq_dec, conv.iq_dec
conv.iq_hex, conv.iq_hex
conv.iw_dec, conv.iw_dec
conv.iw_hex, conv.iw_hex
conv.q_dec, conv.q_dec
conv.q_hex, conv.q_hex
conv.w_dec, conv.w_dec
conv.w_hex, conv.w_hex
Conversion, Conversion

D

Data Macros, Data Macros
disp, disp

E

Environment Variable FASMLIB, Environment Variable FASMLIB
err.text, err.text
extconv.b_dec, extconv.b_dec
extconv.b_hex, extconv.b_hex
extconv.d_dec, extconv.d_dec
extconv.d_hex, extconv.d_hex
extconv.dec_b, extconv.dec_b
extconv.dec_d, extconv.dec_d
extconv.dec_ib, extconv.dec_ib
extconv.dec_id, extconv.dec_id
extconv.dec_iq, extconv.dec_iq
extconv.dec_iw, extconv.dec_iw
extconv.dec_q, extconv.dec_q
extconv.dec_w, extconv.dec_w
extconv.hex_b, extconv.hex_b
extconv.hex_d, extconv.hex_d
extconv.hex_ib, extconv.hex_ib
extconv.hex_id, extconv.hex_id
extconv.hex_iq, extconv.hex_iq
extconv.hex_iw, extconv.hex_iw
extconv.hex_q, extconv.hex_q
extconv.hex_w, extconv.hex_w
extconv.ib_dec, extconv.ib_dec
extconv.ib_hex, extconv.ib_hex
extconv.id_dec, extconv.id_dec
extconv.id_hex, extconv.id_hex
extconv.iq_dec, extconv.iq_dec
extconv.iq_hex, extconv.iq_hex
extconv.iw_dec, extconv.iw_dec
extconv.iw_hex, extconv.iw_hex
extconv.q_dec, extconv.q_dec
extconv.q_hex, extconv.q_hex
extconv.w_dec, extconv.w_dec
extconv.w_hex, extconv.w_hex

F

FASMLIB (Environment Variable), Environment Variable FASMLIB
fasmlib.init, fasmlib.init
fasmlib.shutdown, fasmlib.shutdown
fasmlib.uninit, fasmlib.uninit
File I/O, File I/O
File Layout, File Layout
file.append, file.append
file.close, file.close
file.create, file.create
file.extappend, file.extappend
file.extcreate, file.extcreate
file.extopen, file.extopen
file.extopen.handle, file.extopen.handle
file.open, file.open
file.open.handle, file.open.handle
file.peek, file.peek
file.peek.byte, file.peek.byte
file.read, file.read
file.read.byte, file.read.byte
file.seek, file.seek
file.tell, file.tell
file.write, file.write
file.write.byte, file.write.byte
file.write.dword, file.write.dword
file.write.word, file.write.word
fileio.append, fileio.append
fileio.close, fileio.close
fileio.create, fileio.create
fileio.open, fileio.open
fileio.read, fileio.read
fileio.seek, fileio.seek
fileio.size, fileio.size
fileio.tell, fileio.tell
fileio.write, fileio.write
fstream._close, fstream._close
fstream._peek, fstream._peek
fstream._read, fstream._read
fstream._seek, fstream._seek
fstream._tell, fstream._tell
fstream._write, fstream._write

H

Heap, Heap
Heap - How it works, Heap - How it works
Heap Corruption, Heap - How it works
Heap Fragmentation, Heap - How it works
Heap Manager, Heap - How it works

I

idata, Data Macros
ifndef, ifndef
IncludeIData, Data Macros
IncludeUData, Data Macros
Internal Features, Internal Features

L

libcall, libcall

M

mem.alloc, mem.alloc
mem.alloc0, mem.alloc0
mem.alloc_heap, mem.alloc_heap
mem.cmp, mem.cmp
mem.copy, mem.copy
mem.fill, mem.fill
mem.find, mem.find
mem.free, mem.free
mem.free_heap, mem.free_heap
mem.init, mem.init
mem.realloc, mem.realloc
mem.realloc0, mem.realloc0
mem.realloc_heap, mem.realloc_heap
mem.size, mem.size
mem.uninit, mem.uninit
Memory Leaks, Memory Leak
Memory Management, Memory Management
mstream._peek, mstream._peek
mstream._read, mstream._read
mstream._seek, mstream._seek
mstream._skip, mstream._skip
mstream._tell, mstream._tell
mstream._write, mstream._write
mstream.create, mstream.create
mstream.extcreate, mstream.extcreate

O

Output Format String, Output Format String

P

Process Management, Process Management
process.exit, process.exit

S

stderr.extwrite.b_dec, stderr.extwrite.b_dec
stderr.extwrite.b_hex, stderr.extwrite.b_hex
stderr.extwrite.d_dec, stderr.extwrite.d_dec
stderr.extwrite.d_hex, stderr.extwrite.d_hex
stderr.extwrite.dec, stderr.extwrite.dec
stderr.extwrite.hex, stderr.extwrite.hex
stderr.extwrite.ib_dec, stderr.extwrite.ib_dec
stderr.extwrite.ib_hex, stderr.extwrite.ib_hex
stderr.extwrite.id_dec, stderr.extwrite.id_dec
stderr.extwrite.id_hex, stderr.extwrite.id_hex
stderr.extwrite.idec, stderr.extwrite.idec
stderr.extwrite.ihex, stderr.extwrite.ihex
stderr.extwrite.iq_dec, stderr.extwrite.iq_dec
stderr.extwrite.iq_hex, stderr.extwrite.iq_hex
stderr.extwrite.iw_dec, stderr.extwrite.iw_dec
stderr.extwrite.iw_hex, stderr.extwrite.iw_hex
stderr.extwrite.q_dec, stderr.extwrite.q_dec
stderr.extwrite.q_hex, stderr.extwrite.q_hex
stderr.extwrite.w_dec, stderr.extwrite.w_dec
stderr.extwrite.w_hex, stderr.extwrite.w_hex
stderr.write, stderr.write
stderr.write.b_dec, stderr.write.b_dec
stderr.write.b_hex, stderr.write.b_hex
stderr.write.char, stderr.write.char
stderr.write.d_dec, stderr.write.d_dec
stderr.write.d_hex, stderr.write.d_hex
stderr.write.dec, stderr.write.dec
stderr.write.format, stderr.write.format
stderr.write.hex, stderr.write.hex
stderr.write.ib_dec, stderr.write.ib_dec
stderr.write.ib_hex, stderr.write.ib_hex
stderr.write.id_dec, stderr.write.id_dec
stderr.write.id_hex, stderr.write.id_hex
stderr.write.idec, stderr.write.idec
stderr.write.ihex, stderr.write.ihex
stderr.write.iq_dec, stderr.write.iq_dec
stderr.write.iq_hex, stderr.write.iq_hex
stderr.write.iw_dec, stderr.write.iw_dec
stderr.write.iw_hex, stderr.write.iw_hex
stderr.write.q_dec, stderr.write.q_dec
stderr.write.q_hex, stderr.write.q_hex
stderr.write.str, stderr.write.str
stderr.write.w_dec, stderr.write.w_dec
stderr.write.w_hex, stderr.write.w_hex
stdin.extread.chars, stdin.extread.chars
stdin.extread.dec, stdin.extread.dec
stdin.extread.dec_b, stdin.extread.dec_b
stdin.extread.dec_d, stdin.extread.dec_d
stdin.extread.dec_ib, stdin.extread.dec_ib
stdin.extread.dec_id, stdin.extread.dec_id
stdin.extread.dec_iq, stdin.extread.dec_iq
stdin.extread.dec_iw, stdin.extread.dec_iw
stdin.extread.dec_q, stdin.extread.dec_q
stdin.extread.dec_w, stdin.extread.dec_w
stdin.extread.hex, stdin.extread.hex
stdin.extread.hex_b, stdin.extread.hex_b
stdin.extread.hex_d, stdin.extread.hex_d
stdin.extread.hex_ib, stdin.extread.hex_ib
stdin.extread.hex_id, stdin.extread.hex_id
stdin.extread.hex_iq, stdin.extread.hex_iq
stdin.extread.hex_iw, stdin.extread.hex_iw
stdin.extread.hex_q, stdin.extread.hex_q
stdin.extread.hex_w, stdin.extread.hex_w
stdin.extread.idec, stdin.extread.idec
stdin.extread.ihex, stdin.extread.ihex
stdin.extread.line, stdin.extread.line
stdin.extread.until, stdin.extread.until
stdin.extskip.chars, stdin.extskip.chars
stdin.extskip.until, stdin.extskip.until
stdin.fetch, stdin.fetch
stdin.fetch.char, stdin.fetch.char
stdin.fetch.str, stdin.fetch.str
stdin.read.char, stdin.read.char
stdin.read.chars, stdin.read.chars
stdin.read.dec, stdin.read.dec
stdin.read.dec_b, stdin.read.dec_b
stdin.read.dec_d, stdin.read.dec_d
stdin.read.dec_ib, stdin.read.dec_ib
stdin.read.dec_id, stdin.read.dec_id
stdin.read.dec_iq, stdin.read.dec_iq
stdin.read.dec_iw, stdin.read.dec_iw
stdin.read.dec_q, stdin.read.dec_q
stdin.read.dec_w, stdin.read.dec_w
stdin.read.hex, stdin.read.hex
stdin.read.hex_b, stdin.read.hex_b
stdin.read.hex_d, stdin.read.hex_d
stdin.read.hex_ib, stdin.read.hex_ib
stdin.read.hex_id, stdin.read.hex_id
stdin.read.hex_iq, stdin.read.hex_iq
stdin.read.hex_iw, stdin.read.hex_iw
stdin.read.hex_q, stdin.read.hex_q
stdin.read.hex_w, stdin.read.hex_w
stdin.read.idec, stdin.read.idec
stdin.read.ihex, stdin.read.ihex
stdin.read.line, stdin.read.line
stdin.read.until, stdin.read.until
stdin.skip.chars, stdin.skip.chars
stdin.skip.until, stdin.skip.until
stdout.extwrite.b_dec, stdout.extwrite.b_dec
stdout.extwrite.b_hex, stdout.extwrite.b_hex
stdout.extwrite.d_dec, stdout.extwrite.d_dec
stdout.extwrite.d_hex, stdout.extwrite.d_hex
stdout.extwrite.dec, stdout.extwrite.dec
stdout.extwrite.hex, stdout.extwrite.hex
stdout.extwrite.ib_dec, stdout.extwrite.ib_dec
stdout.extwrite.ib_hex, stdout.extwrite.ib_hex
stdout.extwrite.id_dec, stdout.extwrite.id_dec
stdout.extwrite.id_hex, stdout.extwrite.id_hex
stdout.extwrite.idec, stdout.extwrite.idec
stdout.extwrite.ihex, stdout.extwrite.ihex
stdout.extwrite.iq_dec, stdout.extwrite.iq_dec
stdout.extwrite.iq_hex, stdout.extwrite.iq_hex
stdout.extwrite.iw_dec, stdout.extwrite.iw_dec
stdout.extwrite.iw_hex, stdout.extwrite.iw_hex
stdout.extwrite.q_dec, stdout.extwrite.q_dec
stdout.extwrite.q_hex, stdout.extwrite.q_hex
stdout.extwrite.w_dec, stdout.extwrite.w_dec
stdout.extwrite.w_hex, stdout.extwrite.w_hex
stdout.write, stdout.write
stdout.write.b_dec, stdout.write.b_dec
stdout.write.b_hex, stdout.write.b_hex
stdout.write.char, stdout.write.char
stdout.write.d_dec, stdout.write.d_dec
stdout.write.d_hex, stdout.write.d_hex
stdout.write.dec, stdout.write.dec
stdout.write.format, stdout.write.format
stdout.write.hex, stdout.write.hex
stdout.write.ib_dec, stdout.write.ib_dec
stdout.write.ib_hex, stdout.write.ib_hex
stdout.write.id_dec, stdout.write.id_dec
stdout.write.id_hex, stdout.write.id_hex
stdout.write.idec, stdout.write.idec
stdout.write.ihex, stdout.write.ihex
stdout.write.iq_dec, stdout.write.iq_dec
stdout.write.iq_hex, stdout.write.iq_hex
stdout.write.iw_dec, stdout.write.iw_dec
stdout.write.iw_hex, stdout.write.iw_hex
stdout.write.q_dec, stdout.write.q_dec
stdout.write.q_hex, stdout.write.q_hex
stdout.write.str, stdout.write.str
stdout.write.w_dec, stdout.write.w_dec
stdout.write.w_hex, stdout.write.w_hex
stdstream.init, stdstream.init
stdstream.uninit, stdstream.uninit
stop macros, Compilation stopping macros
str.cat, str.cat
str.catchar, str.catchar
str.cmp, str.cmp
str.cmpi, str.cmpi
str.copy, str.copy
str.ins, str.ins
str.inschar, str.inschar
str.len, str.len
str.lowcase, str.lowcase
str.pos, str.pos
str.poschar, str.poschar
str.sub, str.sub
str.upcase, str.upcase
stream close method, stream close method
stream peek method, stream peek method
stream read method, stream read method
stream seek method, stream seek method
stream skip method, stream skip method
stream tell method, stream tell method
stream.close, stream.close
stream.create, stream.create
stream.peek, stream.peek
stream.peek.byte, stream.peek.byte
stream.read, stream.read
stream.read.byte, stream.read.byte
stream.seek, stream.seek
stream.skip, stream.skip
stream.tell, stream.tell
stream.write, stream write method, stream.write
stream.write.byte, stream.write.byte
stream.write.dword, stream.write.dword
stream.write.word, stream.write.word
Streams, Streams
String Library, String Library

T

Text Processing, Text Processing
text.extread.chars, text.extread.chars
text.extread.dec, text.extread.dec
text.extread.dec_b, text.extread.dec_b
text.extread.dec_d, text.extread.dec_d
text.extread.dec_ib, text.extread.dec_ib
text.extread.dec_id, text.extread.dec_id
text.extread.dec_iq, text.extread.dec_iq
text.extread.dec_iw, text.extread.dec_iw
text.extread.dec_q, text.extread.dec_q
text.extread.dec_w, text.extread.dec_w
text.extread.hex, text.extread.hex
text.extread.hex_b, text.extread.hex_b
text.extread.hex_d, text.extread.hex_d
text.extread.hex_ib, text.extread.hex_ib
text.extread.hex_id, text.extread.hex_id
text.extread.hex_iq, text.extread.hex_iq
text.extread.hex_iw, text.extread.hex_iw
text.extread.hex_q, text.extread.hex_q
text.extread.hex_w, text.extread.hex_w
text.extread.idec, text.extread.idec
text.extread.ihex, text.extread.ihex
text.extread.line, text.extread.line
text.extread.until, text.extread.until
text.extskip.chars, text.extskip.chars
text.extskip.until, text.extskip.until
text.extwrite.b_dec, text.extwrite.b_dec
text.extwrite.b_hex, text.extwrite.b_hex
text.extwrite.d_dec, text.extwrite.d_dec
text.extwrite.d_hex, text.extwrite.d_hex
text.extwrite.dec, text.extwrite.dec
text.extwrite.hex, text.extwrite.hex
text.extwrite.ib_dec, text.extwrite.ib_dec
text.extwrite.ib_hex, text.extwrite.ib_hex
text.extwrite.id_dec, text.extwrite.id_dec
text.extwrite.id_hex, text.extwrite.id_hex
text.extwrite.idec, text.extwrite.idec
text.extwrite.ihex, text.extwrite.ihex
text.extwrite.iq_dec, text.extwrite.iq_dec
text.extwrite.iq_hex, text.extwrite.iq_hex
text.extwrite.iw_dec, text.extwrite.iw_dec
text.extwrite.iw_hex, text.extwrite.iw_hex
text.extwrite.q_dec, text.extwrite.q_dec
text.extwrite.q_hex, text.extwrite.q_hex
text.extwrite.w_dec, text.extwrite.w_dec
text.extwrite.w_hex, text.extwrite.w_hex
text.fetch, text.fetch
text.fetch.char, text.fetch.char
text.fetch.str, text.fetch.str
text.read.char, text.read.char
text.read.chars, text.read.chars
text.read.dec, text.read.dec
text.read.dec_b, text.read.dec_b
text.read.dec_d, text.read.dec_d
text.read.dec_ib, text.read.dec_ib
text.read.dec_id, text.read.dec_id
text.read.dec_iq, text.read.dec_iq
text.read.dec_iw, text.read.dec_iw
text.read.dec_q, text.read.dec_q
text.read.dec_w, text.read.dec_w
text.read.hex, text.read.hex
text.read.hex_b, text.read.hex_b
text.read.hex_d, text.read.hex_d
text.read.hex_ib, text.read.hex_ib
text.read.hex_id, text.read.hex_id
text.read.hex_iq, text.read.hex_iq
text.read.hex_iw, text.read.hex_iw
text.read.hex_q, text.read.hex_q
text.read.hex_w, text.read.hex_w
text.read.idec, text.read.idec
text.read.ihex, text.read.ihex
text.read.line, text.read.line
text.read.until, text.read.until
text.skip.chars, text.skip.chars
text.skip.until, text.skip.until
text.write, text.write
text.write.b_dec, text.write.b_dec
text.write.b_hex, text.write.b_hex
text.write.char, text.write.char
text.write.d_dec, text.write.d_dec
text.write.d_hex, text.write.d_hex
text.write.dec, text.write.dec
text.write.format, text.write.format
text.write.hex, text.write.hex
text.write.ib_dec, text.write.ib_dec
text.write.ib_hex, text.write.ib_hex
text.write.id_dec, text.write.id_dec
text.write.id_hex, text.write.id_hex
text.write.idec, text.write.idec
text.write.ihex, text.write.ihex
text.write.iq_dec, text.write.iq_dec
text.write.iq_hex, text.write.iq_hex
text.write.iw_dec, text.write.iw_dec
text.write.iw_hex, text.write.iw_hex
text.write.q_dec, text.write.q_dec
text.write.q_hex, text.write.q_hex
text.write.str, text.write.str
text.write.w_dec, text.write.w_dec
text.write.w_hex, text.write.w_hex
timedate, Time/Date macros

U

udata, Data Macros
Usage, Usage