Exophase
Nothing good will ever come of Exophase.
That's inefficient, and simply unnecessary (unless I've misread the mul docs). Why not:
mul r9, r2, #10
?
There isn't a mul immediate instruction.
That's inefficient, and simply unnecessary (unless I've misread the mul docs). Why not:
mul r9, r2, #10
?
Also, I note in your newline macro, you declare the length of a newline character is 2 bytes; that's not actually the case on linux and the Pandora - it's a single 0x0a. I guess it works though because you've defined the contents of the newline address as a zero terminated string, so you've actually stored 0x0a and 0x00 there. The zero byte isn't considered a printable character, so I guess it just silently ignores it.
Your comment to your syswrite macro is also not quite correct; you're not printing out the contents of r1, you're printing out what r1 points at. But, eh, it's only a comment.
I've not got round to looking at the logic of the code yet, but initial impressions are favourable, and if you reckon it does what it's meant to then that's promising.
Other than that, I'll just note that almost all of the instructions of the form 'mov rx, ry' can be eliminated, except for 'mov r8, r5' where you preserve the state of r5. Also, if you split the dual uses of r10 as a multiplier into one that contains the reciprocal, and one that contains #10, you can move the setting of those outside of the loop.
About using more registers, can it have drawbacks ?
Does pushing more registers doing macro or function call has a weight ?
dmarschal mentioned that "\n" is coded as one "0xA" character in the binary file.
I don't get how to use this value in the code.
Just say the length of newline is 1 byte, rather than 2 as you currently do. That should still work, then you can try replacing the .asciz directive with a .ascii one, which will avoid writing out the ending 0x00. You don't need to engineer an 0x0A value - '\n' already evaluates to that.
I don't think that'll cause any problems with alignment, as it appears that the .word directive aligns automatically, but I'd test it out at every stage in case I've misinterpreted what the assembler is doing there.
I've been told that things like recursion can't be done with a macro as it produces infinite length code.
I suppose macros can execute functions ?
What's this .global thing when including functions ?
Doesn't macros can be passed argument at ?
I'm not sure I get the difference between a macro and a function...
What are 1: and 2: because I see other in the same code so it can't be the same label ?
Or is it like a private thing ?