ML routine

ML routine

Post by Russ Gilber » Tue, 25 Mar 2003 07:13:02



I wrote a ml routine to replace one I have in BASIC
to print characters to a graphics 7 screen.
It is too big, about 380 bytes.  The problem there
is that I wanted to put the ml routine in a BASIC
string, I like to do that and let BASIC handle the
memory.  My asm routine isn't relocatable, because
I had to use a JMP instead of a BNE/BEQ.  BNEs
can only go 128 bytes up or down.  In addition,
I had a multiply routine to JSR to, that also requires
a non-relocatable address.  The JSR can be replace
by putting the multiply in-line the two times I call it.
Other than trying to make more efficient code, I'll have
to either make the main loop in BASIC or use the
poke 106(peek(106)-2) and reserve a specific
memory area.  Anybody got some suggestions for
reserving memory?  Mapping says I'd have to
use a minimum of 4K using the 106.  At this point
I only have about 7k left, I'd rather do something
using less memory.
 
 
 

ML routine

Post by Le » Tue, 25 Mar 2003 17:20:00



> I wrote a ml routine to replace one I have in BASIC
> to print characters to a graphics 7 screen.
> It is too big, about 380 bytes.  The problem there
> is that I wanted to put the ml routine in a BASIC
> string, I like to do that and let BASIC handle the
> memory.  My asm routine isn't relocatable, because
> I had to use a JMP instead of a BNE/BEQ.  BNEs
> can only go 128 bytes up or down.  In addition,
> I had a multiply routine to JSR to, that also requires
> a non-relocatable address.  The JSR can be replace
> by putting the multiply in-line the two times I call it.
> Other than trying to make more efficient code, I'll have
> to either make the main loop in BASIC or use the
> poke 106(peek(106)-2) and reserve a specific
> memory area.  Anybody got some suggestions for
> reserving memory?  Mapping says I'd have to
> use a minimum of 4K using the 106.  At this point
> I only have about 7k left, I'd rather do something
> using less memory.

As a cheat you can do multiple Branches on down to the final
Jump location you wanted to get to.  But I don't know how many
it would take for your code string, or if there are convenient
places to add the extra Branch instructions.  Basic is not my
strong suit, sorry no advise there.

 
 
 

ML routine

Post by Carsten Strotman » Tue, 25 Mar 2003 21:25:48



> I wrote a ml routine to replace one I have in BASIC
> to print characters to a graphics 7 screen.
> It is too big, about 380 bytes.  The problem there
> is that I wanted to put the ml routine in a BASIC
> string, I like to do that and let BASIC handle the
> memory.  My asm routine isn't relocatable, because
> I had to use a JMP instead of a BNE/BEQ.  BNEs

On
http://www.strotmann.de/twiki/bin/view/APG/AsmTips
you can find some ASM tips how to write relocateable JMP and JSR.

Quote:> can only go 128 bytes up or down.  In addition,

Regards

Carsten

 
 
 

ML routine

Post by Russ Gilber » Tue, 25 Mar 2003 23:36:58


Thanks, Lee and Carston.
I'm going to be away from my computer a few days,
so I won't be responding.
Thanks, Again
 
 
 

ML routine

Post by Ron Hamilto » Wed, 26 Mar 2003 04:35:52


Hi, Russ;
Are page 6 and the cassette buffer in use? Between them you have about 387
fixed location bytes available.

Can you make it relocatable with a double branch like:
  BNE STEP1
code continues up to 120 bytes
  CLV ;configure for branch around
  BVC SKIP ;go around intermediate stepping stone
STEP1 BNE FINAL ;go to actual destination
SKIP go on with flow of code
Overflow flag is rarely used and will not affect others in your logic plus
you only reach STEP1 from that original branch. This is very doable for a
single long branch or two and difficulty increases with more.

Another possibility is a small jump table in page 6 or bottom of the page 1
stack. Whenever you USR(ADR(ML$)) the address of ML$ will be in $D4-5 so you
could start ML$ with:
START *=$4000
  LDA $D4
  CLC
  ADC (DESTN-START)&$FF ;lo byte
  STA $100
  LDA $D5
  ADC (DESTN-START)/256 ;hi byte
  STA $101
  PLA ;your original code continues
