Below you will find pages that utilize the taxonomy term “Assembly”
wAx the VIC-20
Wax
Over the years, I’ve looked for an Assembler for the VIC-20. Sure, there are great cross-assemblers like Kick Assembler, but I wanted something that would run on the VIC-20 itself.
Is the VIC-20 a good machine on which to write assembly? Maybe not ON the machine. The 22-column screen is a bit limiting, but after spending so much time in Turbo Macro Pro on the C64, I wanted to see what I could do on the VIC-20 natively.
Machine Language: Count Faster on 6502
I’ve done a lot of silly math, ciphers and asked a lot of my vintage hardware on this site over the years. But I’ve not talked a ton about optimizing code for faster results.
Today, we will count from 0 to 2^24-1
(16,777,215). Nothing else. Count, time it, and see how fast we can get it to go.
Rust
In Rust on my 2020 MacBook Pro:
use std::time::{Instant};
fn main() {
// Start timing
let start = Instant::now();
// Loop from 0 to 16777215
for _i in 0..=16777215 {
// The loop body is empty, just like in the BASIC code
}
// Calculate elapsed time
let duration = start.elapsed();
// Convert elapsed time to seconds
let elapsed_seconds = duration.as_secs() as f64
+ (duration.subsec_nanos() as f64 / 1_000_000_000.0);
println!("Counting to 16777215 took {} seconds", elapsed_seconds);
println!("That's {} additions per second", 16777216.0 / elapsed_seconds);
println!("On 2 GHz Quad-Core Intel Core i5")
}
A gentle introduction to two's complement
I was recently on a video call with a friend, throwing around some ideas for a new product. I mentioned adding large signed numbers in assembly and using two’s complement. He asked me what two’s complement was. I was a little surprised that he didn’t know. He’s been a Java programmer for more than 30 years. Java and Python programmers (and others like gasp Commodore / MicroSoft BASIC) don’t have a native unsigned integer type. The language takes care of the details for you.