Files

41 lines
1.8 KiB
Plaintext
Raw Permalink Normal View History

2022-09-02 19:57:59 +03:00
; a proposed assembly syntax for NRJ machines (example for NRJ16)
; semicolons are comments
; preprocessor instructions start with dot (.)
; every non-preprocessor instruction creates an entry in the lookup table
; all addressing is in words
; we usually start at the word 3 (don't pre-fill the I/O buffers)
.bit 16 ; word/address size: NRJ16 is the default setting
.org 3 ; .org defines the start of further code/data (in words, hex)
; include the standard library
.inc stdlib.nrjasm
.var x 2EF ; .var defines a label for a particular memory location
.var y 2F0 ; define another variable at 0x2F0
.set @x 'm ; .set sets a memory location to a particular hex constant at the build time, @ dereferences a label into the address
2022-09-02 19:57:59 +03:00
.set @y 'M ; ' dereferences a character into a whole word with its ASCII code
; we CANNOT use dereferencing operators with .var, only with .set or directly
; there also can be .inc instruction to include a snippet from another file in the same directory
; now, main elementary macros:
; NXT - address of the next instruction position in the lookup table
; HLT - the last address position in the lookup table (0xFFFF for NRJ16), set by .bits
; FREE - address of the next available (at build time) memory cell, can only be used in .var
; for the lookup table and CUR/NXT macros to work correctly, the code must start at an address divisible by 3
; note that FREE doesn't intelligently detect the available cells, it only takes the next one after the maximum address used
; so in our case, the first FREE instance will be substituted with 2F1, the next with 2F2 and so on
2022-09-02 19:57:59 +03:00
; now, lets output a character by transferring the y value to the output cell 1
; in an endless loop
.lbl myloop
MOV 1 @x
2022-09-02 19:57:59 +03:00
MOV 1 @y @myloop ; output the character and jump to the beginning
; we don't have to explicitly zero out the cell 1 as it is done by the I/O logic