Hey there! I am new to this forum.
I am interested to learn assembly on a C64. I am using C64Studio and the VICE Emulater for that. I worte today two codefragments:
and a smaller one
So my questions are:
1) The first program compiles and runs AT ONCE with autostart option "inject into RAM" in VICE. But its not running if i change the startaddress for example to $C000 and try to run it in vice with sys 49152. Well the program run only if the first line is saved in $0801. Is there anything special about
$0801 (Begin of Basic RAM) as i should know for assembly?
2) The second program runs perfectly (but NOT automatically) with any address expect $0801. I realy dont understand why ... May be you have a hint for me ?
Thank you very much in advance for your answer and i am sorry about my bad english knowledge
Greetings from Zurich, Switzerland.
- Posts: 31
- Joined: Fri May 23, 2014 2:19 pm
- Location: Leeds, U.K.
The first !byte statement after the *=$0801 is essentially a small BASIC program being pushed into memory as hex; specifically it says 2018 SYS 2062 so, when you inject or drag/drop that assembled program into VICE, the BASIC runs and executes your code at 2062 ($080e in hex) which is where that first LDA after the !byte sits in memory. If you change the start address it's no longer loading into BASIC; forcing it up to $c000 gets you 13 bytes of unexecutable data (what was the BASIC program) followed by the actual code so SYS49152+13 should work.htheus1974 wrote: ↑Wed Nov 21, 2018 11:57 pm1) The first program compiles and runs AT ONCE with autostart option "inject into RAM" in VICE. But its not running if i change the startaddress for example to $C000 and try to run it in vice with sys 49152. Well the program run only if the first line is saved in $0801. Is there anything special about $0801 (Begin of Basic RAM) as i should know for assembly?
The second program at $c000 is just raw machine code, without the BASIC startline like the one included by the !byte command in the first listing it can only be started manually with a SYS command. If you assemble at $0801 it'll cause problems because BASIC is trying to treat it as a BASIC program and finding something it doesn't understand.
My variation of the BASIC startline builder looks like this:
The first * aims at the start of BASIC and the !word, !byte and !text commands construct a BASIC listing which reads 0 SYS 2066 and that's where the code starts assembing from the second origin point, the * = $0812 - if you change the 2066 to 16384 and the $0812 to $4000 it'll move the machine code up memory but should still execute automatically.
Code: Select all
; Add a BASIC startline * = $0801 !word entry-2 !byte $00,$00,$9e !text "2066" !byte $00,$00,$00 ; Entry point at $0812 * = $0812 entry lda #$00 sta $d020
Disclaimer: a message board post from this person shouldn't be seen as any kind of indication that a project has been started or is ongoing because as a programmer he has the attention span of... oh look, a squirrel!