Graphic version of "hello world" issue

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Graphic version of "hello world" issue

William DesLauriers
I copied a program off a Coursera website. The program is named "Rectangle.asm", which is a graphic version of the "hello world" program. It seems having its infinite loop and a blank screen. My 3 questions are; 1)Do we have a flowchart program? 2)Do we do some flowchart manual drawings? 3)How do I paste my code here instead of my file? Wm
Reply | Threaded
Open this post in threaded view
|

Re: Graphic version of "hello world" issue

cadet1620
Administrator
William DesLauriers wrote
I copied a program off a Coursera website.  The program is named "Rectangle.asm", which is a graphic version of the "hello world" program.  It seems having its infinite loop and a blank screen.  My 3 questions are; 1)Do we have a flowchart program?  2)Do we do some flowchart manual drawings? 3)How do I paste my code here instead of my file?

Wm
I don't know Rectangle.asm. There is a file in projects/06/Rect names Rect.asm which is probably what Rectangle.asm was derived from. This file is used for testing the Assembler that you will write, and its .hack file is used for testing your Computer in project 5.

That program requires that R0 be set manual before it is run to a non-zero value (the number of lines to draw). This is done by the test script in project 05 that uses the .hack file.

What you are probably seeing is that the program is drawing R0 = 0 black lines and entering its halt loop. Try setting R0 = 10 and running the program.


To answer your questions,

Flowcharts are not generally used in the nand2tetris course; algorithms are presented in pseudocode.

You can insert any file by using "upload file" found under the "More" button. You can also insert code snippets inline in your posts by placing <raw> and </raw> tags around them. Raw text is also good for simple tables using fixed layout:
 a | b ||a^b
---|---||---
 0 | 0 || 0
 0 | 1 || 1
 1 | 0 || 1
 1 | 1 || 0

--Mark


Reply | Threaded
Open this post in threaded view
|

Re: Graphic version of "hello world" issue

William DesLauriers
This post was updated on .
// 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/Rectangle.asm

//
//
//




@Screen
D=A
@addr
M=D  // address = 16384(Base address of the Hack screen)

@0
D=M
@n
M=D  // n = RAM[0]


(LOOP)
@i

[Edited out by Author]


M=D+M  // addr = addr +32
@LOOP
0;JMP  // goto LOOP

(END)
        @END  // program's end
        0;JMP // infinite loop
Reply | Threaded
Open this post in threaded view
|

Re: Graphic version of "hello world" issue

cadet1620
Administrator
Yes, that's a variant of Rect.asm, but it isn't a functional program.  There are some bugs:

13: @Screen

This needs to be @SCREEN.  As written, the program starts writing -1 into RAM starting at address 16 instead of 16384.  (@Screen is a RAM variable.)

27:(LOOP)
28: @i
29: D=M

Variable 'i' was not initialized.  It needs to be initialized to zero immediately before the (LOOP) variable.

25: @i
26: M=0
24: (LOOP)

There may be other bugs; I quit looking.

--Mark
Reply | Threaded
Open this post in threaded view
|

Re: Graphic version of "hello world" issue

William DesLauriers
No Problem, I will try to smash these bugs myself.

Wm