dcpu16 icon indicating copy to clipboard operation
dcpu16 copied to clipboard

invalid operand

Open harwoodr opened this issue 13 years ago • 4 comments

I'm getting:

hello.asm:10: invalid operand hello.asm:10: >> :nextchar ife [data+i], 0 ; If the character is 0 .. <<

When I try running Notch's "hello world" code through a16.

https://raw.github.com/jtauber/DCPU-16-Examples/master/hello.asm

Any thoughts on that? I haven't completely traced through your code to see where things go awry, yet.

harwoodr avatar Apr 10 '12 18:04 harwoodr

Ah I see what it is. 'data' is a keyword so it's getting confused.

travisg avatar Apr 10 '12 19:04 travisg

Hmm. That's fixable. It gets a little weird though if you want to be able to use labels named "a" or the like. Easiest fix for now is probably removing the DATA alias for DAT

swetland avatar Apr 10 '12 21:04 swetland

Yeah, I think the best solution would be to put the lexer into a 'look for label' mode when at that part of the parser. I'd guess it'd not try to match against keywords, but only registers at that point.

travisg avatar Apr 10 '12 21:04 travisg

The problem is that [a,b] is ambiguous if we allow labels to alias register names. Aliasing keywords is not a problem though, you're right.

swetland avatar Apr 11 '12 03:04 swetland