Jump to content
  • 0
CursorKeys

How to use the "S" command in monitor

Question

Hi!

 

I hope I am not repeating and old question, but I am just getting into the X16, and I did search the forums, and found no answer.

 

I am trying the monitor "MON", inside the X16 emulator, to write a rudimentary assembly program. 

However I have issues with the "S" command.

 

I checked the syntax for the save (S) command over here: https://rr.pokefinder.org/rrwiki/images/7/70/Final_Cartridge_III_english_Manual.pdf (search for THE MONITOR [12.0] )

Syntax:  S "<file-name>",xx,yyyy,zzzz            
    xx = device number  01 for tape 08 for disk
    yyyy = the start location of the program
    zzzz = the end location of the program + 1

I tried to save memory location $2000 to $2100 to disk, below are my attempts:

 

Attempt1, assume, device is 8

S "TST",8,2000,2100

fails, output -> S "TST",8,?000,2100 (see the ? sign in the output on the left)

Attempt2, assume, device is 1

S "TST",1,2000,2100

fails, output -> S "TST",1,?000,2100

Attempt3, assume, device is not needed

S "TST",2000,2100

fails, output -> S "TST",20?0,2100

 

So I assume the second param must be the device, as well on the X16, but I am not sure which. Since attempt 3 marked the second param as wrong.

So I tried from 0 up to 9, no differences.

Then I maybe the syntax of the start address is wrong.

 

Attempt4, assume, address starts with $

S "TST",8,$2000,$2100

fails, output -> S "TST",8,?2000,$2100

 

Then I was thinking maybe param nr 3 is a string, so I tried as well, and what about if the addresses are supposed to be "large" addresses, which I tried as well.

No luck so far.  Any help appreciated!

 

Thanks

/C

 

Share this post


Link to post
Share on other sites

5 answers to this question

Recommended Posts

  • 0

I think for the second argument, the device, it needs to be two digits, so

Quote

S "TST",08,2000,2100

However when I try that, I just get "I/O ERROR".  It may be that the monitor save function doesn't work presently.  The last I knew, the monitor was in a buggy state since changes were made with the way banking works in the kernel.

  • Thanks 1

Share this post


Link to post
Share on other sites
  • 0
15 hours ago, Ender said:

I think for the second argument, the device, it needs to be two digits, so

However when I try that, I just get "I/O ERROR".  It may be that the monitor save function doesn't work presently.  The last I knew, the monitor was in a buggy state since changes were made with the way banking works in the kernel.

Ok two chars for the device, that makes sense.  But yes, it also throws I/O ERROR for me.  I tried many device numbers. I guess I have to find some other route in assembly. 

Maybe I'll give cc65 a try.

Thanks!

 

 

Share this post


Link to post
Share on other sites
  • 0

I took a quick look at the monitor source, and it looks like the load/save functionality has been disabled for now like I thought (the fa, sa, etc. variables are all set to $1111).  I think the fixing of it has been a lower priority because it supposedly will get replaced with @mjallison42's assembly environment eventually.  If you want to stick with a native environment, another alternative could be @Ed Minchau's META/L assembly language editor.

 

  • Like 1

Share this post


Link to post
Share on other sites
  • 0

I'd say "forget about the monitor." 

Assemblers like 64TASS are easy to use, and you can assemble a project and launch the emulator with a simple batch file. If you use the -debug switch to launch the emulator, you can actually break into a nice monitor built into the emulator itself. This has the advantage of being able to pick apart the system state from the inside, so to speak, as the emulator can see the internal state of the CPU in a way that SuperMon can't.

My generic build script looks like this:

Quote

 

@echo off

:start
del %1.lst
64tass %1.asm -o %1.prg --list %1.lst
if errorlevel 1 goto fail

choice /m "Start emulator?"
if errorlevel 2 goto end
..\emulator\x16emu -sdcard ..\tom2.vhd -scale 2 -echo -prg %1.prg -debug
goto done

:fail
echo Assembly failed.

:done
cd
choice /m "Try again?"
if errorlevel 2 goto end
goto start

:end
echo END OF LINE

 

While this seems complicated, it actually boils down to two parts. The stuff below :start actually assembles the code (I start the build script with build filename), and the block below that starts the emulator.

The other piece to the puzzle is a copy of 64TASS, which is IMO the easiest to use and most capable 6502 assembler available. It doesn't require any installation or dependencies - you don't need Java or CygWin, and you can just drop a copy into the same directory as your asm files. 

Trust me, after spending half an hour setting up 64TASS the first time, you'll be much happier than trying to assemble in the MONitor. 

  • Like 1

Share this post


Link to post
Share on other sites
  • 0

As @Ender mentioned, the META/L editor could help you do this.  If you're in META/L, you can GOTO 2000 and enter whatever code or subroutine you wanted there.  Then GOTO 2100 and type FEND to mark the file end + 1, GOTO 2000 and type FSTR to mark the file start, then type SAVE.  You will be prompted FILENAME: and just enter the filename.  This will also save whatever metadata you have associated with that section of code in the META folder.  If that 256 byte chunk of RAM is just a short lookup table or something, you probably don't need the associated metadata files in the META folder.  When you want to load your file later just remember to LOAD"yourfilename",8,1 and it will load into the spot where it was saved, in this case $2000.

However, if you're (for instance) writing a BASIC program that uses a short assembly language lookup, there's a way to do that too.  In that case, you would load up the META/L editor and type NEW, then write your BASIC program normally, and just make SYS calls as if you had already written the assembly code.  Then SYS 1024 to bring up the editor, GOTO 2000 or wherever you want your code, and type it all in there.  When you want to save, just make sure that you go to the last address of your code plus one and type FEND (It may have automatically set this for you if your last byte is code rather than a lookup), and type SAVE.  FSTR (the file start) is set to 0400 by default to include the editor in case you want to make changes later, but beware that BASIC needs to be told the MEMTOP or changes to your BASIC program could shift your assembly code around.  Once you're sure you're done editing your program you can eliminate the editor call (and the need to add ,8,1 to your LOAD) by changing FSTR to 0801 and SAVE.

I may make a short video on this for my tutorial series.

Edited to add: here's how to write a short piece of code that saves 2000-20FF as MYFILE.BIN

 

Edited by Ed Minchau
  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

Please review our Terms of Use