Files
FASM4Delphi/FasmDll/SOURCE/DLL/FASM.ASH
2018-02-11 23:55:18 +03:00

105 lines
3.8 KiB
Plaintext

; The following structure resides at the beginning of memory block provided
; to the fasm_Assemble function. The condition field contains the same value
; as the one returned by function.
; When function returns FASM_OK condition, the output_length and
; output_data fields are filled - with pointer to generated output
; (somewhere within the provided memory block) and the count of bytes stored
; there.
; When function returns FASM_ERROR, the error_code is filled with the
; code of specific error that happened and error_line is a pointer to the
; LINE_HEADER structure, providing information about the line that caused
; the error.
struct FASM_STATE
condition dd ?
union
output_length dd ?
error_code dd ?
ends
union
output_data dd ?
error_line dd ?
ends
ends
; The following structure has two variants - it either defines the line
; that was loaded directly from source, or the line that was generated by
; macroinstruction. First case has the highest bit of line_number set to 0,
; while the second case has this bit set.
; In the first case, the file_path field contains pointer to the path of
; source file (empty string if it's the source that was provided directly to
; fasm_Assemble function), the line_number is the number of line within
; that file (starting from 1) and the file_offset field contains the offset
; within the file where the line starts.
; In the second case the macro_calling_line field contains the pointer to
; LINE_HEADER structure for the line which called the macroinstruction, and
; the macro_line field contains the pointer to LINE_HEADER structure for the
; line within the definition of macroinstruction, which generated this one.
struct LINE_HEADER
file_path dd ?
line_number dd ?
union
file_offset dd ?
macro_calling_line dd ?
ends
macro_line dd ?
ends
; General errors and conditions
FASM_OK = 0 ; FASM_STATE points to output
FASM_WORKING = 1
FASM_ERROR = 2 ; FASM_STATE contains error code
FASM_INVALID_PARAMETER = -1
FASM_OUT_OF_MEMORY = -2
FASM_STACK_OVERFLOW = -3
FASM_SOURCE_NOT_FOUND = -4
FASM_UNEXPECTED_END_OF_SOURCE = -5
FASM_CANNOT_GENERATE_CODE = -6
FASM_FORMAT_LIMITATIONS_EXCEDDED = -7
FASM_WRITE_FAILED = -8
FASM_INVALID_DEFINITION = -9
; Error codes for FASM_ERROR condition
FASMERR_FILE_NOT_FOUND = -101
FASMERR_ERROR_READING_FILE = -102
FASMERR_INVALID_FILE_FORMAT = -103
FASMERR_INVALID_MACRO_ARGUMENTS = -104
FASMERR_INCOMPLETE_MACRO = -105
FASMERR_UNEXPECTED_CHARACTERS = -106
FASMERR_INVALID_ARGUMENT = -107
FASMERR_ILLEGAL_INSTRUCTION = -108
FASMERR_INVALID_OPERAND = -109
FASMERR_INVALID_OPERAND_SIZE = -110
FASMERR_OPERAND_SIZE_NOT_SPECIFIED = -111
FASMERR_OPERAND_SIZES_DO_NOT_MATCH = -112
FASMERR_INVALID_ADDRESS_SIZE = -113
FASMERR_ADDRESS_SIZES_DO_NOT_AGREE = -114
FASMERR_DISALLOWED_COMBINATION_OF_REGISTERS = -115
FASMERR_LONG_IMMEDIATE_NOT_ENCODABLE = -116
FASMERR_RELATIVE_JUMP_OUT_OF_RANGE = -117
FASMERR_INVALID_EXPRESSION = -118
FASMERR_INVALID_ADDRESS = -119
FASMERR_INVALID_VALUE = -120
FASMERR_VALUE_OUT_OF_RANGE = -121
FASMERR_UNDEFINED_SYMBOL = -122
FASMERR_INVALID_USE_OF_SYMBOL = -123
FASMERR_NAME_TOO_LONG = -124
FASMERR_INVALID_NAME = -125
FASMERR_RESERVED_WORD_USED_AS_SYMBOL = -126
FASMERR_SYMBOL_ALREADY_DEFINED = -127
FASMERR_MISSING_END_QUOTE = -128
FASMERR_MISSING_END_DIRECTIVE = -129
FASMERR_UNEXPECTED_INSTRUCTION = -130
FASMERR_EXTRA_CHARACTERS_ON_LINE = -131
FASMERR_SECTION_NOT_ALIGNED_ENOUGH = -132
FASMERR_SETTING_ALREADY_SPECIFIED = -133
FASMERR_DATA_ALREADY_DEFINED = -134
FASMERR_TOO_MANY_REPEATS = -135
FASMERR_SYMBOL_OUT_OF_SCOPE = -136
FASMERR_USER_ERROR = -140
FASMERR_ASSERTION_FAILED = -141