TITLE "example.a: Demo of SMAL data structures" ; ASCII Control Characters NUL = 0 ; Null (end of string) ; The Null pointer NULL = 0 SUBTITLE "Strings" ; Demonstrates end of line using NUL terminator ASCII "Hello world!",NUL ; Strings as self-describing arrays H 12 ASCII "Hello world!" ; Strings as self-describing arrays with help from assembler H theend - thestart thestart: ASCII "Hello world!" theend: SUBTITLE "Binary Trees" ; a constant tree (lexicographic order) ROOT: W NODEA ; pointer to the root NODEA: W NODEB ; left pointer W NODEC ; right pointer W 2 ; value NODEB: W NULL W NULL W 1 NODEC: W NULL W NODED W 3 NODED: W NULL W NULL W 4 SUBTITLE "Arrays" ; tictactoe is a 2 dimensional array, 3 by 3 of words ; really, an array of 3 rows ; where a row is an array of 3 words (12 bytes) ; where a word is an array of 4 bytes TICTACTOE: W 0 ; tictactoe[0][0] = tictactoe[0,0] W 0 ; tictactoe[0][1] W 0 ; tictactoe[0][2] W 0 ; tictactoe[1][0] = tictactoe[0,1] W 0 W 0 W 0 ; the address of tictactoe[i,j] is W 0 ; TICTACTOE + i*12 + j*4 W 0 END