4 messages
Open this post in threaded view
|

 This post was updated on . Just to make sure I understand the basics: I'd appreciate it if anyone could check the codes below for me: the main function is to make arr[j]=0 and arr[j]=17. Thanks arr[j]=0://arr=20561,j=3012 @3012 D=A @20561 D=D+A @D M=0 arr[j]=17// @3012 D=A @20561 D=D+A @D D=M @17 D=D+A if x[i]<=0 goto NEXT @x D=A  //&x @i D=D+A  //&x+i @D D=M    //x[i] @NEXT D;JLE another question is whether do I need to use the symbols like arr or j to code this or simply just replace them with the numbers you provide in the pdf?
Open this post in threaded view
|

 Administrator lonelyjohner wrote Just to make sure I understand the basics: I'd appreciate it if anyone could check the codes below for me: the main function is to make arr[j]=0 and arr[j]=17. Thanks ... //arr=20561,j=3012 arr[j]=17// @3012 D=A @20561 D=D+A @D D=M @17 D=D+A ... another question is whether do I need to use the symbols like arr or j to code this or simply just replace them with the numbers you provide in the pdf? I suggest that you load your code into the CPU Simulator, step through it, an see what happens; it doesn't do what you want. Reread how @ commands work. In particular, if the argument to an @ command is not a number or a code label, the assembler allocates a RAM location for a new variable. The command "@D" does not do anything involving the D Register. To read or write RAM locations, you need to use "M" as a source or destination. The address of the RAM location to be accessed must be in the A Register. It is better to use symbolic names because there is less chance of error.  For the programs that you write for for project 4, you can use the built-in variable names R0 - R15, KBD, and SCREEN instead of hard coded numbers. You can use a named variable like "j" for indexing into the screen memory. --Mark