|
s502 assembler
A very simple assembler for the 6502 line of processors written in C
|
This program can handle many errors:
The handled errors do not cause the program to crash, instead, it prints where it encountered the problem, tells details and then de-allocates all used resources before quitting.
Error signaling is based on return values, usually negative return values indicating error. Most functions also print FAIL messages when one of their sub-tasks quitted with an error, thus giving us a partial traceback.
Bellow is a list of all possible errors, and one (or many) ways to reproduce them.
This list can be used to check if no error ever leaks memory or crashes the program. (which I did by hand)
Please note that the described ways are only examples on how to trigger these errors, and might NOT cover all cases for all errors, but all currently reproducible errors have at least one example.
Reproduce:
.define.define A.define A B C(any number of arguments other than 2)
Reproduce:
.define A &nondefReproduce:
.define veeeeery_loooooong_coooonstant_naaame 5(actual max value is set in map.h)
Reproduce:
.ifbeq.ifbeq A.ifbeq A B C(any number of arguments other than 2)
Reproduce:
.ifbeq &A &BTriggers on any undefined label
Reproduce:
.printReproduce:
.printc.printc A B(any number of arguments other than 1)
Reproduce:
.include.include A B(any number of arguments other than 1)
Reproduce:
.ifdef.ifndef.ifdef A B.ifndef A B(any number of arguments other than 2)
Reproduce:
.org.org A B(any number of arguments other than 1)
Reproduce:
.org &nondefinedReproduce:
.pad.pad A B C(any number of arguments other than 1 or 2)
Reproduce:
.pad ABC Triggers on any non-defined labels/constants or on number parsing errors Reproduce:
.org $500 .pad $400Reproduce:
.whatisthisReproduce:
.data w:&nondefinded.data &nondefined(same message for both words and bytes, but with two different ERROR lines)
Also triggers "Invalid byte/word in .data" message
Reproduce:
.data $errorMight also trigger "Can not interpret number" or "Label is not defined"
Reproduce:
.data "abcReproduce:
.data $5 256.data $5 $errorMight also trigger "Can not interpret number" or "Label is not defined"
Reproduce:
.pad $100.pad $errorTriggers if pad byte is >255 or does not have a value (undefined label/constant, number parsing error)
Might also trigger ""Can not interpret number
Reproduce:
Reproduce:
No known ways to reproduce any memory allocation errors
Reproduce:
some terribly (and also unnecessarily) long line that should never exist in an assembly source file, not even in .data directives bc it's unreadablePlease note that comments and whitespaces does NOT count here
Reproduce:
.data THIS_IS_NOT_A_NUMBERCan trigger anywhere where a number was expected but could not be parsed.
Might also have other error messages.
Reproduce:
.endifReproduce:
this_label_is_so_long_it_will_genererate_an_error:Limit is set in map.h
Reproduce:
my_label: my_label:Reproduce:
lda &undef_labelCan only happen in instructions
Reproduce:
asm.exe -lasm.exe -dasm.exe -d Aasm.exe -oReproduce:
asm.exe -o very/long/file/path/that/wont/fit/in/my/small/bufferMaximum can be set in state.h
Reproduce:
asm.exe -o -argument2Reproduce:
asm.exe -l ABCDReproduce:
asm.exe -d A ABCDReproduce:
asm.exe -d very_long_constant_name_that_will_cause_an_error 2Reproduce:
asm.exe very_very_VERY_long_input_file_name_or_pathMaximum can be set in state.h
Reproduce:
asm.exe -not_an_input_fileReproduce:
asm.exeReproduce:
wtf #$5Reproduce:
lda *#(5),ZReproduce:
lda ($1234)Reproduce:
la:.ab.label:No known ways to reproduce
Reproduce:
.org 0 beq $8000Max relative jump distance is 8 bit signed ((-128)-127)