|
Post by nathan999 on Jul 16, 2015 7:22:01 GMT -5
The problem is that, prior to calling a FUNCTION which uses parameters, the compiler generates a subroutine call to deal with such parameters. That subroutine is compiled at the beginning of the main binary, it seems, just before your program starts.
The problem is that the subroutine is called with the instruction "bsr allign_heap2" - and such bsr only performs a 16 bits jump, meaning that it only can jump roughly 32K back or forward.
If the code where you call the subroutine with parameters (which originates a "bsr allign_heap2") is more than 32K ahead of where allign_heap2 is located, bsr cannot reach it so the assembler fails.
It's a very, very simple bug which would be really easy to solve if the BEX sources were available, but alas, they aren't. So what you can do is make sure that every FUNCTION call with parameters is close to the top of your program. Which can be impossible to achieve with big/complex programs.
Another solution (a PITA) would be configuring BasiEgaXorz to output the assembly, manually (or automaticly, using proper find&replace from a command line tool) editing the assembly listing to replace the relative jumps for full-range jumps, and using ASMX to assemble the result.
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Jul 16, 2015 7:45:37 GMT -5
Another possible ( slightly ugly ) workaround is to "convert" functions ( that need to be called from outside the 32K range ) into subroutines. For example, instead of .. x = add(1,2) print x
declare function add(a as integer, b as integer) as integer return a+b end function .. you could go with .. global result as integer add 1,2 x = result print x
declare sub add(a as integer, b as integer) result = a+b exit sub end sub .. or for instance .. add 1,2,varptr&(x) print x
declare sub add(a as integer, b as integer, p& as long) pokeint p&,a+b exit sub end sub But in most cases it's simply a matter of reorganizing your code a bit
|
|
|
Post by jessicasmith on Jul 16, 2015 21:06:59 GMT -5
I stripped my code first, making all variables globals and thus elliminating tons of parameter passing. People can try game happy wheels
|
|
|
Post by riper on Jul 17, 2015 3:44:06 GMT -5
Another solution (a PITA) would be configuring BasiEgaXorz to output the assembly, manually (or automaticly, using proper find&replace from a command line tool) editing the assembly listing to replace the relative jumps for full-range jumps, and using ASMX to assemble the result. Thank you for the comments nathan999I have changed the options on BEX and now I have the .asm code. What do I have to search for on it? And with what instruction should I change it? Thx. @titan , thank you for your examples. I know that the best option would be to improve my coding style but I can't (i have not enough experience, I haven't seen a full code example to learn from and for sure i'm not skilled enough). That's why at my eyes my code is not too bad at all (because it works). These last days I've tried to go around my problem but I have not been able fix it, so now I'm dealing with SGDK trying to port my code there. Maybe I'm not going to have this kind of limitations (maybe others, who knows) but again I have to learn how to do everything. Thanks.
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Jul 17, 2015 4:10:44 GMT -5
These last days I've tried to go around my problem but I have not been able fix it, so now I'm dealing with SGDK trying to port my code there. Alright, good luck moving to SGDK. In case you need any help .. make sure to check out the forum on SpritesMind
|
|
|
Post by nathan999 on Jul 17, 2015 4:14:26 GMT -5
I'm not a 68000 coder, sadly. I can understand a bit of it an generally know what's on.
You have to find "bsr allign_heap2" (that's the piece of code the assembler is complaining about) which is a relative jump, and replace it with an absolute jump, that is, "jsr allign_heap2"...
But I can't guarantee that will work as I'm no 68000 coder. Anybody?
|
|
|
Post by riper on Jul 17, 2015 5:12:11 GMT -5
@titan I made a very small and ugly ASCII Pong using SGDK: Pseudo-PONG
But of course I prefer to stay on BEX over SGDK. nathan999Thanks! I'll try to change all "bsr allign_heap2" by "jsr allign_heap2" and try to compile it using ASMX
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Jul 17, 2015 6:19:32 GMT -5
But I can't guarantee that will work as I'm no 68000 coder. Correct, simply change to JSR. Read this for more information. By the way. the reason why BEX compiles to just BSR instead of BSR.S or BSR.W is because the assembler automatically selects the required size. Unfortunately BSR.L isn't supported on the 68000 ( only on 68020/30/40 ) .. as you already know
|
|
|
Post by riper on Jul 18, 2015 16:09:36 GMT -5
Of course I agree with Titan: is much better to improve the code (and learn how) than do dirty tricks. But I have not enough experience and knowledge to do that. That's because I want to try the "dark side". I have that "BEX extractor" software and it give me 5 files: - basic.s - basicasm.cni - basicdat.s - basicstr.s - basicvi.s I have changed all the bsr by jsr on the basic.s Now I'm trying to compile the code using ASMX but I get some errors on the compilation process. The method that I'm using to compile the files is: ASMX.EXE -e -b -C 68000 -- basic.sHere an screenshot of the process and the error: Am I using wrong options on the compilation process? Anyone knows the way to compile the sources using ASMX? I have to say that a basic.bin file is generated during this erroneous process, but it's not possible to open it on Fusion. Well, you can open it, but it doesn't work. The erronious .bin file (manually generated by ASMX) and the working .bin (generated by BEX) have the same size, but the first one doesn't work. (I think that the "Checksum Incorrect" happens even with my BEX working compilations). Ideas? Thank you a lot.
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Jul 19, 2015 15:25:49 GMT -5
I shouldn't be helping you with this ( as i recommended you not to take this route ) .. but you need to change line 18-20 of basicasm.cni into the following ..
|
|
|
Post by riper on Jul 19, 2015 16:52:46 GMT -5
Thank you @titan , but once again you win. I give up that crazy method. I'm going to forget that project and start doing smaller things. See you.
|
|
|
Post by landeel on Oct 10, 2015 13:37:45 GMT -5
My code got about 70 KB, and I started getting this errors. This is what I discovered: This is bad: if map(enemyx(e), enemyy(e))=0 then blah
This is ok: ex=enemyx(e) ey=enemyy(e) if map(ex,ey)=0 then blah
It seems you can't use array elements to index other arrays. After this change, code compiles again.
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Oct 10, 2015 13:52:53 GMT -5
It seems you can't use array elements to index other arrays. You can ( proof below ), something else must be amiss. dim map(3,3) as integer dim enemy_x(7) as integer dim enemy_y(7) as integer map(1,2) = 1 enemy_x(e) = 1 enemy_y(e) = 2 if map(enemy_x(e),enemy_y(e)) then print "yay!" endif Using a 2D array as interface to a map is a terrible idea though ( even when you need a dynamic / procedural map in RAM ).
|
|
|
Post by landeel on Oct 10, 2015 15:17:18 GMT -5
I know it's supposed to work, and to a certain point it does. But when the program gets bigger and you use it a lot, it starts giving the "allign_heap2" errors. Just like nesting subs and functions with parameters.
Really? My map is very dynamic. What should I do instead? I still have time to change it, it wouldn't be hard.
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Oct 10, 2015 15:24:45 GMT -5
I know it's supposed to work, and to a certain point it does. But when you use it a lot, it starts giving the "allign_heap2" errors. Just like nesting subs and functions with parameters. Reading / writing to a array doesn't generate any allign_heap2 calls .. Really? My map is very dynamic. What should I do instead? I still have time to change it, it wouldn't be hard. What kind of game are you working on that you can't use ROM? In any case, you should use READ and / or the dataptr& instead.
|
|