The stack rarely gets that low and your assembler computes the offsets so
simply replace JMP DESTN with JMP($0100); just remember to include the $4C
when you construct a JSR $0102. Your table can also go in the $480-5FF range
since it is initialized with each call avoiding damage by floating point use
and string input to that area.

--
Ron

http://www.atariland.com/members/oldatarian
and mirror
http://www.powow.com/oldatarian


> I wrote a ml routine to replace one I have in BASIC
> to print characters to a graphics 7 screen.
> It is too big, about 380 bytes.  The problem there
> is that I wanted to put the ml routine in a BASIC
> string, I like to do that and let BASIC handle the
> memory.  My asm routine isn't relocatable, because
> I had to use a JMP instead of a BNE/BEQ.  BNEs
> can only go 128 bytes up or down.  In addition,
> I had a multiply routine to JSR to, that also requires
> a non-relocatable address.  The JSR can be replace
> by putting the multiply in-line the two times I call it.
> Other than trying to make more efficient code, I'll have
> to either make the main loop in BASIC or use the
> poke 106(peek(106)-2) and reserve a specific
> memory area.  Anybody got some suggestions for
> reserving memory?  Mapping says I'd have to
> use a minimum of 4K using the 106.  At this point
> I only have about 7k left, I'd rather do something
> using less memory.

 
 
 

ML routine

Post by Russ Gilber » Mon, 31 Mar 2003 02:30:05


I'm back.
Ron has some suggestions, some sort of indirection.
I do have other routines using page 6.
And I'm using most available $CB-$D1.  I didn't
know $D4-$D5 holds the ADR(ML$), or you say
I put it there?  I don't understand the ADC (DEST-START)&#FF, dind't know
ASMED would do
that sort of stuff.
The BVC idea I sorta thought of doing multiple
branches to reach up the code.
I think I have one more page 0 location to do indirect
JMP and I might do that.
Thanks
 
 
 

ML routine

Post by Ron Hamilto » Tue, 01 Apr 2003 10:39:19


Hi Russ;

Basic puts the USR( ) destination in $D4-5 as a consequence of doing FP math
to evaluate the first argument.

Yes, Asmed will do simple math on parameters; not certain if it uses the
parentheses grouping or just L-->R expansion.

The BVC would need only 3 steps in 384 byte code and both forward and back
code can be in them:

    CMP ARGUMENT
    BNE LATER_ONE
...
    CLV
    BVC AROUND
LATER_ONE BNE LATER_TWO
GOING_BACK BMI EARLIER
AROUND LDA CODE...

Btw, indirect JMP( ) uses a 2-byte argument and does not need zero page.

--
Ron

http://www.atariland.com/members/oldatarian
and mirror
http://www.powow.com/oldatarian

Quote:> I'm back.
> Ron has some suggestions, some sort of indirection.
> I do have other routines using page 6.
> And I'm using most available $CB-$D1.  I didn't
> know $D4-$D5 holds the ADR(ML$), or you say
> I put it there?  I don't understand the ADC (DEST-START)&#FF, dind't know
> ASMED would do
> that sort of stuff.
> The BVC idea I sorta thought of doing multiple
> branches to reach up the code.
> I think I have one more page 0 location to do indirect
> JMP and I might do that.
> Thanks

 
 
 

ML routine

Post by Russ Gilber » Tue, 01 Apr 2003 11:51:33


Hi, Ron, everbody.
Ok, indirect jump doesn't need page 0.
I understand that better than the multiple branches.
All I have to do is pass adr ML$ with the usr call
and PLA HI, STA some $6xx, PLA LO, STA.
and then ADC the offset to my loop beginning.
I have ml code scribbled on yellow sheets of paper.
And I have written in asmeditor and asmed it ok.
Not the JMP ($6xx) code yet, just the adds and
multiplies and the STAs to screen memory and
reads from the ROM char set, that get poked.
It's a fairly fun game for the non-joystick jockey, just
a simple dice game.
Thanks
 
 
 

