..that will fill in all of the screen of the Hack Computer.
// The Hack computer includes a black-and-white screen // organised as 256 rows of 512 pixels per row. // The screen’s contents are represented by an 8K memory map // that starts at RAM address 16384 (0x4000). // Each row in the physical screen, starting at the screen’s top left corner, // is represented in the RAM by 32 consecutive 16-bit words. // Address 16384 (0x4000) is where the screen starts. // Hold this value in memory address currentScreenLocation. @16384 D=A @currentScreenLocation M=D // Address 24575(0x5FFF) is the last 16 bits of the screen. // Hold this value in memory address lastScreenLocation @24575 D=A @lastScreenLocation M=D (LOOP) // Set the value in address 'currentScreenLocation' to -1, which is 16 1's in binary. // This actually means turning on 16 pixels in the screen. @currentScreenLocation A=M M=-1 // Load the currentScreenLocation address to D @currentScreenLocation D=M // Increment the value in D D=D+1 // If lastScreenLocation - incrementedValue = 0, end.. @lastScreenLocation D=M-D @END D;JEQ // Else load the currentScreenLocation address to D @currentScreenLocation D=M // Increment it D=D+1 // Write it back M=D // Go back to Loop to draw 16 more bits.. @LOOP 0;JMP (END) @END 0;JMP // infinite loop