I suppose technically, POKE is a kind of Machine Code cause the command is directly changing the data at the location specified.
Yep, poke changes the byte at a memory address.
and you have to admit, your version has almost twice the amount of text as mine did assuming it does the same thing. I couldn't check cause it didn't work, it says there's a "SYNTAX ERROR IN 10".
It does have twice (three times, four times?) the amount of complexity (there is a reason). And it does work in line 10, I wouldn't post you syntax errors Renoised (if there is a syntax error, it's probably because you've typed the line incorrectly, or what you think is correct to what is printed here)
I've been watching some videos though, and I'm starting to realise that Assembler is directly attached to Machine Code in a way I didn't realise, so I still might learn Assembler. I can see now that there's a difference between how something like C gets compiled to Machine Code, and Assembler which is a different thing cause it's directly interacting with it. Assembly language is different in that it assembles the Machine Code from humanly readable commands whereas C goes through all sorts of stuff. Anyway, even if I fucked-up with my understanding of it, I still know a lot more than I did the other day, so yep, I might still choose Assembler after all
If nothing else Renoised, at least I've made you realise that there is a one to one correspondence between assembly language and machine code
So why is this program...
10 FOR N=0 TO 11:READA:POKEN+49152,A:NEXT
20 DATA 169,0,141,134,2,141,32,208
30 DATA 141,33,208,96
40 SYS 49152
much different than just those 3 POKE's Renoised? Well line 10 is just POKE'ing into memory, it's just taking the following DATA statement numbers and doing it in a FOR loop. Why? Simple. Saves writing out 12 pokes manually But why is the program still so complicated? Well instead of just POKE'ing and changing memory locations manually Renoised, it pokes into memory (starting at address 49152) a machine code program for the CPU to execute. The CPU program (those numbers in the DATA statements) gets the CPU to do the equivalent POKE'ing that you were doing. Line 40 actually taps the C64 CPU on the shoulder and says 'hey, pssst, could you just stop executing basic for a moment and jump to location 49152 and start executing those 12 numbers I've put there.'
4TEY: Hey, psst could you start executing at address 49152?
CPU : Yeah, whatever, let me finish...right address 49152..
what number is there? 169 you say, right, that's a load accumulator instruction,
what number do you want me to load?..[cpu looks at the contents of the next address]..ah zero...
what is the next instruction?..141..that's a store accumulator instruction..where
do you want me to put the contents of my accumulator?...[cpu looks at the next 2
addresses]..ah location 646....
and so on until that 96 number at the end of the last DATA statement (which means RTS, return from subroutine), so the CPU goes back to executing basic.
Ah, I'm not surprised that it is a touch more complicated than just 3 POKE statements
[Edit:] Just to mention what the CPU program (the numbers in the DATA statements above) looks like in assembly source code for reference:
Addr Opcode (in decimal) 6510 Instruction (assembly)
49152 169,0 LDA #0
49154 141,134,2 STA 646
49157 141,32,208 STA 53280
49160 141,33,208 STA 53281
49163 96 RTS
[Edit2:] The d64 Vice disk image might be available here: Darkness.d64
Attach the disk image to drive 8 manually and type:
Edited by 4Tey, 17 January 2018 - 08:32.