Author |
Message |
|
cjgone Aw3s0m3
Active Member
Joined: 24 May 2006 Posts: 693
|
Posted: 05 Aug 2008 05:04:40 pm Post subject: |
|
|
Code: .NOLIST
#define EQU .equ
#define equ .equ
#define END .end
#define end .end
#include "ti83plus.inc"
.LIST
.org 9D93h
.db $BB,$6D
ld hl,_start
ld de,$86EC
ld bc,_end - _start
ldir
Call $86EC
ret
.org 86ECh
_start:
ld b,2
_loop:
push bc
B_CALL(_NEWLINE)
ld hl,txt
B_CALL(_PutS)
pop bc
djnz _loop
ret
_end:
txt:
.db "YO WADDDUP!",0
.end
end
Why can't I have 2 .org statements???
Wtf, I don't get it.. Is their some lame reason why I can't do that for an easy address patch or something??? |
|
Back to top |
|
|
Liazon title goes here
Bandwidth Hog
Joined: 01 Nov 2005 Posts: 2007
|
Posted: 05 Aug 2008 05:13:14 pm Post subject: |
|
|
which assembler are you using? iirc, they all do the same thing in a different way.
spasm has a macro called relocate(), but spencer told me that .org is better. |
|
Back to top |
|
|
cjgone Aw3s0m3
Active Member
Joined: 24 May 2006 Posts: 693
|
Posted: 05 Aug 2008 05:38:39 pm Post subject: |
|
|
I use TASM. |
|
Back to top |
|
|
Liazon title goes here
Bandwidth Hog
Joined: 01 Nov 2005 Posts: 2007
|
Posted: 05 Aug 2008 05:49:26 pm Post subject: |
|
|
that's probably why. not sure, but iirc TASM does something stupid like insert X bytes of padding until you reach where you're second .org is. not possible if you're new .org comes before the previous one.
does it not assemble? or does it just not output what you want?
Last edited by Guest on 05 Aug 2008 05:50:28 pm; edited 1 time in total |
|
Back to top |
|
|
DarkerLine ceci n'est pas une |
Super Elite (Last Title)
Joined: 04 Nov 2003 Posts: 8328
|
Posted: 05 Aug 2008 05:54:38 pm Post subject: |
|
|
Instead of using an .org (which you're doing improperly anyway, and as a result _start would equal 86ECh), add 86ECh-_start to every absolute address in the code that gets moved.
Here, you would replace ld hl, txt with ld hl, txt+86ECh-_start.
Note that you don't need to change the labels for jr and djnz: since those use relative jumps, they're going to work fine when you move the code somewhere else in any case.
Finally, put the _end label after the text data, since you need to include that with the code to display the text.
Last edited by Guest on 30 Jul 2010 05:08:11 am; edited 1 time in total |
|
Back to top |
|
|
cjgone Aw3s0m3
Active Member
Joined: 24 May 2006 Posts: 693
|
Posted: 05 Aug 2008 06:23:47 pm Post subject: |
|
|
I'm doing this for 'C' compiler... I can't do that to labels. I need to patch the whole jump.
So .org ain't gonna be working? |
|
Back to top |
|
|
Spencer
Advanced Newbie
Joined: 06 Nov 2005 Posts: 99
|
Posted: 05 Aug 2008 06:50:05 pm Post subject: |
|
|
For some reason TASM and brass write bytes with .org, I don't believe that is useful or correct.
If you want to write a program that relocates code, simply use SPASM or one of brass's special directives for relocation. |
|
Back to top |
|
|
cjgone Aw3s0m3
Active Member
Joined: 24 May 2006 Posts: 693
|
Posted: 05 Aug 2008 06:57:00 pm Post subject: |
|
|
Any way I can somehow do that for the "C" compiler?
Code: void function(void)
{
//crap here
// relocate meh please cuz I have no control over how the compiler does jumps
}
|
|
Back to top |
|
|
Liazon title goes here
Bandwidth Hog
Joined: 01 Nov 2005 Posts: 2007
|
Posted: 05 Aug 2008 07:28:58 pm Post subject: |
|
|
are you writing a C compiler this time? or are you trying to modify the output from the C compiler?
either Darkerline's or Spencer's method should work. either manually edit absolute addresses or find something in SPASM/BRASS to do it for you. i think that should do what you're asking for. |
|
Back to top |
|
|
cjgone Aw3s0m3
Active Member
Joined: 24 May 2006 Posts: 693
|
Posted: 05 Aug 2008 08:43:44 pm Post subject: |
|
|
I'm using the z88dk C compiler but the code created is huge so over flows of the 8k limit which I need to surpass by label patching, so I hoped there would be an easy way to patch the code via assembly in the C mix. |
|
Back to top |
|
|
DarkerLine ceci n'est pas une |
Super Elite (Last Title)
Joined: 04 Nov 2003 Posts: 8328
|
Posted: 05 Aug 2008 08:51:41 pm Post subject: |
|
|
Maybe it's possible to move code directly in C - with function pointers and such. I wouldn't know any exact syntax (haven't worked with C in years) and in any case the compiler in question might not support it, but it's worth a try.
Make sure all the data is at the end of the file first, though, otherwise you might solve the issue by moving the data there.
Last edited by Guest on 05 Aug 2008 08:52:48 pm; edited 1 time in total |
|
Back to top |
|
|
cjgone Aw3s0m3
Active Member
Joined: 24 May 2006 Posts: 693
|
Posted: 05 Aug 2008 09:44:15 pm Post subject: |
|
|
I'm probably going to get the C asm output, use globabl variables and patch the jumps in asm with the adress addition, etc.
I could get pointers to functions but the jumps in the code genereated by the compiler would not be patched. I think what i wrote above should work cuz i'm totally sick of writing in assembly.
Last edited by Guest on 05 Aug 2008 09:44:31 pm; edited 1 time in total |
|
Back to top |
|
|
benryves
Active Member
Joined: 23 Feb 2006 Posts: 564
|
Posted: 06 Aug 2008 06:09:03 am Post subject: |
|
|
Spencer wrote: For some reason TASM and brass write bytes with .org, I don't believe that is useful or correct. I was originally aiming for backwards compatibility with TASM, but this behaviour has been changed ("fixed"? ) in Brass 3. .org sets both program counter and output counter to the same value, though, so you're better off modifying $ directly for relocation. |
|
Back to top |
|
|
Liazon title goes here
Bandwidth Hog
Joined: 01 Nov 2005 Posts: 2007
|
Posted: 06 Aug 2008 05:57:48 pm Post subject: |
|
|
nice! good to hear some news on brass 3 |
|
Back to top |
|
|
|