View Single Post
Old 09 July 2015, 00:36   #4
Join Date: Jan 2010
Location: Kansas
Posts: 1,284
Originally Posted by SainT View Post
It's some seriously dodgy looking code, but it does some call-like stuff. Once I've got something a bit less crap working I'll submit the code to the git repo.
It's not doing "call-like stuff" correctly. The main() function is "close" to putting the foo() parameters on the stack correctly (AT&T 68k ABI) although, I believe, the 12 should be sign extended before placing on the stack as a word ($0012) or longword ($00000012). It would be best to follow how GCC does this. Of course "call #foo" should be "bsr foo" in order to assemble.

The foo() function is majorly messed up. It looks like it is attempting to use A6 (stack frame pointer on non-Amiga 68k but should be A5 on an Amiga) instead of A7 (stack pointer) to access the arguments. GCC uses stack frames by default (and really can't be turned completely off) while vbcc has stack frame pointers turned off by default which is more efficient (there should be options for both methods and options for register arguments and RTD would be easier to implement early). The foo() variable needs to be allocated by LINK (with a stack frame pointer) or by SUB/LEA without. I believe the stack should have the return address, then the function arguments (for 68k ABI), and then space for local variables/storage which is not the case in the current code. Any MOVEM registers need to be accounted for on the stack as well. There is quite some work to do and it could be tricky to implement correct function calling with different options. I suggest you look at the same code output for different compilers with the same options turned on.
matthey is offline  
Page generated in 0.04842 seconds with 10 queries