Browse code

Splitted asma into library and piano demo.

Andrew Alderwick authored on 07/10/2021 20:08:18
Showing 2 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,101 @@
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    [ &pad    $8 &write    $1 ]
5
+|a0 @File       [ &vector $2 &success  $2 &offset-hs $2 &offset-ls $2 &name $2 &length $2 &load $2 &save $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
+	(
20
+		Assemble the source code into an output ROM file.
21
+
22
+		If all you want is to use asma.tal to assemble files, insert a BRK
23
+		after this statement.
24
+	)
25
+	;&source-file ;&dest-file ;asma-assemble-file JSR2
26
+
27
+	(
28
+		If an error has occurred, BRK here, otherwise continue. (The error
29
+		message will already have been printed to the Console in
30
+		asma-assemble-file.)
31
+	)
32
+	;asma/error LDA2 #0000 EQU2 JMP BRK
33
+
34
+	(
35
+		Load the output ROM over the currently running program, almost as if
36
+		we loaded the ROM with uxnemu directly!
37
+
38
+		It's not a totally pristine environment, as File/load doesn't zero out
39
+		memory beyond the end of the file. So if the assembled program assumes
40
+		that all memory above it is zero, it may misbehave.
41
+
42
+		Asma itself doesn't use the zero page, but this example code writes a
43
+		DEO2 instruction to 0x00ff. In order to execute File/load and have the
44
+		CPU continue at memory location 0x0100, we write the final DEO2
45
+		instruction there and jump there as our final act.
46
+
47
+		Just in case the assembled code is zero-length (which can occur when
48
+		assembling an empty source file), we write a BRK to the reset vector so
49
+		that will prevent an infinite loop.
50
+	)
51
+	;&dest-file .File/name DEO2
52
+	#0000 .File/offset-ls DEO2
53
+	#ff00 .File/length DEO2
54
+	#0100 .File/load
55
+	LIT DEO2 #00ff STA
56
+	LIT BRK #0100 STA
57
+	#00ff JMP2
58
+
59
+	&source-file
60
+		"projects/examples/demos/piano.tal 00
61
+	&dest-file
62
+		"bin/asma-boot.rom 00
63
+
64
+include projects/library/asma.tal
65
+
66
+(
67
+	Heap, a large temporary area for keeping track of labels. More complex
68
+	programs need more of this space. If there's insufficient space then the
69
+	assembly process will fail, but having extra space above what the most
70
+	complex program needs provides no benefit.
71
+
72
+	This heap, and the buffers below, are free to be used to hold temporary
73
+	data between assembly runs, and do not need to be initialized with any
74
+	particular contents to use the assembler.
75
+)
76
+
77
+@asma-heap
78
+
79
+|e000 &end
80
+
81
+(
82
+	Buffer for use with loading source code.
83
+	The minimum size is the length of the longest token plus one, which is
84
+	0x21 to keep the same capability of the C assembler.
85
+	Larger sizes are more efficient, provided there is enough
86
+	heap space to keep track of all the labels.
87
+)
88
+
89
+@asma-read-buffer
90
+
91
+|f800 &end
92
+
93
+(
94
+	Buffer for use with writing output.
95
+	The minimum size is 1, and larger sizes are more efficient.
96
+)
97
+
98
+@asma-write-buffer
99
+
100
+|ffff &end
101
+
0 102
similarity index 88%
1 103
rename from projects/software/asma.tal
2 104
rename to projects/library/asma.tal
... ...
@@ -1,11 +1,3 @@
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    [ &pad    $8 &write    $1 ]
5
-|a0 @File       [ &vector $2 &success  $2 &offset-hs $2 &offset-ls $2 &name $2 &length $2 &load $2 &save $2 ]
6
-
7
-( vectors )
8
-
9 1
 (
10 2
 	Asma - an in-Uxn assembler
11 3
 
... ...
@@ -19,61 +11,6 @@
19 11
 	examples of asma's usage and can be discarded.
20 12
 )
21 13
 
22
-|0100 @reset
23
-	(
24
-		Set the log level for helping to debug stuff.
25
-		Its value is the bitwise OR of all the following output types:
26
-			#01 prints the number of lines in the source code,
27
-			#04 dumps all defined labels at end, and
28
-			#08 prints the heap usage.
29
-	)
30
-	#09 ;asma/log-level STA
31
-
32
-	(
33
-		Assemble the source code into an output ROM file.
34
-
35
-		If all you want is to use asma.tal to assemble files, insert a BRK
36
-		after this statement.
37
-	)
38
-	;&source-file ;&dest-file ;asma-assemble-file JSR2
39
-
40
-	(
41
-		If an error has occurred, BRK here, otherwise continue. (The error
42
-		message will already have been printed to the Console in
43
-		asma-assemble-file.)
44
-	)
45
-	;asma/error LDA2 #0000 EQU2 JMP BRK
46
-
47
-	(
48
-		Load the output ROM over the currently running program, almost as if
49
-		we loaded the ROM with uxnemu directly!
50
-
51
-		It's not a totally pristine environment, as File/load doesn't zero out
52
-		memory beyond the end of the file. So if the assembled program assumes
53
-		that all memory above it is zero, it may misbehave.
54
-
55
-		Asma itself doesn't use the zero page, but this example code writes a
56
-		DEO2 instruction to 0x00ff. In order to execute File/load and have the
57
-		CPU continue at memory location 0x0100, we write the final DEO2
58
-		instruction there and jump there as our final act.
59
-
60
-		Just in case the assembled code is zero-length (which can occur when
61
-		assembling an empty source file), we write a BRK to the reset vector so
62
-		that will prevent an infinite loop.
63
-	)
64
-	;&dest-file .File/name DEO2
65
-	#0000 .File/offset-ls DEO2
66
-	#ff00 .File/length DEO2
67
-	#0100 .File/load
68
-	LIT DEO2 #00ff STA
69
-	LIT BRK #0100 STA
70
-	#00ff JMP2
71
-
72
-	&source-file
73
-		"projects/examples/demos/piano.tal 00
74
-	&dest-file
75
-		"bin/asma-boot.rom 00
76
-
77 14
 (
78 15
 	Common macros for use later on.
79 16
 )
... ...
@@ -919,39 +856,3 @@ include projects/library/heap.tal
919 856
 	&EOR        :&DUP      :&EQU        "EOR 00
920 857
 	&SFT         $2         $2          "SFT 00
921 858
 
922
-(
923
-	Heap, a large temporary area for keeping track of labels. More complex
924
-	programs need more of this space. If there's insufficient space then the
925
-	assembly process will fail, but having extra space above what the most
926
-	complex program needs provides no benefit.
927
-
928
-	This heap, and the buffers below, are free to be used to hold temporary
929
-	data between assembly runs, and do not need to be initialized with any
930
-	particular contents to use the assembler.
931
-)
932
-
933
-@asma-heap
934
-
935
-|e000 &end
936
-
937
-(
938
-	Buffer for use with loading source code.
939
-	The minimum size is the length of the longest token plus one, which is
940
-	0x21 to keep the same capability of the C assembler.
941
-	Larger sizes are more efficient, provided there is enough
942
-	heap space to keep track of all the labels.
943
-)
944
-
945
-@asma-read-buffer
946
-
947
-|f800 &end
948
-
949
-(
950
-	Buffer for use with writing output.
951
-	The minimum size is 1, and larger sizes are more efficient.
952
-)
953
-
954
-@asma-write-buffer
955
-
956
-|ffff &end
957
-