The fundamental rules of inline asm on GCC are the same for all chips, what changes is the registers, the available instructions and the register aliases, e.g. on AVR r means any register and d means an upper register.
It shouldn’t clobber a register unless you explicitly state it to be an output operand or to be clobbered.
Considering this is rendering code, I’m inclined to agree.
As long as the external interface is C++ friendly,
the implementation can be pure assembly for speed sake,
providing it’s well-commented.
Functions do have a memory alignment, but if it pads I would assume it’s just padding with more nops,
which shouldn’t be a major issue.
ARM instructions are 32 bits wide, but I can’t find any information about function alignment.
I found a thing discussing the alignment of structs which said that the largest field being int causes 4-byte alignment and the largest field being long long causes 8-byte alignment, but nothing beyond that.
I’m erring on the side of memory barriers/formal no-tampering rules though, see this SO question that demonstrates how something as simple as asm("# im in ur loop"); can have an impact because of the side effects of the presense of an asm block (note that the asm block here is implicitly asm volatile).
The Pokitto uses Thumb, not the full 32-bit ARM IS, so it’s just 16 bits wide. I vaguely remember the TRM mentioning 4-byte instruction alignment for certain ops.
What do you mean? You’re using inline asm in the PokittoLib:
fileOpen doesn’t return bool, it returns a uint8_t, and signals success with 0 and failure with 1.
This is one of the many reasons I hate implicit conversion between integer types and bool, if conversion was explicit, you’d have got a compiler error telling you that were trying to put an integer expression in an if instead of a boolean expression.
At least that seems to be the case.
On the simulator it all seems to work fine:
But the hardware code is more than a little confusing.
It’s full of comments and empty functions:
At one point I’d written a nice object-oriented wrapper for some of the file functions, but I lost it somewhere (and may have accidentally deleted it).
I was aiming to design it so you didn’t have to remember call close because the object’s destructor would call it when the object fell out of scope.
If it’s only supposed to play one way, I’d hope it was at least using delta compression.
If ROM files are read only, would it not be possible to leave them on the SD and stream the data from there? or would seeking slow tings down too much?
It would be really slow, and getting it to full speed is being challenging enough. Besides, doing it this way I can use defines to optimize for the specific mapper in the cartridge. Also, the pokitto loader already acts as a menu for picking a game, putting another one in the emulator would be redundant.