%FT and %BT
Pages: 1 2
Tank (53) 375 posts |
As the source for the GPIO module was updated in the repository, I thought I would download and build it, as a test, myself. I have noticed in the past this does sometimes happen and have been able to see the problem as I was only introducing incremental changes, but now as the whole source has changed, it may have introduced multiple branch problems. Does anyone else have this problem, or is it something I’m doing in my code that causes the branch calculation to fail. I only noticed this as I was asked for a copy of the module to run on a B+ and the person requesting it found part of their code now failed. Assembler version is ARM AOF Macro Assembler 4.01. Example code is…
When assembled normally the BEQ would branch to MOV r0,#2 but can assemble to MOV r0,#3. |
Rick Murray (539) 13840 posts |
Completely off the top of my head (as I don’t use the FT/BT myself) – don’t you need a ROUT or something to indicate to the assembler which section of code is which? |
Rick Murray (539) 13840 posts |
“The local label, a subclass of label, begins with a number in the range 0-99. Local labels work in conjunction with the ROUT directive and are most useful for solving the problem of macro-generated labels. Unlike global labels, a local label may be defined many times; the assembler uses the definition closest to the point of reference. To begin a local label area use: «label» ROUT The label area will start with the next line of source, and will end with the next ROUT directive or the end of the program. Local labels are defined as: number«routinename» although routinename need not be used; if omitted, it is assumed to match the label of the last ROUT directive. It is an error to give a routine name when no label has been attached to the preceding ROUT directive.” And more. Assembler PDF, (virtual) page 46. |
Tank (53) 375 posts |
Rick, I’ve just looked at a couple of assembler files in the repository and they use the same method as show in the “example” code above. See castle/RiscOS/Sources/HAL/OMAP3/s/Audio and many Bxx %FT10/%BT10 are used pointing to many jump points in the code. There seems to be no use of ROUT there. Also these labels are not in macro’s. From the description you give the assembler should point to the nearest label, but in my case it misses the nearest and gets the next. |
Steve Pampling (1551) 8170 posts |
My understanding (limited) is that unless the ROUT directive has been used the FT or BT are global to the whole code, but the ROUT directive limits the scope. In which case the use of the numeric element alone (without the routine name) is a special case that only works if you don’t try and re-use the same local label without the containment. In short using the numeric alone is (slightly) bad practice. Awaits shot and downward spiral in flames… |
Steve Pampling (1551) 8170 posts |
I read it as pointing to the last defined: “although routinename need not be used; if omitted, it is assumed to match the label of the last ROUT directive” |
Rick Murray (539) 13840 posts |
Spiral of flames… Did you read the OMAP3 code Tank linked to? It’s like the first quarter is chock full of jumps, all to label %10. That is so hairy! |
Rick Murray (539) 13840 posts |
Do you keep code versions, for an examination of code that does and does not fail? There must be an as yet unknown condition that changes the behaviour. |
Tank (53) 375 posts |
I have just sent copies of actual good and “bad” code to “Sprow”, who was the person who updated the source for ROOL. Hopefully he will find my glaring error and correct me… |
Steve Pampling (1551) 8170 posts |
There are reasons I keep getting confused and studying code like that is one of them.1 Interestingly other code (elsewhere) that I’ve looked at is careful enough to use %10 and %20 although reading the manual it seems %10mylabel1 and %20label2 would appear to be the correct version of things. BTW. Small delay was due to watching LH beat NR in a wheel to wheel again Congrats to VB for deserved 3rd. 1 Many more reasons have nothing to do with obfuscation elements, but this doesn’t help |
Rick Murray (539) 13840 posts |
Well, it appears to build correctly. However if there is some little quirk that can mess up the references, then I can imagine it would be hell to try to debug. As with Tank’s code, where he thinks the branch should be and where it really is may differ.
I grew up with the BASIC assembler, coupled with a desire to know exactly what my code is doing. I still prefer inline code over macros – I find “STMFD R13!,{xxxx,R14}” to be a lot clearer than "ENTRY "xxxx"". That isn’t to say that macros don’t have positive attributes (a single EXIT that takes care of itself is quite nice), I just prefer to see the code. For example, in http://www.heyrick.co.uk/software/resfinder/resfinder_s.html "count_loop" and "count_loop_b" are sure candidates for using the local references. You’ll notice that the code is commented in detail. I must remember that it may not be me making the next modification. And if it is, it might be years later when I no longer have “familiarity” with the code. A few higher level comments (even if pointing out the obvious) can save a LOT of time at some unspecified future date.
Not quite. I think “mylabel1” and “label2” need to match their respective “ROUT” definitions. So:
would be correct, but:
would be incorrect (label1 != somecode).
Probably the only time anybody around here would offer an accolade to VisualBasic? No? Then no idea what that line means. |
Steve Pampling (1551) 8170 posts |
There’s a VBScript that checks printed letters for particular content and counts each type reporting to a summary sheet used by a particular team I won’t name1 there is another (set) that creates barcode labels on Zebra printers.2 There’s a complicated one that checked every PC on the domain for trace evidence of Conficker, squashed it and moved on, looped and re-checked.3
Formula 1. 1 I’ve had complaints I didn’t finish the job and have it create a new tab in the Excel spreadsheet that team uses so we could have “lost” a few bums on seats 2 check the script they use ^A start label, ^Z end label, ^FO x,y field origin is x,y – I knocked up scripts halfway through a go live morning to test printer alignment issues. Looked later, no comments – binned. 3 Nasty little beast needs an automated “whack-a-mole” to keep it in check while you do all your other clean up work. 4 Good job really, the printer scripts were pointing at a server based printer share and when the server changed I needed to edit. To do that I had to read stuff I hadn’t looked at since 2008 5 NR having failed in his attempt at the first corner and flat-spotted his tires so bad the team owner referred to them as “square” he pitted, changed them and spent the race trying to catch up. Having the fastest make of car on the track helped on that bit. |
Tank (53) 375 posts |
“Sprow” has found the problem… |
Steve Pampling (1551) 8170 posts |
Which is exactly what the documentation says about it being valid until the next ROUT. Since macros are essentially a marker for an automated insertion of a block of code I suppose you should expect all macros to clear down the last %10 you used. Probably best not to use them if you have a macro or two around. Probably best not to use them. |
Colin Ferris (399) 1814 posts |
Since the ‘Assembler’ is supposed to be helping you – could not this error be checked for? Another one is the ‘ALIGN’ command – if you place it at the beginning of the line by mistake – it doesn’t work. No error is given then – but a possible error given later on with a branch. It only seems to only flag an error if you use ‘ALIGN’ twice! – at the beginning of a line. Are we allowed to ask – for extras to be added to the ‘assembler’? Like MACRO’s at the end of the file & the use of ‘:’ to make something like below possible. DCB "Message",0:ALIGN |
Steve Drain (222) 1620 posts |
Me too, but I am trying rather unsuccessfully to wean myself onto the hard stuff. ;-)
A very long time back I came across “2 1/2 pass assembly” in BASIC and then designed my own system, which I think is unique. This allows me to re-use labels such as ‘count’ freely throughout the the code. It is abandoning such convenience for the more awkward constraints of of the Assembler that is holding me back. ;-(
Oh yes!
But would this be ok?
|
Steve Drain (222) 1620 posts |
While I still use Darren Salt’s Extended BASIC Assembler I can do: DCZA “Message”but I will not be in a position to use it forever. |
Rick Murray (539) 13840 posts |
Ages ago I wrote this: http://www.heyrick.co.uk/software/resfinder/equx_h.html EQUSZA does what you want. |
Steve Pampling (1551) 8170 posts |
Report from filter at work: “Entertainment sites are blocked” How the hell does the guy on the next desk know what I do for entertainment? :) |
Rick Murray (539) 13840 posts |
Entertainment? Not heard my blog called that before. But hey, I’ll take it as a compliment. ;-) |
Rick Murray (539) 13840 posts |
@ Colin:
If you use a macro, you don’t need the : thingy. Link to EQUSZA above. I think macros need to come first as the assembler would need to know what a macro was prior to using it. If you want macros at the end, you are asking for the assembler to perform an additional pass (to find all the macros). There is, however, no reason why you can’t put macros into a header file (like the “EQUx” ones that I linked to) and insert it into the assembly with a simple GET command. @ Steve:
Using assembler at all is “the hard stuff”. ;-) The nice thing about objasm is that, asides from the “must indent or its a label” thing, is that it is pretty flexible. Macros? If you like, not enforced. Local branching? If you like, not enforced. Conditional assembly? Simple loops? Named registers? Ditto. You can use as many or as few facilities as you like.
Sounds interesting, tell more?
A billion years ago, I used to use a different assembler. Nick Roberts’ ASM. It offered a number of features as yet unsupported on objasm, but I have moved over because it is probably better to stick with the one standard toolchain instead of patching together something custom. |
Steve Drain (222) 1620 posts |
No, the BASIC assembler is warm and cuddly.
The usual way to assemble code in BASIC is one pass with errors off to create variables for all labels, essential for forward references. Then a second pass with errors on to assemble the final code. In “2 1/2 pass” assembly the first pass is the same, but the intention is to create global labels. In the second pass any section of code requiring local labels is given its own double pass. That is how I first saw it, rather awkwardly implemented. My own method just makes the whole thing quite simple to work with. The source is divided into FN (macro) sections which are included under a further function that does the double pass and controls the options and pointer. So, in truth, each section of source is passed three times, but I use the original name for the idea.
I entirely agree. It is getting there that is the problem. I am comfortable where I am. |
Colin Ferris (399) 1814 posts |
Is the source available for – Darren Salt’s Extended BASIC Assembler – might be worth 32bitting. |
Steve Drain (222) 1620 posts |
You can get the source from: http://old-www.moreofthesa.me.uk/progs.utils.html#extbasicasmHowever, it would not be just a matter of 32-bitting it, because it modifies and uses a soft-loaded copy of the BASIC module. AFAICT this provides jumps into the EBA module from a lot of points in the error handling. Therefore a fresh version has to be prepared, or checked, against new versions of BASIC. The latest one available works with BASIC 1.20 in RO 4.02. [Edit] Actually, just 32-bitting might help if only the assembler features of 1.20 are needed. To see what EBA can do you could look at my StrongHelp manual: http://www.kappasite.pwp.blueyonder.co.uk/extbasasm.htmJust to bring this on topic, EBA provides ROUT, but with @10 rather than %10. I prefer not to use that since the local labels have to be numbers and I like meaningful names. |
Colin Ferris (399) 1814 posts |
That manual for extbasicasm is most useful. Have assembled the code with ObjAsm – few changes – but now end up with a module of the same length. Difficult to check for errors – as the ADRLs vary from what was used before. ADR R0,&XXX Using StrongEd v4.66 over a group of files – how do you search for : MOV R0,#1 Don’t seem to get the syntax correct – I can search for ‘MOV’ or ‘R0,#1’ 32Bitting looks doable – first 32bitting to work with the RO4 BASIC & then with a RO5 version of BASIC. Which version of BASIC for RO5? – has the updates added by a third person been added to the latest version? As a note – the code uses - BEQ %ft20export |
Pages: 1 2