Whats wrong with this line of assembly?
NF_SUBSECTOR = $8000 results in: /home/matze/amigatoolchain/amiga-gcc-out/bin/vasmm68k_mot -Fhunk -phxass -warncomm -nosym -ldots -spaces -m68030 -m68882 -I/home/matze/amigatoolchain/amiga-gcc-out/m68k-amigaos/sys-include -I/home/matze/amigatoolchain/amiga-gcc-out/m68k-amigaos/ndk/include amigaasm/r_engine.asm -o r_engine.o I believe the ~ somehow turns the value into a 32bit value... but how can I convey to vasm to just use it as word sized? |
Nf_subsector = -$8000
EDIT: for some reason the editor convert NF_SUBSECTOR to Nf_subsector... why?! EDIT2: verbose mode I think it's due to the fact that instructions default to .w operations So in a 16 bit two's complement logic $8000 cannot exist.. -$8000 yes |
try and #~NF_SUBSECTOR&$FFFF,d0
|
Try adjusting the value $8000 to $7fff
|
Both Alkis and Galahad's solutions work, though I chose Alki's in the end (to stick with a named symbol rather than a magic number)
What I don't understand: why bitwise negating a 16bit number does not result in a 16bit number - is this a bug in vasm maybe? |
Quote:
NF_SUBSECTOR = $8000 = $00008000 and #~NF_SUBSECTOR,d0 = and #~$00008000,d0 = and #$FFFF7FFF,d0 |
I thought the 'and' without .w defaults to .w - no?
Adding .w yields the same error message. If its an error in the declaration of NF_SUBSECTOR, how do I change it so it would become a 16bit number? |
Quote:
|
So the question remains: how to declare less-than-32bit symbols then?
|
No, the problem is that you cannot filter a longword reliable in D0 with only 16 bits. You have to expand it to 32 bits as shown by alkis.
In case that you want to process the contents of D0 later only as a word in your code, you may have to ask Frank Wille why this error message appears. I'm not a user of VASM, I still prefer the good old PhxAss, but never had to fight with such a problem yet (because anything similar newer existed in my code). Did you already try NF_SUBSECTOR DC.W $8000 but that's not a preprocessor declaration maybe NF_SUBSECTOR = $8000.w ???? |
Quote:
Alkis method is truncating back to 16bit, not expanding to 32bit. I think what happens is that NF_SUBSECTOR is treated as 32bit constant (that just happens to fit into 16bit). When the ~ operator is applied, the result is $FFFF7FFF (as you showed), which doesn't fit into 16bits anymore. Anyways, thanks for your input... its working now. This thread is already way too long for a single assembly line ;-( |
Quote:
Best you could do is to ask Frank Wille (phx) Cheers ... Peter |
Operators in vasm, as well as in phxass, use longwords regardless of instruction size. I guess most assemblers will do the same.
This behaviour is perfectly normal. You can use exclusive or to perform the "~" operation on a word (this is for phxass, i don't know if vasm uses the same character for eor) : Code:
NF_SUBSECTOR = $8000 Code:
NB_SUBSECTOR = 15 |
But the problem lies in the fact that you use the constant NF_SUBSECTOR both as 16 and 32 bit?
Because otherwise no problems arose. If you define as -$8000 the value is the same both 16 or 32 bit: $FFFF8000 or $8000, sign extended And if you use and.w #~NF_SUBSECTOR,d0or and.l #~NF_SUBSECTOR,d0or and #~NF_SUBSECTOR,d0result is one: and.x #$7fff,d0, that is the requested operation (logically for .w upper bits are untouched). So, even if assembler default to 32bit, result is correct. What's wrong with this? |
Quote:
|
Quote:
|
Quote:
Quote:
|
Quote:
So equates are always stored as 32 bit values. And eval_expression() always returns $ffff7fff for ~$8000. Then the AND.W instruction checks its immediate operand, which doesn't match its current operation size... Yes, I think all assemblers work that way. Otherwise I have to fix it. :) |
All times are GMT +2. The time now is 14:59. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.