Philosophical question...
escher
Posts: 138
in Propeller 1
Question: What is the difference between
and
in a 400 SLoC PASM routine?
Answer:
6 hours and a migraine.
if_c add nxtptr, #4
and
if_c add nxtptr, $4
in a 400 SLoC PASM routine?
Answer:
6 hours and a migraine.
Comments
Enjoy!
Mike
If nxtptr is pointing to a block of longs, the first approach is correct.
A few minutes later...
I decide to write a bit of test code -- I am sure about both assertions now. The first value returns 4, the second returns $80BC1404.
But ye, confusing absolute address vs. immediate data happens to me all the time when writing any assembly language.
The weird custom PASM XMM assembler DSL uhm... thing I've been working on/with actually bypasses this problem by distinguishing between cog/hub/virtual addresses and literal numbers. It'd look like this or this if you actually wanted to read from COG RAM
While that stops these inexplicable bugs, I keep forgetting to convert addresses into numbers when I load them into registers. At least that throws a compiler error.
I feel like I should release that thing, but on the other hand, I don't think anyone else could really make any sense of it.
Told you I'd been on a PASM break! (lots of Python and C for work)
That's actually a very cleaver idea. I think 'No warning is a lot of typing, perhaps maybe something like 'nowarn or 'sptr (source is pointer)? It would probably be good to have a switch to turn off (or on) for people who find such warnings annoying. I'm sure this would have saved me many hours of debugging!
Although "jmp label" is a lot more common than literal cog pointers, which may be annoying if you enable these warnings on pre-existing code.
There's also the case of placeholder values for self-modifying code. Most people use "0-0", so that could also be detected, I guess?
fastspin handles warnings for "jmp label" (no immediate) by looking at the label. If what follows "label" is code then it issues a warning, if it's data then no warning (it assumes you knew what you were doing and that the data is meant to hold an address). You can override this by making the operand a more complicated expression than just a label, so "jmp label+0" never issues a warning. We could implement something similar for literal constants, so:
Another fastspin warning I've found useful is for instructions (other than nop) with no effect, e.g.: I'm not sure how hard/easy that would be to add to p2asm, I haven't looked.
I've learned to look for this when I have a bug...
For me, I think the syntax is backwards... should add the number 4 and not register 4.
But, you just have to learn to watch out for that...
I like the Z80 style better. Where you put parens around the value if you want memory access.
LD HL,123
LD HL,(123)
I think it makes it much clearer what you want to do.
Actually square brackets would be even better then you could parens for math.
Bean
-Phil
Obviously the contents of register 4 was not always 4. I guess that line is followed by: In that case it should be sufficient for the lower 16 bits to be $0004. That's somewhat unlikely, but it could happen if D was a multiple of 128 and S was 4.
Uh, oh! Now you got me wondering what interesting things would happen if an instruction specified its own address for D, S, or both.
BTW, I made a meme. forums.parallax.com/discussion/170706/meme-what-i-accomplish-on-social-media