asma-piano.tal (2968B)
1 ( devices ) 2 3 |00 @System [ &vector $2 &wst $1 &rst $1 &pad $4 &r $2 &g $2 &b $2 &debug $1 &halt $1 ] 4 |10 @Console [ &vector $2 &read $1 &pad $5 &write $1 &error $1 ] 5 |a0 @File [ &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2 ] 6 7 ( vectors ) 8 9 |0100 @reset 10 ( 11 Set the log level for helping to debug stuff. 12 Its value is the bitwise OR of all the following output types: 13 #01 prints the number of lines in the source code, 14 #04 dumps all defined labels at end, and 15 #08 prints the heap usage. 16 ) 17 #0d ;asma/log-level STA 18 19 ;asma-heap ;heap STA2 20 21 ( 22 Assemble the source code into an output ROM file. 23 24 If all you want is to use asma.tal to assemble files, insert a BRK 25 after this statement. 26 ) 27 ;&source-file ;&dest-file ;asma-assemble-file JSR2 28 29 ( 30 If an error has occurred, BRK here, otherwise continue. (The error 31 message will already have been printed to the Console in 32 asma-assemble-file.) 33 ) 34 ;asma/error LDA2 #0000 EQU2 JMP BRK 35 36 ( 37 Load the output ROM over the currently running program, almost as if 38 we loaded the ROM with uxnemu directly! 39 40 It's not a totally pristine environment, as File/read doesn't zero out 41 memory beyond the end of the file. So if the assembled program assumes 42 that all memory above it is zero, it may misbehave. 43 44 Asma itself doesn't use the zero page, but this example code writes a 45 DEO2 instruction to 0x00ff. In order to execute File/read and have the 46 CPU continue at memory location 0x0100, we write the final DEO2 47 instruction there and jump there as our final act. 48 49 Just in case the assembled code is zero-length (which can occur when 50 assembling an empty source file), we write a BRK to the reset vector so 51 that will prevent an infinite loop. 52 ) 53 ;&dest-file .File/name DEO2 54 #ff00 .File/length DEO2 55 #0100 .File/read 56 LIT DEO2 #00ff STA 57 LIT BRK #0100 STA 58 #00ff JMP2 59 60 &source-file 61 "projects/examples/demos/piano.tal 00 62 &dest-file 63 "bin/asma-boot.rom 00 64 65 ~projects/library/asma.tal 66 67 ( 68 Heap, a large temporary area for keeping track of labels. More complex 69 programs need more of this space. If there's insufficient space then the 70 assembly process will fail, but having extra space above what the most 71 complex program needs provides no benefit. 72 73 This heap, and the buffers below, are free to be used to hold temporary 74 data between assembly runs, and do not need to be initialized with any 75 particular contents to use the assembler. 76 ) 77 78 @asma-heap 79 80 |e000 &end 81 82 ( 83 Buffer for use with loading source code. 84 The minimum size is the length of the longest token plus one, which is 85 0x21 to keep the same capability of the C assembler. 86 Larger sizes are more efficient, provided there is enough 87 heap space to keep track of all the labels. 88 ) 89 90 @asma-read-buffer 91 92 |f800 &end 93 94 ( 95 Buffer for use with writing output. 96 The minimum size is 1, and larger sizes are more efficient. 97 ) 98 99 @asma-write-buffer 100 101 |ffff &end 102