[TI ASM] calling program w/o SMC?

Got questions? Got answers? Go here for both.

Moderator: MaxCoderz Staff

Post Reply
King Harold
Calc King
Posts: 1513
Joined: Sat 05 Aug, 2006 7:22 am

[TI ASM] calling program w/o SMC?

Post by King Harold »

Is it possible to call any program without SMC?
pseudocode:

Code: Select all

bcall(_chkfindsym)
inc de
inc de
call de
however, one can not "call de", i allready managed to do this with SMC, but can it be done without it? I haven't found a way yet..
User avatar
KermMartian
Calc Wizard
Posts: 549
Joined: Tue 05 Jul, 2005 11:28 pm
Contact:

Post by KermMartian »

Code: Select all

bcall(_chkfindsym)
  inc de
  inc de 
  ex de,hl
  ld de,return
  push de
  jp (hl)
Return:
...etc...
Image Image Image
CoBB
MCF Legend
Posts: 1601
Joined: Mon 20 Dec, 2004 8:45 am
Location: Budapest, Absurdistan
Contact:

Post by CoBB »

You can substitute a call with a push and a jump. This is 'call de':

Code: Select all

ex de,hl
ld de,return_address
push de
jp (hl)
return_address:
EDIT: Kerm was faster. :)
Spencer
Extreme Poster
Posts: 346
Joined: Mon 17 Jan, 2005 8:56 am
Location: Indiana

Post by Spencer »

Why does everyone do the push? If you're returning right after the call ...

Code: Select all

 ex de,hl
 call call_hl
return:

...
call_hl:
 jp (hl)
King Harold
Calc King
Posts: 1513
Joined: Sat 05 Aug, 2006 7:22 am

Post by King Harold »

ok thanx guys
(I should have thought of this myself.. silly me..)

but one could do this:

Code: Select all

bcall(_chkfindsym)
inc de
inc de
call call_de
;after execution of the called program it will return HERE
...
...
call_de:
push de
ret
cant you?
(i should have thought of this before posting..)
CoBB
MCF Legend
Posts: 1601
Joined: Mon 20 Dec, 2004 8:45 am
Location: Budapest, Absurdistan
Contact:

Post by CoBB »

Spencer wrote:Why does everyone do the push? If you're returning right after the call ...
Well, if you wrap it into a call, that's basically pushing. No-one said there would be a return immediately afterwards.

Using push de \ ret is basically the same as ex de,hl \ jp (hl), except that it has a different side-effect: it destroys a word in memory instead of swapping two registers. Also, it's slower because of this memory access. But you can use it, yes.
King Harold
Calc King
Posts: 1513
Joined: Sat 05 Aug, 2006 7:22 am

Post by King Harold »

It's easier to understand to me, i'll just experiment a bit with it and see what happens (and im not repeatedly calling a program so those 3 or 4 extra T-states dont really matter anyway)
User avatar
KermMartian
Calc Wizard
Posts: 549
Joined: Tue 05 Jul, 2005 11:28 pm
Contact:

Post by KermMartian »

Also, keep in mind that you just can't "call" any old regular ASM program. You have to copy or move its code to $9d95 so that its lds and jps/calls are correctly positioned.
Image Image Image
King Harold
Calc King
Posts: 1513
Joined: Sat 05 Aug, 2006 7:22 am

Post by King Harold »

ofcourse, the labels would be messed up, but all relative jumps should be fine, and loading anything else then a label's pointer..
but it shouldnt be a problem..
could i just copy it to the end of the calling program?
(ofcourse with a different progstart, namely the end of the calling program +1)
CoBB
MCF Legend
Posts: 1601
Joined: Mon 20 Dec, 2004 8:45 am
Location: Budapest, Absurdistan
Contact:

Post by CoBB »

King Harold wrote:could i just copy it to the end of the calling program?
(ofcourse with a different progstart, namely the end of the calling program +1)
Moving around files is a tricky business. As long as the routine in question doesn't rely on TIOS variables in any way, you can get away with swapping it into that place and swapping back after it finished running. But if it is supposed to run from a specific location, and you don't want to assemble it together with the main program for some reason, using a saferam area (e.g. savesscreen) is a better idea, because it doesn't mess up user memory.
User avatar
Dwedit
Maxcoderz Staff
Posts: 579
Joined: Wed 15 Dec, 2004 6:06 am
Location: Chicago!
Contact:

Post by Dwedit »

Moving files around isn't that hard, Venus does it really quickly, and CrunchyOS does it. Venus does it in the best way I've ever seen, it even uses an undocumented TIOS romcall to speed things up.
You know your hexadecimal output routine is broken when it displays the character 'G'.
King Harold
Calc King
Posts: 1513
Joined: Sat 05 Aug, 2006 7:22 am

Post by King Harold »

which rom call might that be? and what does it do?
User avatar
KermMartian
Calc Wizard
Posts: 549
Joined: Tue 05 Jul, 2005 11:28 pm
Contact:

Post by KermMartian »

Ah yes, Doors CS also does file moving. All shells with Ion support have to, actually...
Image Image Image
Post Reply