[Coco] More Color Forth
Stephen Pereira
spereira1952 at comcast.net
Sun Jan 25 15:08:15 EST 2015
Hi Art,
Thanks very much for your response.
Yes, I know what you are saying. This is probably something that I am not understanding as I read the disassembly of the Disk Basic code.
Here is the code I am looking at (I truncated the comments):
2124 CF7E CC 02 00 LDD #$0200 * FILE TYPE=2, ASCI
2125 CF81 FD 09 57 STD DFLTYP *
2126 CF84 BD CA 04 JSR LCA04 GET NEXT UNOPEN FIL
2127 CF87 4F CLRA *ZERO FLAG - FIRST
2128 CF88 8D 2B BSR LCFB5 *WRITE A BYTE TO BU
2129 CF8A EC 62 LDD $02,S GET END ADDRESS
2130 CF8C A3 64 SUBD $04,S SUBTRACT THE START
2131 CF8E C3 00 01 ADDD #$0001 THE SAVED DATA BLOC
2132 CF91 1F 02 TFR D,Y SAVE LENGTH IN Y
2133 CF93 8D 1E BSR LCFB3 WRITE FILE LENGTH T
2134 CF95 EC 64 LDD $04,S GET THE START ADDRE
2135 CF97 8D 1A BSR LCFB3 WRITE OUT THE START
2136 CF99 AE 64 LDX $04,S GET START ADDRESS
2137 CF9B A6 80 LCF9B LDA ,X+ GRAB A BYTE
2138 CF9D BD CC 24 JSR LCC24 WRITE IT OUT
2139 CFA0 31 3F LEAY -1,Y DECREMENT BYTE COUN
2140 CFA2 26 F7 BNE LCF9B BRANCH IF ALL BYTES
2141 CFA4 86 FF LDA #$FF FIRST BYTE OF POSTA
2142 CFA6 8D 0D BSR LCFB5 WRITE IT OUT - EOF
2143 CFA8 4F CLRA * FIRST ARGUMENT OF
2144 CFA9 5F CLRB * A DUMMY - ZERO VA
2145 CFAA 8D 07 BSR LCFB3 WRITE OUT POSTAMBLE
2146 CFAC 35 36 PULS A,B,X,Y GET CONTROL ADDRESS
2147 CFAE 8D 03 BSR LCFB3 WRITE OUT THE TRANS
2148 CFB0 7E A4 2D JMP LA42D GO CLOSE ALL FILES
Because of my prior experience with the 8080, I am probably not reading the code correctly.
In line 2129 when it says LDD $02,S doesn’t that mean to get the address 2 bytes down from the top of stack and put them into registers A and B?
In line 2130 when it says SUBD $04,S doesn’t that mean to subtract the address 4 bytes down from the top of stack from registers A and B?
In line 2134 when it says LDD $04,S doesn’t that mean to get the address 4 bytes down from the top of stack and put them into registers A and B?
In line 2132 I see TFR D,X and in line 2136 I see LDX $04,S, so I thought that the code loads the X register on its own.
That is how I am interpreting what I see. If that is not correct, there is my problem! This is why I thought that I only have to have the addresses on the stack, and I cannot see where I have to have them in other registers.
I am not trying to be argumentative - I am only trying to learn by saying what I thought I was reading. I greatly appreciate any advice and counsel that you may offer.
smp
--
Stephen M. Pereira
Bedford, NH 03110
KB1SXE
> On Jan 25, 2015, at 2:30 PM, Arthur Flexser <flexser at fiu.edu> wrote:
>
> If the description I gave you earlier, based on some old code of mine that
> I unearthed, is right, then what you did isn't quite in accord with it.
> You need to push all the registers, after loading them with the start, end,
> exec, and address for resuming execution, in a SINGLE pshs operation, which
> will ensure the correct order of what is pushed. Then JMP (not JSR) to the
> savem routine. I'm not sure your final PULS is reached, unless you set the
> resume address to that.
>
> Art
>
> On Sun, Jan 25, 2015 at 2:01 PM, Stephen Pereira <spereira1952 at comcast.net>
> wrote:
>
>> Hello again, all,
>>
>> In my continuing Color Forth project, I am attempting to install a brute
>> force save of the Color Forth code screens to disk. When I am eventually
>> successful, I hope to at least be able to save and load the entire set of
>> Color Forth screens 1-8 to and from disk, so we can be free from
>> pre-loading only one set of screens 1-8 as it is now.
>>
>> I am hoping to use the SAVEM (and LOADM) command from DECB.
>>
>> I am a pretty good programmer in 8080 machine language, but I am an
>> outright beginner on the 6809. Please forgive my non-optimal code for
>> now. I am only hoping to get something going and then look for doing it
>> well after I understand it all.
>>
>> From my reading of “Disk Basic Unravelled,” I see that one can load the
>> filename at $094C and the file extension at $0954, then put the start
>> address, end address and execute address on the stack, and finally call
>> SAVEM at $CF7E. Yes, I know that is not the official entry point, I am
>> bypassing the initial code to get the file name and addresses from the
>> Basic input buffer.
>>
>> Here is the snippet of (brute force) code that I wrote:
>>
>> PSHS CC,A,B,DP,X,Y,U SAVE ALL JUST IN CASE
>> LDX #$094C
>> LDA #$53 S
>> STA ,X+
>> LDA #$43 C
>> STA ,X+
>> LDA #$52 R
>> STA ,X+
>> LDA #$4E N
>> STA ,X+
>> LDA #$31 1
>> STA ,X+
>> LDA #$54 T
>> STA ,X+
>> LDA #$4F O
>> STA ,X+
>> LDA #$38 8
>> STA ,X
>> LDX #$0954
>> LDA #$42 B
>> STA ,X+
>> LDA #$49 I
>> STA ,X+
>> LDA #$4E N
>> STA ,X
>> LDD #$2382 START SCR 1
>> PSHS A,B
>> LDD #$439F END SCR 8
>> PSHS A,B
>> LDD #$0000 EXEC
>> PSHS A,B
>> JSR $CF7E SAVEM
>> PULS U,Y,X,DP,B,A,CC RESTORE ALL
>>
>> What I am concerned about is whether or not I am getting the addresses
>> onto the stack in the right order, and with the correct byte order.
>>
>> The reason I’m asking is that this code “kind of works” in my Color
>> Forth. I do get a file onto disk called SCRN1TO8.BIN, but it is 21 blocks
>> long, instead of 4 blocks, like I expected.
>>
>> Finally, while my Drivewire UI shows the disk activity start and end, my
>> code does not return to the command line in Color Forth, so I am also
>> concerned about that. I see in the “Disk Basic Unravelled” that the SAVEM
>> command dose end with an RTS, so I did expect my code to return.
>>
>> Thanks very much, in advance, for any comments or advice you may offer!
>>
>> smp
>> --
>> Stephen M. Pereira
>> Bedford, NH 03110
>> KB1SXE
>>
>>
>>
>> --
>> Coco mailing list
>> Coco at maltedmedia.com
>> https://pairlist5.pair.net/mailman/listinfo/coco
>>
>
> --
> Coco mailing list
> Coco at maltedmedia.com
> https://pairlist5.pair.net/mailman/listinfo/coco
More information about the Coco
mailing list