Casm 0.991 alpha

New version of Casm available here.


Casm 0.99 alpha

Assembler with built-in linker for programming graphic calculators cfx9850G, cfx9800G and compatible.

Today (22/10/2K0) I just finished first true assembler for cfx9850, which supports symbolic names for labels, variables, instructions entered by names and other features, which support most of other assemblers. This page should give you some information about Casm usage.

Usage: <input.asm> <output.bin>

example: c:\casm.exe doom.asm doom.bin

Because the files stored backwards in the calculator, you must after using casm convert the output file using my another tool (for example otoc doom.bin doom.cas) and this result you can send in your calculator. Use communication tool, which supports plain cas files (details). Of course you don't need to convert output file, if you are programming a part of ROM.


Casm directives

; - all, what is between ";" and eoln, is comment

example: ADD,8 R00,R10 ; add two 64 bit registers, result store to the first one (R00)

ALIGN <16 bit value> - specifies the address of the last byte (programs written for cfx9850G to be stored in RAM should contain ALIGN 7FFE). This command must be used only once and it cannot be used, if ORG was used.

ORG <16 bit value> - specifies the address of the first byte ( it should be used for programming ROMs). This command must be used only once and it cannot be used, if ALIGN was used.

INCLUDE "<filename>" - includes file filename to be compiled. Included files can also contain this directive.

DEFINE <macroname> <macrovalue> - defines macro macroname with value macrovalue, the value is taken from the first nonwhite character after macroname to the end of line. Macros containing more lines are not supported now.

RADIX <radixvalue> - defines new default radix, only radix 10 and 16 are supported, radix 16 is default; it is possible to temporary switch radix 10 to 16 appending the "H"character to the number. Radix 16 cannot be temporary switched, because the appended "D" character can be parsed as a valid hex digit.

DB <data> <data>... - declares 8-bit data

example:  Manas79: DB "Manas" 79

DB "Toto je Alois Manas, bratra me babicky zed v podnajmu ;-))))"

DB 00 01 02 03 04 FE

DW <16-bit data> - declares 1 16-bit variable, can be used to define table for jumping

example:  Var1 : DW 0AD04  ; the first zero says, that it is a number , not a label name

Skiptable: DW func1

DW func2

DW errhandler

DW crashhandler

...

DU <length> - declares <length> bytes long buffer of uninitialised data, buffer is filled by random values !

example: makeprogramlookbig: DU 4096   ;see source code of win 98 for details :-))


Registers

The CPU has probably array of 128 8-bit registers, you can group any 2,8 or 10 neighbor registers to make 16,64 or 80 bit register. So as a register name are valid values R00~R7F or R00~R127 (in the Radix 10 case)


Addressing modes

OP = operation (ADD,BADD,SUB,BSUB,AND,OR,XOR,TEST,CMP,MOV)

S = size of operands (B-byte,W-word,8-8 bytes,10-10 bytes)

OP,S R1,R2   ; register R1 OP register R2 -> register R1 (R2->R1 in the mov case, no result storage in the case of CMP or TEST)

OP,S R1,[R2] ; register R1 OP memory at the address stored in register R2 -> R1

OP,S R1,V1  ; register R1 OP direct byte value V1 -> R1, mov supports also word value

OP,S [R1],R2 ; memory at the address stored in register R1 OP register R2 -> memory at the address stored in R1

OP,S [R1],V1 ; memory at the address stored in register R1 OP direct byte value V1 -> memory at the address stored in R1


Jumps, calls and returns

Casm supports all jumps, calls and returns as written in instruction table, but there is only one jump if zero, one call if zero and one return if zero.

Casm automatically converts labels / direct values to the correct endian

mov,w R42,1234  ;compiled as C1 42 34 12

jmp 1234 ;compiled as 88 12 34


Known limitations

Please write me about every bug you find, it's terrible to debug program compiled by buggy compiler. I will be also happy, if you write me about your successful projects.