VFP/NEON assembler improvements
Jeffrey Lee (213) 6048 posts |
Today I’ve been working on fixing a couple of bugs and implementing a couple of new features in the VFP/NEON assembler. However, a couple of bits could do with some feedback:
Are there any other aspects of the assembler that people would like to see improved? Or any bugs they’ve spotted? |
Kuemmel (439) 384 posts |
…regarding the DCFD issue: I’m open for anything if an automatic detection isn’t possible or too much hassle. If there will be a new directive I think it would be best to have 2 new directives (for single and double precision) that are good for VFP/Neon, so may be like DCVD and DCVS…so that they can be easily remembered. Question is for me also how to convert from FPA to VFP/Neon for double precision ? At the moment I have some code that uses a ATN-function as this is not implemented in VFP/Neon and I want to pass the result back to VFP/Neon. How would that be achieved ? Is there some supporting instruction for that (I didn’t check…) ? |
WPB (1391) 352 posts |
Think I’d vote for the OPT flag. Adding a new directive (a pseudo instruction, I presume you mean?) might clash with a real ARM instruction in the future, and is less obvious to people who are already familiar with the instruction set from other assemblers. I guess another option would be to add a suffix to the instruction like DCFD_le or DCFD_be?
I think it’d definitely be safer to remove this, but your idea of an error message that gives the closest equivalent is a good one. I’d go for that.
Haven’t even managed to find time to try it yet! Wish I could… Anyway, keep up the good work ;) |
Jeffrey Lee (213) 6048 posts |
The single precision format is the same, so there’s no particular need for a DCVS directive.
To convert between the two formats all you need to do is swap the upper and lower words. I think there are a couple of ways you could do it, but the easiest is probably to use VMOV to transfer the value to ARM registers, but with the registers in opposite order, e.g. “VMOV R1,R0,D0”. Then use the appropriate FPA instruction (I don’t have a reference handy!) to load from R0,R1.
No, a directive. DCD, DCFS, DCFD, EQUD, EQUS, etc. aren’t assembled to instructions, all they do is allow you to insert data values. |
WPB (1391) 352 posts |
Of course. Sorry, wasn’t thinking. Nevertheless, you wouldn’t want one to clash with an instruction, I guess. |
Kuemmel (439) 384 posts |
…hm, I think a necessary FPA instruction doesn’t exist. According to Link you can only do it with one register so either FLTS F0,R0 or FLTD F0,R0 and back with FIX R0,F0. According to the exampels on Link there is a precision difference between using FLTS and FLTD and go back with FIX, but I wonder how that’s so. I didn’t read everything, but it seems there’s nothing like a FIX R0,R1,F0 or something. So I think I got to do STFD to store it in memory and then load it back with VLDR D0,value and then swap S0 and S1, or like VLDR S0,value+4 / VLDR S1,value to get into D0. |
Jeffrey Lee (213) 6048 posts |
You’re right – my approach wouldn’t work. FLTS and FLTD both convert from an int to a float, and FIX converts from float to int. So the only way of getting a float into/out of FPA registers without integer conversion is with the load/store instructions. |
Jeffrey Lee (213) 6048 posts |
Any more thoughts on DCFD? I’m hesitant to dedicate an OPT flag to it, since it’s only one directive/instruction out of the several hundred that the assembler supports. Plus there’s the danger of ROL’s BASIC or someone elses extended assembler reusing the same OPT flag for an entirely different purpose. But maybe this isn’t such a serious issue if we’re going to move the assembler out into a seperate module. E.g. instead of OPT just taking a number, the new version might be of the form “OPT <x>,<y>”, where <x> is the standard BASIC flags for error reporting, assembler listing, etc., and <y> is a set of flags (or maybe a string?) for controlling the extra features of the assembler backend. For the moment I’ve implemented a solution similar to WPB’s suggestion of DCFD_le and DCFD_be – you can use DCFD.fpa for the FPA version and DCFD.vfp for the VFP version. This doesn’t rely on the user having to know which one is big-endian and which is little-endian, and it matches the ‘.suffix’ syntax style that ARM seem to have become fond of. A plain old DCFD will use the FPA format, but we can easily change that to be configurable by OPT once we’ve worked out how to move the assembler out into a seperate module. Any complaints if we go with this method for the moment? Other improvements I’ve made:
If everyone’s (relatively) happy with the above then I should be able to get everything checked in tonight. |
Steve Drain (222) 1620 posts |
This is the method used by Extended BASIC assembler, using the directive: EXT flags%,options% . |
Jeffrey Lee (213) 6048 posts |
The assembler changes are now checked in. For reference, the two assembler bugs that I fixed were:
|