Debugging Fill.asm "exptected expression"

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

Debugging Fill.asm "exptected expression"

Vijay99
Perhaps my code has some syntax error but I am not able to figure it out:
status line says: "expected expression at line 33"

(TURN)          // turns the screen black
@loo             // loo is a variable that counts the no of iterations
D=M             // line 33
D=D-8192
@LOOP
D;JGT           // go back to (LOOP) which checks for KBD input

Here's the file Fill.asm
Reply | Threaded
Open this post in threaded view
|

Re: Debugging Fill.asm "exptected expression"

WBahn
Administrator
D-8192

Is not a recognized mnemonic.

There are 28 recognized mnemonics, all of which are defined in Figure 4.3.

Anything other than one of those 28 mnemonics is not guaranteed to work.

The author's assembler will accept D+M and M+D, though I would prefer it didn't as it reinforces the very confusion you are falling prey to.
Reply | Threaded
Open this post in threaded view
|

Re: Debugging Fill.asm "exptected expression"

Vijay99
I resolved it. Why was it giving the error at line 33, should it not refer to line 34?
WBahn wrote
The author's assembler will accept D+M and M+D, though I would prefer it didn't as it reinforces the very confusion you are falling prey to.
I take it to mean that D-8192 was confusing. Or is there some other confusion?
In totality, do you think it is a satisfactory solution to the problem?
Reply | Threaded
Open this post in threaded view
|

Re: Debugging Fill.asm "exptected expression"

WBahn
Administrator
Vijay99 wrote
I resolved it. Why was it giving the error at line 33, should it not refer to line 34?
It may count lines starting with zero.

It may just return a line counter's current value and it doesn't increment until it moves onto the next line.

Several possible reasons. In general, whenever a tool says line N, it's a good idea to look at the lines immediately above and below if it isn't obvious that the problem is on the indicated line.

Vijay99 wrote
WBahn wrote
The author's assembler will accept D+M and M+D, though I would prefer it didn't as it reinforces the very confusion you are falling prey to.
I take it to mean that D-8192 was confusing. Or is there some other confusion?
In totality, do you think it is a satisfactory solution to the problem?
Do I think what is a satisfactory solution? What change did you make to solve the problem (of having an unknown expression in your code)?

D-8192 is NOT an instruction mnemonic.

The assembler has to convert each assembly instruction into exactly one 16-bit opcode. What opcode would it convert the instruction D=D-8192 into?
Reply | Threaded
Open this post in threaded view
|

Re: Debugging Fill.asm "exptected expression"

Lozminda
In reply to this post by Vijay99

If I remember correctly (and it was a long time ago I did this, no doubt/hopefully I'll be corrected):

If one wants to take on number away from another, one has to load the first value into a register, and the other into the other register say D and A and then do something like M = D - A. My implementation is I'm sure wrong, but you get the Feeling, if you want to take values away from each other, everything's got to go into a register including the result...