|
Post by stiggity on Dec 10, 2022 5:35:05 GMT
c128old: Thanks for your assistance... i really appreciate it. Since this issue is squared away, i have another problem.
After the ML call loads the file (merges it), once i jsr $ffd5, if that's successful, would .X hold low byte of load, and .Y hold High byte of _that current_ file, loaded? I'm trying to come up with a way of performing.
a=256*peek(4625)+peek(4624)-2:poke4051,(a and 255):poke4052,a/256: <== Is what i would like to learn how to accomplish in assembly
I have done some basic division, and i guess multiplication is #+#+#?? but it's a 16 bit number....so im doing 16 bit addition, and haven't the slightest idea... thats why i was asking if after teh $FFD5 (LOAD) kernal call is issued, how can i find current end of basic text?? x =low, y = hi
Sorry to sound so crude, but this would really help..
-Regards
|
|
|
Post by stiggity on Dec 10, 2022 23:05:48 GMT
Alright, after the initial merge, integrity is true. Then setting up hi/low of NEXT merge is a success (According to the two address's, and Vice monitor)., but the modified loader finds the filename, loads the second file, and returns with no errors, but no data at the beginning line Number for the 2nd merge. If anybody would care too see source, and/or BASIC setup, I'd be honored... if i peek and look in the VICE monitor, all hi/lo bytes are correct, and afaik the loader/merge routine has been written with care, but im not seeing any BASIC in listing...
|
|
|
Post by stiggity on Dec 11, 2022 4:15:56 GMT
Okay! i got things working.. but!! once the 2nd load/merge is ran, the file is merged and re-linked, but im missing the first BASIC line of the last load/merge.. the whole thing is in memory, and functioning.. (well.. with a little shove here and there). But, it's working alright... heres a question ... im still setting end of text so the first file is loaded/merged, and its ended with "-2", and ALL files merge great. Okay, after the merge and return to BASIC, i call the same code, but use a different floating variable, poke poke two other registers, hi/low, but before doing that the formula again, ends in "-2", but this second load/merge is loading, and linking, but I'm 1 line off.. would I subtract one instead of two, or subtract 3 instead of 2??? hoping to get a reply.. been at it most of the day.. thanks for reading this, goodbye.
|
|
|
Post by c128old on Dec 11, 2022 11:48:14 GMT
Regarding your question with the 16bit arithmetic: find 6502 resources online, several will explain this great!
Consider your code: a=256*peek(dec("1211"))+peek(dec("1210"))-2 poke dec("0Fd3"),(a and 255) poke dec("0Fd4"),a/256
We know most 8 bit systems store their 16bit things in the order "Low, High" From $1211 we get the high byte and to create a 16bit we do (High*256 + Low). Thus an address like $8001 stored in $01, $80 will yield '$80' for the high byte. Times 256 means $80 gets 'shifted' over by 8 positions, becoming $8000. Now add the low byte of $01 and the basic value for a = $8001. From this we substract 2 and get $7FFF. This clearly shows you cannot (simply) lower the count on 8001 by two.
The goal of this operation is to find 'where to load your data to', a place in memory that is known by basic (in $1210-$1211) and we want to start 2 down from there. Consider: We want a copy of the end of basic pointer in 0FD3, 0FD4, but "-2"
Get basic ptr low byte LDA $1210
Now A is the low byte (01 in my example). Lets try to lower by 2: SEC . Note how we HAVE to set the carry before the subtract (else we get a sub by 3 instead of by 2) SBC #2 STA $0FD3
This subtraction will result in the C being set, or not, when we cross 00. In the example of 8001, this is the case. When we have done this, the result in A will be $FF, that is correct. So the low byte copied pointer in 0FD3 is OK.
Continue with the high byte, and remember we are not touching the carry bit LDA $1211 SBC #0 STA $0FD4
Subtracting a zero from A will result in either -1 or nothing as a function of the carry value.
In our case we get: first read: A = $01 Carry = 1 A = A - 2 A = $FF and Carry = 0 second read: A = $80 Carry = 0 A = A - 1 A = $7F
|
|
|
Post by stiggity on Dec 11, 2022 21:58:51 GMT
c128old: You made that look/feel too easy!! here all along, I was over complicating the whole operation... But, even though I've been a hobbyist (c64 until 2020) my learning curve is the pits... your explanation made a lot of sense. Even though zero page and pointers are the foundation of 6502 assembly, I learn new things everyday. please accept my gratitude...I would not have gotten the last subtraction of #0 without setting carry, which would have made more problems.. thanks a lot! The depth you respond with, makes things easier to adhere..
|
|