Path: news1.icaen!news.uiowa.edu!chi-news.cic.net!199.60.229.3!newsfeed.direct.ca!news.uoregon.edu!cie-2.uoregon.edu!nparker From: nparker@cie-2.uoregon.edu (Neil Parker) Newsgroups: comp.sys.apple2.programmer Subject: Re: Monitor commands from Assembler Programs? Date: 18 Jun 1997 00:13:41 GMT Organization: University of Oregon Campus Information Exchange Lines: 97 Message-ID: <5o797l$2sm@pith.uoregon.edu> References: <5o46eu$1avm@info4.rus.uni-stuttgart.de> NNTP-Posting-Host: cie-2.uoregon.edu NNTP-Posting-User: nparker In article <5o46eu$1avm@info4.rus.uni-stuttgart.de> christoph@gym-schiff.lu.rp.schule.de (Christoph Heidinger) writes: >I have found out that I can save a memory area, for example the one from $4000 >to $6000 (HiRes Image) to (audio) cassettes. I now would like to do so from an >Applesoft program on a IIe. I would also write a small Assembler program to >manage to do so. > >Has anyone got a hint for me how I can execute the monitor command > >4000.6000w > >from another program? The best way to do this is probably to CALL the tape write routine. First, you need to POKE the starting address into 60 (low byte) and 61 (high byte), and the ending address into 62 (low byte) and 63 (high byte). Then CALL -307. For example, here a BASIC routine that does the same thing as "4000.6000W": 10 POKE 60,0: POKE 61,64: POKE 62,0: POKE 63,96 20 CALL - 307 And here it is in assembly: A1L EQU $3C ;Starting address A1H EQU $3D A2L EQU $3E ;Ending address A2H EQU $3F WRITE EQU $FECD ;Tape write routine LDA #0 ;Set up starting & ending addresses STA A1L STA A2L LDA #$40 STA A1H LDA #$60 STA A2H JSR WRITE ;Write it to tape You'll probably also be interested in reading your data back from the tape. The tape read routine is "CALL -259" (or JSR $FEFD in assembly), and its setup is identical to the tape write routine: starting address in 60 and 61, ending address in 62 and 63. Of course these examples only work on machines that have cassette ports, so don't expect useful results on a IIc or IIGS. (By the way, "4000.6000W" writes one more byte than is necessary...it would probably be better to use "4000.5FFFW".) > By the way, the m command would as well be interesting. CALLing the monitor move command from BASIC is a little harder. The monitor move command requires that the Y register contain 0 when you call it, but BASIC's CALL statement doesn't set up the Y register for you. So instead of CALLing the move routine directly, you have to CALL a short subroutine that sets Y to 0 and then does the move. The monitor move command expects the starting address in 60 and 61, the ending address in 62 and 63, and the destination address in 66 and 67. For example, here's "6000<2000.3FFFM" in BASIC: 10 FOR X = 0 TO 4: READ Y: POKE 768 + X,Y: NEXT 20 DATA 160,0,76,44,254: REM LDY #0; JMP $FE2C 30 POKE 60,0: POKE 61,32: POKE 62,255: POKE 63,47: POKE 66,0: POKE 67,96 40 CALL 768 And here it is in assembly: A1L EQU $3C ;Starting address A1H EQU $3D A2L EQU $3E ;Ending address A2H EQU $3F A4L EQU $42 ;Destination address A4H EQU $43 MOVE EQU $FE2C ;Memory move routine LDA #0 ;Set up addresses and Y STA A1L STA A4L TAY LDA #$20 STA A1H LDA #$FF STA A2L LDA #$3F STA A2H LDA #$60 STA A4H JSR MOVE ;Do the move - Neil Parker -- Neil Parker, nparker@{cie-2,cie}.uoregon.edu, http://cie-2.uoregon.edu/~nparker "Evolution is vastly overrated." -- Ambassador Delenn, _Babylon_5_ Unsolicited commercial e-mail to my address will be discarded unread.