SDCC DivuInt
when I divide an integer
sdcc wants to import a function called divuint
I think it used to be in z80.lib but now it doesnt seem to be in there.
Im looking in
usr/local/share/sdcc/lib/src/z80
and it has divusigned.a
but no divuint
sdcc wants to import a function called divuint
I think it used to be in z80.lib but now it doesnt seem to be in there.
Im looking in
usr/local/share/sdcc/lib/src/z80
and it has divusigned.a
but no divuint
Post edited by slenkar on
Comments
My copy of sdcc/device/lib/divunsigned.s is exporting two symbols:
.globl __divuint
.globl __divuchar
You can see if that symbol is defined inside z80.lib by running the archive program on it (you may have to look that up in the manual as I don't know what it is on sdcc offhand). I think the library format is plain text so maybe a search in a text editor will see if the definition is there too (as opposed to a call).
Write games in C using Z88DK and SP1
I am including z80.lib in the build but I still get the error for some reason
could you take a look at my makefile to see if Im doing anything wrong please?
You don't have to include anything -- I think the "-mz80" will cause the z80.lib to be linked against.
The "-I" are for specifying include paths -- I assume you know what you are doing there. Other than that, I don't see a crt file. It needs to be the first file on this compile line because it sets up the memory map. I'm not sure if that would cause a symbol not found error.
Write games in C using Z88DK and SP1
I put the whole file path of the crt0.rel file in the command line but still get the same errors. I am using the latest version, so I could try downgrading
I compiled divuint.c myself and included it, and the game compiled.
It resets the spectrum though.
I put this in my main function at the beginning:
__asm
LD SP,#50000
__endasm;
but it doesnt make any difference
EDIT-
ok after putting this in the compilation:
--no-std-crt0
it actually works but the stack is still at 29969, 31 bytes behind the code
it still crashes after a few pathfinds, i dont know why doing a pathfind a certain number of times would cause the stack to grow,
if the pathfind function was too much for the stack it would crash on its first use surely
You can't put it in main as the first thing main will do is create a stack frame before your inline asm runs. It should be done in your crt file.
Without seeing your source it's hard to say exactly what is going on. You could open up a debugger screen in your emulator after loading the binary and have a look at the asm that was generated, at least the beginning to see what is going on with sp.
The stack grows down so that may not be a problem.
Maybe. Have you tried compiling with "--reserve-regs-iy" for all your files? I'm wondering if you still have the basic isr running, which uses iy. sdcc may use iy if you don't have that flag set.
The "-I" option is also for the include path (ie looking for header files) -- I don't know if you meant "-L" which is for library search path.
Write games in C using Z88DK and SP1
my machine code functions use iy so I dont know if that is the reason?
-L lib didnt work,
I remember that when I used to use SDCC in the past i set interupt mode to 1.
I put IM 1 in the main function and the stack actually appeared close to 50000
It still crashes after a few pathfinds though
I haven't seen sdcc use iy very often unless the optimization level is turned up. With "--max-allocs-per-node 200000" it always uses iy. But it expects both ix and iy to be unchanged. The rom isr is troublesome because it will poke values into the system vars area (iy+?) and sdcc will often have iy pointing into the stack so the rom isr will corrupt the stack. Incidentally, this will also happen if your m/c is using iy and maybe this is the problem. You'll have to provide your own isr or disable interrupts. Try a "di" in your main and see if you get further.
If you have the rom isr running you will have to use "--reserve-regs-iy" for all the sdcc compiles. If your m/c is using iy it isn't compatible with the rom isr.
You might have to specify full path. Maybe "./lib"?
Write games in C using Z88DK and SP1