AmiDevCpp asm - undefined reference
Hi again,
further to my post a few days ago I have been dipping my toe in the water here and trying to find a working environment to code C and ASM for amiga in. Hannibals toolchain seemed perfect when I compiled the examples because I really want to use visual studio but it fell apart a bit when I tried to change the project structure (mostly because it relies on a .bat rather than giving visual studio references to the alternative compilers and intelligent command lines) and then I found most of the c standard library was missing (stdio, etc) and shoehorning it in didnt work so well. Basically it's great but very much designed for writing demos and in pretty much pure assembler. That aside I decided to try amidevcpp as a "should just work" solution. Again, I'd much rather visual studio but right now i'll take anything that'll compile. I wrote a simple hello world in pure C - it compiled. I put the exec on a virtual hdd in winuae and ran it and it worked - joy :) Then I added test_asm.s to my project. I've been following the amiga hardware programming asm tutorials on youtube so I decided to simply try compiling the mouse wait loop from tutorial 1. It looks like: Code:
waitmouse: [Linker Error] undefined reference to `$bfe001' if I comment out the btst line the rest compiles fine :/ Is there some other syntax for btst in amidev or some such? Thanks for your time :) |
Quote:
|
Quote:
|
Quote:
@Sephnroth You can use another assembler with Motorola format (like vasm) if you are assembling the files separately and linking the .o files. This is only possible with unofficial older versions of GCC which output Amiga HUNK format executables (I believe this includes default AmiDevCpp GCC). Your hardware banging and polling is not multitasking or C friendly which you probably already know :D. |
It certainly isnt friendly, at the moment I'm stuck having hung the system and failing to restore it :P I was just coming in to post to ask about it!
My goal here is to be able to create full screen games, multitasking can go do one ;) BUT my hope is to use C for the bulk of any game's engine (the state machine, logic, etc) and bang the hardware for the bits that need the speed - ie, rendering bitmaps etc. Currently I successfully start my program, print some text to console window (not at the full screen game graphics stage yet! :P), disable "the system", start a loop, wait for a mouse click and then exit my loop and in theory my program. Sadly the "restore the system" part is NOT working. I'm probably doing something stupid - I havnt programmed ASM since 2005 and that was for ARM9 and minimal (similar situation to this, C programming for GP2X handheld with some ASM hardware access for co-processor) - also having nearly every tutorial in the world assume ASM-ONE syntax and being stuck with GAS isnt helping. Anyway! My C code: Code:
#include <stdio.h> Code:
|gas uses a pipe as a comment symbol? really? no idea where I'm messing up now XD |
I'm knowledgeable about 68k assembler but not the Amiga hardware so no comment about what you are trying to do there. I do see 2 major problems though. You can not assume a register (D5) is preserved from one function to the next. You should change the 2x "move.b" in mouseclick() to "moveq" so the whole 32 bit int return value is affected. You can and should remove the second "br done". Many assembler programmers on here don't know or like the MIT format and are unlikely to help because of it.
|
Oh dear, guess I'm on the wrong side of the fence! I'll try and get a workflow with vasm working :(
Really appreciate the advice thou! I will remove the br and swap to moveq for the click test :D I had same thought about the d5 reg (even commented it :P) and so added the getinterrupt function so I could save it off in a c variable instead of a register and modified restoresystem to take a parameter (d0) instead. Still didn't fix it thou :/ |
Ah! I'm at work and looking over this code during a break and I think I've spotted my problem! I dont specify a register for the parameter in my c code so I suspect my parameter is only present on the stack. I guess the stack is the proper place to read params from anyway... I'll investigate after work xD
|
Quote:
|
Ok, example for calling from to C to asm and parameters passing.
main.c Code:
#include <stdio.h> Code:
.global _regadd It's all in the prototyping in the C code. Also, be carefull when you hit the hardware for the "width". If the hardware manual says the register is byte, specify .b. .w for word. Don't use generic move 0xhardware,d0 like that. You have to specify the length of the move. |
matthey and alkis - thankyou both very much :D My program now works!
I store INTERA in an int at the start of the program and then disable the system. I start my loop, poll the hardware for a mouse click and when detected I end the loop, restore the INTERA value and end the program. It sounds so feable but I'm genuinely super excited I got my own code including asm hardware access compiling and working XD I've used a register for restoring INTERA atm but I may switch to the stack to try and make that a habbit for compiler independence. Incidently the true cause of my hang/failing to restore was actually in the C code, the getchar() call. If you try to getchar() whilst the sytem is disabled you get stuck forever XD moving getchar() to under restoresystem(INTERA); brought everything to life :D Now to see if I can take over the display and start doing something graphical full screen.. watch this space for more of me crying into my beer begging for help from someone who knows what they are doing :P |
and I already have a question haha.. I actually ran into this last night but forgot until now. Alkis you wrote perfect GAS compliant asm for amiga just then so maybe you know the answer to this one :P
how can I declare hunk type's using gas? I need to position my copper list in chip ram. In the hardware programming guide on youtube I was following it was: SECTION some_name,DATA_CHIP (or DATA_FAST, DATA_PUBLIC, etc). Looking online for the GAS documentation I've discovered I can declare sections with .section and set a name and a type like d for data or c for code but i have NO clue how to cause the equivalent of _CHIP or _FAST with their syntax :/ |
I don't think that's supported in the later versions of gcc.
As you can read here http://cahirwpz.users.sourceforge.ne...gaos/chip.html it should be .datachip but I get: funcs.s:12: Error: unknown pseudo-op: `.datachip' (from m68k-amigaos-gcc (GCC) 3.4.0 / GNU assembler 2.14) If you are gonna play more with assembly and less with C you should really switch to vasm as Matthey already suggested. If however you insist on C/asm, have a look and steal a technique or two from here f.ex. https://github.com/astrofra/amiga-ex.../fx_routines.c |
Quote:
I'd use VASM to compile the ASM and then link it to the AmiDevCpp project as an include (object). |
Quote:
Bebbo's version allows and supports ".datachip" (v6) Code:
Code:
.datachip Code:
which is buggy (the label is shifted by 1 byte...) so maybe there are some issues but at least the data is in chipmem all right. Note: using ".word" syntax or 1 "dc" per data doesn't fix the bug. |
All times are GMT +2. The time now is 04:23. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.