|
hello everyone. I would be grateful to all if you can tell me what should be modified in project 4, fill.asm file if i want the screen to be blak not pressing any key, but pressing a specific key from keyboard..it doesn t matter which one...
By default, if you press any key, screen become black, but i want to be black only when i press a specific key...
the cod is this>
// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/04/Fill.asm
// Runs an infinite loop that listens to the keyboard input.
// When a key is pressed (any key), the program blackens the screen,
// i.e. writes "black" in every pixel;
// the screen should remain fully black as long as the key is pressed.
// When no key is pressed, the program clears the screen, i.e. writes
// "white" in every pixel;
// the screen should remain fully clear as long as no key is pressed.
// Put your code here.
// First, a simpler program the just fills the entire screen
//@counter
//M=-1
//(LOOP)
//@counter
//M=M+1
//D=M
//@SCREEN
//A=A+D
//M=-1
//@8192
//D=D-A
//@LOOP
//D;JNE
//... this fills the screen with black but stops with err msg: Can't continue past last line
(BEGIN)
@KBD
D=M
@BLACK
D;JNE
@WHITE
D;JEQ
(BLACK)
@counter
M=-1
(LOOP)
@counter
M=M+1
D=M
@SCREEN
A=A+D
M=-1
@8191
D=D-A
@LOOP
D;JNE
@BEGIN
0;JMP
(WHITE)
@counterwhite
M=-1
(LOOPWHITE)
@counterwhite
M=M+1
D=M
@SCREEN
A=A+D
M=0
@8191
D=D-A
@LOOPWHITE
D;JNE
@BEGIN
0;JMP
thank you
|