ML routine

Post by Ron Hamilto » Wed, 02 Apr 2003 06:40:10


You don't even need to pass the ML$ address as executing:
X=USR(ADR(ML$),XPOS,YPOS)
puts XPOS & YPOS on the stack and leaves ADR(ML$) in $D4-5 lo-hi. Apparently
Basic evaluates the arguments in reverse order since the last is on the
bottom and the first is on top just below that 'number of parameters' byte;
the execution address is done last and is left in the FP register - a little
serendipity. You *could* also pass it as a separate argument if you wear
both suspenders (braces) and a belt...

--
Ron

http://www.atariland.com/members/oldatarian
and mirror
http://www.powow.com/oldatarian


> Hi, Ron, everbody.
> Ok, indirect jump doesn't need page 0.
> I understand that better than the multiple branches.
> All I have to do is pass adr ML$ with the usr call
> and PLA HI, STA some $6xx, PLA LO, STA.
> and then ADC the offset to my loop beginning.
> I have ml code scribbled on yellow sheets of paper.
> And I have written in asmeditor and asmed it ok.
> Not the JMP ($6xx) code yet, just the adds and
> multiplies and the STAs to screen memory and
> reads from the ROM char set, that get poked.
> It's a fairly fun game for the non-joystick jockey, just
> a simple dice game.
> Thanks

 
 
 

ML routine

Post by Russ Gilber » Wed, 02 Apr 2003 11:04:11


Uhm. Actually I do wear both suspenders and a belt.:)
Over 50, things start bulging in places and other places
shrink.  Gravity takes over and the bottom goes
down and the top goes up, leaving a wedge of open
space inbetween.  The suspenders are too weak to
actually hold up the pants by themselves, and the belt
doesn't seem to keep my shirt from coming out in
front.
But I ramble
Russg
 
 
 

ML routine

Post by Russ Gilber » Wed, 02 Apr 2003 11:09:34


Uhm. My call will look something like this.
X=USR(ADR(ML$),ADR(TXT$),LEN(TXT$),COL,ROW, and maybe ADR(ML$) again if
I don't get that address from $D4.
The usr call will replace a BASIC subroutine, pass
the string, col and row.
Russg
 
 
 

1. How do I protect an ML routine in BASIC if the routine isn't mine?

Howdy folks

I've stumbled onto a problem while trying to debug CD Audio Player (CDAP).

CDAP is getting so close to the ASPI manager in memory, that TurboBASIC
overwrites part of the manager.  How do I protect the manager if I can not
change the location or format of the manager.

(I just sent Matthias a message to ask him if it is possible to relocate the
manager)

I could stuff the ML code into a BASIC string, but I want to use the manager
as is and no create a version that is 'BASIC only'.

I looked into declaring a string around the manager (from $8000 to $8800),
but (Turbo)BASIC keeps moving these string in memory.

Please help.

CU                            Mathy van Nisselroy

--
---
My old email address will cease to exist as of the end of 2001, please use
my new address.
Meine alte Emailadresse wird Ende 2001 geloescht, bitte benutzen Sie meine
neue Adresse.
Mijn oude Emailadress wordt eind 2001 opgeheven,  gebruikt aub vanaf nu mijn
nieuwe adres.

http://www-users.rwth-aachen.de/mathy.van_nisselroy

2. Thx Herbert and Will! Prob. solved in "How to put a long equation in twocolumn format"

3. The ultimate Player move ML routine

4. TCM320AC37

5. My first ML routine for Atari Basic

6. Gray pop-up advertisements

7. ML Plot routines

8. ** AVAILABLE ** Oracle/DB2/Unix/SQL/C Consultants

9. Hey I found a ML move routine...written by ME!

10. Making your unrelocateable ML code relocateable

11. ML Assemblers

12. Run BASIC from ML

13. Needing ML (Meta Language) for the ST.