From 6ba6c568df55930a4d56472a191cf7c3a6f217b9 Mon Sep 17 00:00:00 2001 From: Sijmen Schoon Date: Wed, 9 Dec 2020 17:51:37 +0100 Subject: [PATCH] Replace .fills with consts wherever possible Reduces filesize from 8kB to 5kB --- c64/btree.asm | 26 ++++++++++++++------------ c64/main.asm | 12 +----------- c64/math.inc | 10 ++++++++++ 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/c64/btree.asm b/c64/btree.asm index 56e096e..1325ee3 100644 --- a/c64/btree.asm +++ b/c64/btree.asm @@ -1,8 +1,21 @@ // vim: filetype=kickass +tree_clear: + lda #0 + tay + + !loop: + sta tree_values_lo, y + sta tree_values_hi, y + sta tree_left, y + sta tree_right, y + iny + bne !loop- + + rts + .const next_index = $02 .const input = $03 -// NOTE Assumes the tree is zeroed tree_insert: ldx #0 @@ -93,14 +106,3 @@ tree_contains: rts brk - - - .align $100 -tree_values_lo: - .fill 256, 0 -tree_values_hi: - .fill 256, 0 -tree_left: - .fill 256, 0 -tree_right: - .fill 256, 0 diff --git a/c64/main.asm b/c64/main.asm index dc37dba..f97c9db 100644 --- a/c64/main.asm +++ b/c64/main.asm @@ -126,6 +126,7 @@ main: sta $01 jsr generate_multiplication_tables + jsr tree_clear //jsr test_tree @@ -145,14 +146,3 @@ day01_input: .import text "../rust/inputs/day01" .byte 0 - .align $100 -* = * "Square table" -square1_lo: - .fill 512, 0 -square1_hi: - .fill 512, 0 -square2_lo: - .fill 512, 0 -square2_hi: - .fill 512, 0 - diff --git a/c64/math.inc b/c64/math.inc index a92df1a..05e2890 100644 --- a/c64/math.inc +++ b/c64/math.inc @@ -1,4 +1,14 @@ // vim: filetype=kickass +.const square1_lo = $c000 +.const square1_hi = $c200 +.const square2_lo = $c400 +.const square2_hi = $c600 + +.const tree_values_lo = $c900 +.const tree_values_hi = $ca00 +.const tree_left = $cb00 +.const tree_right = $cc00 + .const udivmod32_dividend = $10 // 11,12,13 .const udivmod32_divisor = $14 // 15,16,17 .const udivmod32_result = $18 // 19,1a,1b