~aleteoryx/up-for-it

ref: ff0d1bd0afcddd5a61cea8d7afe504abb9a1480c up-for-it/aoc/2025/xx.tal -rw-r--r-- 1.0 KiB
ff0d1bd0Aleteoryx ascii math routines 3 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
( advent of code 2025, day xx, first star )

%dbg { #010e DEO }

@on-reset ( -> )
	banner
	first-star
	BRK

@banner ( -- )
	;/str !puts
@banner/str
	"advent 20 "of 20 "code 20 "2025, 20 "day 20 "xx, 20 "first 20 "star 0a 00


( first star )

@first-star ( -- )
	Input/read
	JMP2r

@first-star/on-input ( b -- )
	JMP2r


( stdlib )

@endl ( n -- )
	#0a18 DEO JMP2r

@puts ( str* -- )
	LDAk #18 DEO
	INC2 LDAk ?puts

	POP2 JMP2r

@putdec2 ( n* -- )
	[ LITr 00 ]

	&loop
		#000a DIV2k STH2k
		MUL2 SUB2
		[ LIT "0 ] ADD NIP
		STH2r ROT STH
		ORAk ?/loop
	POP2
	
	&loop2
		STHr #18 DEO
		STHrk ?/loop2
	POPr JMP2r


( object lib )

@Input/filename "xx.input 00
@Input/read ( -- )
	#01ab DEO
	;/filename #a8 DEO2
	
	&loop
		;/byte #ac DEO2
		#a3 DEI #00 EQU ?/endloop	( EOF )
		[ LIT &byte $1 ]
		first-star/on-input
		!/loop

	&endloop
	POP2 JMP2r

	
@Number/one-byte ( b -- )
	#00 SWP
	LIT "0 SUB
	[ LIT2 &val 0000 ]
	#000a MUL2 ADD2
	,/val STR2
	JMP2r
@Number/get ( -- n* )
	,/val LDR2 JMP2r
@Number/reset ( -- )
	#0000 ,/val STR2 JMP2r


( problem code )