mnelson@ihlpg.ATT.COM (Nelson) (06/09/88)
I am writing a program that uses a ML routine at $C000. I know I have seen programs that use LOAD statments to load other parts of the program and then jumps off to them (boot programs, etc). However, when I have the program try to load the ML routine it seems to loop on that line, ei. it LED on the drive keeps going on and off. The program is loaded because if I break and type in a RUN at the next line the program will work fine. The code looks like this: 10 LOAD "ML PROG AT $C000",8,1 20 POKE THE CIA REGS 30 OTHER BASIC STUFF 40 END If I put a PRINT statement at line 20 it will never be hit. Even putting multiple statements on line 10 doesn't work. The extra statements never get hit. Does anyone out there know a trick to get this to work, or do I have to load the ML through DATA statements? Is the $C000 location the problem? Mike Nelson ihnp4!ihlpg!mnelson AT&T Bell Labs
sl144007@silver.bacs.indiana.edu (06/10/88)
Try this: 10 IF A=0 THEN A=1:LOAD "MLPROGNAME",8,1 20 REST OF PROGRAM... I used to know why this is necessary, but its late and I can't remember at the moment. - Robert Schofield {pur-ee,ihnp4!inuxc,rutgers,pyramid}!iuvax!silver!sl144007 sl144007@silver.bacs.indiana.edu (192.12.206.2) sl144007@iubacs.bitnet (forwarded) +----------------------------------------------------------------------+ | The dark ages return! Gog and Magog feast on idols of clay, idols | | of iron! Idols of double-sided double-density soft-sector vinyl! | +----------------------------------------------------------------------+
hackeron@athena.mit.edu (Harris L Gilliam) (06/10/88)
In article <5449@ihlpg.ATT.COM> mnelson@ihlpg.ATT.COM (Nelson) writes: >I am writing a program that uses a ML routine at $C000. I know I have >seen programs that use LOAD statments to load other parts of the >program and then jumps off to them (boot programs, etc). However, >when I have the program try to load the ML routine it seems to loop on >that line, ei. it LED on the drive keeps going on and off. The >program is loaded because if I break and type in a RUN at the next >line the program will work fine. The code looks like this: > > 10 LOAD "ML PROG AT $C000",8,1 > 20 POKE THE CIA REGS > 30 OTHER BASIC STUFF > 40 END > >If I put a PRINT statement at line 20 it will never be hit. Even >putting multiple statements on line 10 doesn't work. The extra >statements never get hit. > >Does anyone out there know a trick to get this to work, or do I have >to load the ML through DATA statements? Is the $C000 location the >problem? > >Mike Nelson >ihnp4!ihlpg!mnelson > >AT&T Bell Labs Hi Mike, I think this will help. The problem is that the Commodore LOAD command when used from within a program causes the program to run again from the beginning without erasing the current variables. This was included so that basic progs could be chained. To solve the problem try this : 10 IF A=0 THEN A=1: LOAD "ML PROG AT $C000",8,1 20 POKE THE CIA REGS 30 OTHER BASIC STUFF 40 END This should work as A will equal 0 when first run then it will be set to 1 so that when the program re-executes the load will be skipped over. Harris | Harris L. Gilliam ()Internet : hackeron@athena.mit.edu | |4 Ames St. Cambridge MA 02139()UUCP {backbone..}!mit-eddie!athena!hackeron| +--------------------------------------------------------------------------+ * There are no bugs, only unrecognized features. *
nfs0294@dsacg1.UUCP (Glendell R. Midkiff) (06/10/88)
From article <5449@ihlpg.ATT.COM>, by mnelson@ihlpg.ATT.COM (Nelson): > I am writing a program that uses a ML routine at $C000. I know I have > seen programs that use LOAD statments to load other parts of the > program and then jumps off to them (boot programs, etc). However, > when I have the program try to load the ML routine it seems to loop on > that line, ei. it LED on the drive keeps going on and off. > Does anyone out there know a trick to get this to work, or do I have > to load the ML through DATA statements? Is the $C000 location the > problem? It has been a while since I did any programming on the C64 but I think I know what your problem is. When you do a LOAD from within a BASIC program, the system begins execution at the beginning after the load so you are looping between the beginning of your program and the LOAD instruction. The fix for this if I remember correctly is to use a switch to control the load. Use something like: 100 IF LOADSW$ = 0 THEN LOADSW$=1: LOAD "PRG",8,1 Like I said, it has been quite a while since I did this so the syntax may need some work, but you get the idea. You do not have to load from data statements, but you must specify the ,1 which will cause the code to be loaded into the same address it was saved from. Hope this helps.... -- |-----------------------------------------------------------------------| |Glen Midkiff cboscd!osu-cis!dsacg1!gmidkiff | | Phone: (614)-238-9643@DLA, Systems Automation Center, Columbus, Oh. | |-----------------------------------------------------------------------|
joe@cbmvax.UUCP (Joe O'Hara) (06/10/88)
In article <5449@ihlpg.ATT.COM> mnelson@ihlpg.ATT.COM (Nelson) writes: >I am writing a program that uses a ML routine at $C000. I know I have >seen programs that use LOAD statments to load other parts of the >program and then jumps off to them (boot programs, etc). However, When the load is complete, your program is essentially restarted. Since your data areas are unaffected by this, the proper way to accomplish your goal is as follows: 5 IF R = 1 THEN 20 (Did I go thru line 10 already?) 6 R = 1 (This is the first time thru) > 10 LOAD "ML PROG AT $C000",8,1 > 20 POKE THE CIA REGS > 30 OTHER BASIC STUFF > 40 END > -- ======================================================================== Joe O'Hara || Comments represent my own opinions, Commodore Electronics Ltd || not my employers. Any similarity to Software QA || to any other opinions, living or dead, || is purely coincidental. ========================================================================
hedley@cbmvax.UUCP (Hedley Davis) (06/10/88)
In article <5449@ihlpg.ATT.COM> mnelson@ihlpg.ATT.COM (Nelson) writes: >I am writing a program that uses a ML routine at $C000. I know I have >seen programs that use LOAD statments to load other parts of the >program and then jumps off to them (boot programs, etc). However, >when I have the program try to load the ML routine it seems to loop on >that line, ei. it LED on the drive keeps going on and off. The >program is loaded because if I break and type in a RUN at the next >line the program will work fine. The code looks like this: > > 10 LOAD "ML PROG AT $C000",8,1 > 20 POKE THE CIA REGS > 30 OTHER BASIC STUFF > 40 END > >If I put a PRINT statement at line 20 it will never be hit. Even >putting multiple statements on line 10 doesn't work. The extra >statements never get hit. > >Does anyone out there know a trick to get this to work, or do I have >to load the ML through DATA statements? Is the $C000 location the >problem? > >Mike Nelson >ihnp4!ihlpg!mnelson > >AT&T Bell Labs Simple problem due to the wonders of Commodore basic. LOAD causes program to restart from beginning. If you didn't load over top of your basic program or its variables or stack ( as is the case with a $c000 load ), you can fix it like this. 10 IF A=0 then A=1: Load "xxx",8,1 The first time through, A=0, so it loads the ML. The second time through, A <> 0, so it skips the load. Hedley
jrg@hpirs.HP.COM (Jeff Glasson) (06/11/88)
The problem is that after BASIC finishes executing the LOAD, it restarts executing the program from the beginning. That's the way BASIC works. You could do something like this: 10 if a=1 then 30 20 a=1: load "foo",8,1 30 rem rest of program..... Jeff Glasson Hewlett-Packard Information Software Division UUCP: {ucbvax,hplabs}!hpda!jrg Internet: jrg@hpirs.HP.COM
mat@emcard.UUCP (Mat Waites) (06/11/88)
In article <5449@ihlpg.ATT.COM> mnelson@ihlpg.ATT.COM (Nelson) writes: >I am writing a program that uses a ML routine at $C000. I know I have ... >line the program will work fine. The code looks like this: > > 10 LOAD "ML PROG AT $C000",8,1 > 20 POKE THE CIA REGS > 30 OTHER BASIC STUFF > 40 END > >If I put a PRINT statement at line 20 it will never be hit. > >Does anyone out there know a trick to get this to work, or do I have >to load the ML through DATA statements? Is the $C000 location the >problem? > >Mike Nelson >ihnp4!ihlpg!mnelson >AT&T Bell Labs The problem is that commodore basic is strange. Every LOAD is treated as if you are loading another basic program. The interpreter runs the basic program in memory from the beginning after the load is finished. Of course, in your case, it is the same basic program as you started with. You need a little kludgeyness to pull it off: 05 IF A = 1 THEN 20 07 A = 1 10 LOAD "ML PROG AT $C000",8,1 20 POKE THE CIA REGS 30 OTHER BASIC STUFF 40 END This way, A is 0 the first time through and the ML is loaded. When your program runs the second time, it skips the load. Mat ps - just get a Power C compiler and give up on basic -- W Mat Waites | PHONE: (404) 727-7197 Emory Univ Cardiac Data Bank | UUCP: ...!gatech!emcard!mat Atlanta, GA 30322 |
jon@csd4.milw.wisc.edu (Jon George Seidl) (06/14/88)
In article <5449@ihlpg.ATT.COM> mnelson@ihlpg.ATT.COM (Nelson) writes: >I am writing a program that uses a ML routine at $C000. I know I have ... lots of stuff that has already been repeated deleted > >Mike Nelson >ihnp4!ihlpg!mnelson > >AT&T Bell Labs Mike just set a new record. Nine (did I miscount?? I get confused when I go to the next hand) duplicate responses to the same question. Amazing. What's really frightening is I almost responded too! We all meant well, didn't we?? Well, you know what they say... "When the answer is well known, only the first response comes from a genius..." The rest just clutter up the network with repetition. B-) Jon --------------- \\ \\ \\ /\ /| /\ /\ University of Wisconsin - Milwaukee \\ \\ \\//\\// //\\//\\ \\//\\ \/ \/ // \/ \| Internet: jon@csd4.milw.wisc.edu = It's more than just an adventure, = Uucp: uwvax!uwmcsd1!uwmcsd4!jon = It's a job! = Bitnet: jon%csd4.milw.wisc.edu@wiscmac3.bitnet