ObjAsm conditional bug?
Adrian Carpenter (10173) 16 posts |
Hi, I’ve just hit an issue with ObjAsm while modifying code, apologies for code formatting the link to tell me what to do does nothing and whirrs round. I have some kind like this: ^ 0×00 I can happily do this: STRB R0, [R11, IDERegisterSelectCardHead] And ObjAsm is happy with me omitting # and it generates the correct instruction, so it knows it’s an immediate. However, if I add a condition, it fails, so adding MI to the above like so: STRMIB R0, [R11, IDERegisterSelectCardHead] Results in the error “Bad register name symbol”. But this works fine: STRMIB R0, [R11, #IDERegisterSelectCardHead] Maybe I’m abusing the assembler by omitting the #, but it works everywhere except where there’s a conditional, and that shouldn’t matter since the instruction itself is the same, just the conditional flags all and it’s getting it right on the instructions where there isn’t a condition. Further more, this form does with a conditional if it’s WORD based, so: STRMI R0, [R11, IDERegisterSelectCardHead] Works fine. The reason for omitting the # is that it just makes the code easier to read. |
Paolo Fabio Zaino (28) 1882 posts |
When you say “it works fine” do you mean you’ve tested it or that just it assembles your code (without errors)? I can’t reach a RISC OS system for a while, so can’t test it, but I have a feeling that: IDERegisterSelectCardHead # 0×04 Is just being (somewhat) used as 0 I may be wrong though… |
Adrian Carpenter (10173) 16 posts |
It generates the correct code everywhere. I am reverse engineering and building the code triggers a comparison on my local machine which compares the built binary against the original, so a single bit difference anywhere in the file will cause a failure message on my machine. This works everywhere correctly, apart from here on the LDRB/STRB conditionals, on LDR and STR conditionals it works as expected and it works as expected on LRDB or STRB without conditionals, it’s purely an issue on the LRDB/STRB case, for example removing the MI on a LDRMIB command produces: LDRB R14, [R12, #&01C] correctly from: LDRB R14, [R12, IDERegisterStatus] But I cannot use that specific form when a conditional is involved, the compiler just errors. |
Dave Higton (1515) 3526 posts |
It’s a long time since I wrote any significant amount of ARM assembly language, but, as I understand it, # is the correct way to do what you’re trying to do and always has been. If something happens to work without the #, you’re lucky, and you shouldn’t rely on luck. I’m happy to be corrected if I’m wrong. |
Adrian Carpenter (10173) 16 posts |
I’m pretty sure it’s a bug now, having looked around I came across this on page 123 of the ObjAsm manual, referring to immediate operands. “#” is always optional |
Rick Murray (539) 13840 posts |
Yes and no. Is ObjAsm in UAL mode? The default is not to be.
Funny, I find the opposite as it makes it clear that it’s giving a numerical value. Anyway – if you want no #, you need to be in UAL mode, which carries all sorts of other little gotchas, such as “LDRMIB” may no longer work as that same page 123 states that conditions come after other modifiers (so, LDRBMI then?) and SWI is replaced by SVC, etc etc. |
André Timmermans (100) 655 posts |
So far as I know (but that’s pre-UAL), #x is used constants, x is used for register numbers (r0 to r15 are just defined for convenience). Let say you want to implement some code to sum all elements in an array, you can name your registers: |
Stuart Swales (8827) 1357 posts |
Yes, but ONLY when UAL syntax mode has been selected (I always use UAL these days, use —arm command line arg)
It is better to use RN as it’s then clear what the intent is.
|
GavinWraith (26) 1563 posts |
I wonder what buffoon thought that that an asterisk would be a good symbol for a definition? |
Rick Murray (539) 13840 posts |
Isn’t the syntax rather similar to that used by masm? It may be another bit of lingering 6502 era baggage. Having said that, I dislike the GNU assembler code. What buffoon thought that using @ to introduce comments was a good idea? ;) |
Stuart Swales (8827) 1357 posts |
ObjAsm has had |
Rick Murray (539) 13840 posts |
? Unix Amiga Delitracker Emulator or a university in Buenos Aires… (I do love how things that predate “the internet” frequently don’t exist) |
Simon Willcocks (1499) 513 posts |
I don’t know if you’ve noticed, but your x’s aren’t x’s (CHR$78) at all? Apologies if that’s just some feature of the cut-and-paste, but it’s “c3 97”. |
Adrian Carpenter (10173) 16 posts |
The x is either the cut and paste doing something funny or the forum is doing it, they’re most definitely real x characters. |
Simon Willcocks (1499) 513 posts |
Did you try this? STRBMI R0, [R11, #IDERegisterSelectCardHead] |
Steve Pampling (1551) 8170 posts |
Pretty wild, huh? |
GavinWraith (26) 1563 posts |
Sorry, I should not use such a word. What would Robert Recorde have said? |
Paolo Fabio Zaino (28) 1882 posts |
I see, so yes it may be a bug. However, the way I would implement something like this would be:
IIRC, that works 100% in all cases and the case where your approach seems to be not working. Just my 0.5c HTH |
Adrian Carpenter (10173) 16 posts |
Simon yes, as per the initial post that works fine. It’s the case without the # and specifically when a conditional is used that the assembler throws up an error. The weirdness is that omitting the # works in every case apart from a byte load/store with a conditional, there’s no issue with conditional word load/store and there’s no issue a byte load/store as long as there is no conditional. At the very least it’s inconsistent, since it works “more” than it “doesn’t work”, maybe the “bug” is that the behaviour is correct for conditional byte loads/stores and that the other cases should also be erroring. |
David Gee (1833) 268 posts |
If you look closely at the x’s in the initial post they aren’t x’s but multiplication signs: c3 97 is the UTF-8 sequence for such a character. |
Rick Murray (539) 13840 posts |
The forum will “helpfully” translate an ‘x’ in between two numbers into a multiply symbol. Like “123×456” (I typed an X). Best to wrap code in 1 Using curly braces instead of angle ones in order that it not appear wrong after the forum has chewed on it. 2 There’s probably some fancy paragraph style option, but since I write my blog in HTML in Zap, I find it just as easy to type the tags in directly. |
Simon Willcocks (1499) 513 posts |
No, in the original post it was STRMIB, not STRBMI. Rick said: “Anyway – if you want no #, you need to be in UAL mode, which carries all sorts of other little gotchas, such as “LDRMIB” may no longer work as that same page 123 states that conditions come after other modifiers (so, LDRBMI then?) and SWI is replaced by SVC, etc etc.” |
Adrian Carpenter (10173) 16 posts |
It doesn’t matter what the instruction is since the STRBMI example given above includes a “#” and that works in all cases, unless I’m misunderstanding which is a possibility! I think its a bug in the assembler, but the bug is the inverse of my statement in the original post, it shouldn’t be allowing the cases without a “#” in non UAL mode, but it does and as a result it only behaves “correctly” when using a byte wise load/store instruction with a conditional, it should be throwing up errors everywhere else where the # is missing. I’ve modified my code back to what it was originally, that is including the “#” everywhere since that’s the only case that produces a consistent result no matter what size of store and regardless of any conditionals. |