Browse code

(fizzbuzz.tal) Formatting

Devine Lu Linvega authored on 21/07/2023 18:35:56
Showing 1 changed files
... ...
@@ -1,40 +1,36 @@
1
-( FizzBuzz:
2
-	A program that prints the integers from 1 to 100.
3
-	for multiples of three, print "Fizz"
4
-	for multiples of five, print "Buzz"
5
-	for multiples of both three and five, print "FizzBuzz" )
1
+( FizzBuzz: From 1 to 100, for multiples of 3 print "Fizz", of 5 "Buzz" and for both "FizzBuzz" )
6 2
 
7
-|0100 ( -> )
3
+|0100
4
+
5
+@on-reset ( -> )
8 6
 	#6400
9
-	&loop
10
-		( integer )
11
-		DUPk print-dec #2018 DEO
12
-		( fizzbuzz )
13
-		DUP #03 mod ?&no3 ;dict/fizz print-str &no3
14
-		DUP #05 mod ?&no5 ;dict/buzz print-str &no5
7
+	&loop ( integer )
8
+		DUP print-dec #2018 DEO
9
+		DUP #03 mod ?&>no-3
10
+			;dict/fizz print-str &>no-3
11
+		DUP #05 mod ?&>no-5
12
+			;dict/buzz print-str &>no-5
15 13
 		#0a18 DEO
16 14
 		INC GTHk ?&loop
17 15
 	POP2
18
-	( halt )
19
-	#010f DEO
20
-BRK
16
+	( halt ) #010f DEO
17
+	BRK
21 18
 
22 19
 @mod ( a b -- c )
23
-	DIVk MUL SUB
24
-JMP2r
20
+	DIVk MUL SUB JMP2r
25 21
 
26 22
 @print-dec ( num -- )
27
-	#0a DIV print-num
28
-	#0a DIVk MUL SUB
29
-@print-num
30
-	#30 ADD #18 DEO
31
-JMP2r
23
+	( x0 ) DUP #0a DIV print-dec/num
24
+	( 0x ) #0a DIVk MUL SUB &num #30 ADD #18 DEO
25
+	JMP2r
32 26
 
33 27
 @print-str ( addr* -- )
34
-	&while
28
+	&while ( -- )
35 29
 		LDAk #18 DEO
36 30
 		INC2 LDAk ?&while
37
-	POP2
38
-JMP2r
31
+	POP2 JMP2r
32
+
33
+@dict ( strings )
34
+	&fizz "Fizz $1
35
+	&buzz "Buzz $1
39 36
 
40
-@dict &fizz "Fizz $1 &buzz "Buzz $1