summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBen Bridle <bridle.benjamin@gmail.com>2024-01-09 11:42:44 +1300
committerBen Bridle <bridle.benjamin@gmail.com>2024-01-09 11:47:06 +1300
commit2ff465ec880107691e3aa288574a3049f5276af2 (patch)
tree4f83c74513c93b6812d2c29b36bedd5b15dc470b /src
parentc8dfaecc8f02754d74cd6d92a66dc28c0e78c84b (diff)
downloadbedrock-asm-2ff465ec880107691e3aa288574a3049f5276af2.zip
Report program size as a percentage
The assembler previously reported only the length of the generated bytecode in bytes. It now also reports the program size as a percentage of the maximum program size of 64KB, to give the user an idea of how close they are to hitting the program size limit.
Diffstat (limited to 'src')
-rw-r--r--src/main.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs
index d9683a3..11ce42b 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -26,7 +26,9 @@ fn main() {
eprintln!();
}
- eprintln!("Assembled program in {} bytes.", bytecode.len());
+ let byte_count = bytecode.len();
+ let byte_percentage = (byte_count as f32 / 65536.0 * 100.0).round() as u16;
+ eprintln!("Assembled program in {byte_count} bytes ({byte_percentage}% of maximum).");
if is_error {
std::process::exit(1)