Gonna Learn 6510 ML Code
Gonna Learn 6510 ML Code
Alright, given how I'm interested obsessed in trying to make a C64 Bard's Tale Game Maker program, it occurs to me I need to seriously learn how ML works.
Every time I see something like "ORA($3100,Z)" I get a little frightened and concerned, and this should not be.
Does anyone have any recommendations? Like some kind of retro online course or do I just find a bunch of books at the library?
Any advice is welcome.
Every time I see something like "ORA($3100,Z)" I get a little frightened and concerned, and this should not be.
Does anyone have any recommendations? Like some kind of retro online course or do I just find a bunch of books at the library?
Any advice is welcome.
-
- Posts: 352
- Joined: Tue Apr 28, 2009 11:03 pm
Re: Gonna Learn 6510 ML Code
Had to dig through a bunch of old Amiga bookmarks to find this, but I hope it helps. Will post more, if I find them:
https://www.commodore.ca/manuals/c64_pr ... nguage.pdf
https://www.commodore.ca/manuals/c64_pr ... nguage.pdf
"Using No Way as Way; Having No Limitation As Limitation". - Bruce Lee.
BTBuilder Stuff - https://drive.google.com/folderview?id= ... sp=sharing
BTBuilder Stuff - https://drive.google.com/folderview?id= ... sp=sharing
Re: Gonna Learn 6510 ML Code
Ah the Holy Grail of C64 ML programming. Of course!
The PRG also references this book here: http://archive.6502.org/books/mcs6500_f ... manual.pdf
Gonna have a ton of Google Chrome windows open I think.
Thank you, by the way.
The PRG also references this book here: http://archive.6502.org/books/mcs6500_f ... manual.pdf
Gonna have a ton of Google Chrome windows open I think.
Thank you, by the way.
Re: Gonna Learn 6510 ML Code
Holy sh...ovels.
I'm reading this and it's blowing my mind.
What does "complementing a byte" even mean? "Hi there Mr Byte, you sure do look nice in those shoes today!"
I'm reading this and it's blowing my mind.
Code: Select all
2.2.4.3 EOR— "Exclusive OR" Memory with Accumulator
The EOR instruction transfers the memory and the accumulator
to the adder which performs a binary "EXCLUSIVE OR" on a bit-by-bit
basis and stores the result in the accumulator.
This is indicated symbolically by A ^ M -* A.
This instruction affects the accumulator; sets the zero flag
if the result in the accumulator is 0, otherwise resets the zero flag
sets the negative flag if the result in the accumulator has bit 7 on,
otherwise resets the negative flag.
EOR is a "Group One" instruction having addressing modes of
Immediate; Absolute; Zero Page; Absolute,X; Absolute,?; Zero Page,X;
Indexed Indirect; and Indirect Indexed.
One of the uses of the EOR instruction is in complementing
bytes. This is accomplished below by exclusive ORA-ing the byte with
all l ’s.
Example 2.21: Complementing a byte with EOR
LDA 1010 1111
EOR 1111 1111
STA 0101 0000
Re: Gonna Learn 6510 ML Code
Wait a minute, I just figured it out.
Eeyore - I mean, EOR - turns all bits that are ON to OFF, and all bits that are OFF, to ON.
The 4 sets of bits immediately beside LDA, EOR and STA were throwing me off, I think.
Eeyore - I mean, EOR - turns all bits that are ON to OFF, and all bits that are OFF, to ON.
The 4 sets of bits immediately beside LDA, EOR and STA were throwing me off, I think.
Re: Gonna Learn 6510 ML Code
But then again, why bother with Eeyore - EOR - when you can just program the byte directly:
Hmm. Mysteries.
Code: Select all
LDA #$09 (9 for instance)
STA $0802 (store byte 9 at memory location 802)
Hmm. Mysteries.
-
- Posts: 352
- Joined: Tue Apr 28, 2009 11:03 pm
Re: Gonna Learn 6510 ML Code
Is it helping, at least?
If not, maybe something here will:
http://69.60.118.202/commodore/index.htm
If not, maybe something here will:
http://69.60.118.202/commodore/index.htm
"Using No Way as Way; Having No Limitation As Limitation". - Bruce Lee.
BTBuilder Stuff - https://drive.google.com/folderview?id= ... sp=sharing
BTBuilder Stuff - https://drive.google.com/folderview?id= ... sp=sharing
Re: Gonna Learn 6510 ML Code
That isn't right. EOR turns off all bits that are 1 in both numbers or 0 in both numbers. If both bits are 1, then the result is 0. If both bits are 0, then the result is also zero. If one bit is 1 and the other is 0 then the result is 1. The logic table is
Code: Select all
A | B | R
-------------
0 | 0 | 0
0 | 1 | 1
1 | 0 | 1
1 | 1 | 0
Re: Gonna Learn 6510 ML Code
Can you explain what the 2 numbers are exactly?drifting wrote: ↑Fri Feb 22, 2019 7:26 amThat isn't right. EOR turns off all bits that are 1 in both numbers or 0 in both numbers. If both bits are 1, then the result is 0. If both bits are 0, then the result is also zero. If one bit is 1 and the other is 0 then the result is 1. The logic table isIn x86 assembly it's used a lot to set a register to 0. xor ax, ax is very common in x86 assembler since it takes fewer cycles than setting the register directly via mov ax, 0Code: Select all
A | B | R ------------- 0 | 0 | 0 0 | 1 | 1 1 | 0 | 1 1 | 1 | 0
I guess I'd need to see it in an example mode.
Code: Select all
LDA $0400
LDX $0800
EOR A,X
BEQ [somewhere else]
RTS
I'd really like to nail this arithmetic portion because if I can figure all this out it'll make the rest more or less a breeze.
Re: Gonna Learn 6510 ML Code
It is actually. I'm finding myself reading through the entire ML section.Methuselas wrote: ↑Fri Feb 22, 2019 6:35 am Is it helping, at least?
If not, maybe something here will:
http://69.60.118.202/commodore/index.htm
I have a WINVICE window with a 64MON cartridge installed and I'm very, very slowly (timidly) attempting to experiment with code.
Re: Gonna Learn 6510 ML Code
The two numbers of the EOR instruction are:Darendor wrote: ↑Fri Feb 22, 2019 10:28 am Can you explain what the 2 numbers are exactly?
I guess I'd need to see it in an example mode.
Is that more accurate? Apologies if I've missed it again.Code: Select all
LDA $0400 LDX $0800 EOR A,X BEQ [somewhere else] RTS
I'd really like to nail this arithmetic portion because if I can figure all this out it'll make the rest more or less a breeze.
- The value in A
- The number in the EOR instruction
Code: Select all
LDA #$80 ; Load #$80 into A
EOR #$04 ; Do an exclusive or on A (#$80) and #$04
BEQ [somewhere] ; The result of which is #$84 so do not branch
RTS ; Return
-
- Posts: 352
- Joined: Tue Apr 28, 2009 11:03 pm
Re: Gonna Learn 6510 ML Code
The second link I gave you, has a bunch of games that are in ML code. You might want to also look at those.
"Using No Way as Way; Having No Limitation As Limitation". - Bruce Lee.
BTBuilder Stuff - https://drive.google.com/folderview?id= ... sp=sharing
BTBuilder Stuff - https://drive.google.com/folderview?id= ... sp=sharing
Re: Gonna Learn 6510 ML Code
So drifting, if I read your example code correctly, the EOR function appears to add #$80 and #$04 together to make #$84.
Is that a coincidence or is that a constant function?
The BEQ is a brance on equal, which means that it would branch to [somewhere] if it was #$84. I think.
Thank you for the patience.
Is that a coincidence or is that a constant function?
Code: Select all
LDA #$80 ; Load #$80 into A
EOR #$04 ; Do an exclusive or on A (#$80) and #$04
BEQ [somewhere] ; The result of which is #$84 so do not branch
RTS ; Return
Thank you for the patience.
Re: Gonna Learn 6510 ML Code
Huzzah, I discovered this:
Progress.
Code: Select all
AND - turns bits off
ORA - turns bits on
EOR - flips bits over
Re: Gonna Learn 6510 ML Code
You really shouldn't think of bit level operations as addition and subtraction. They are all bitwise operations. The EOR instruction is performing a bitwise XOR on the two numbers.
This is some of the fun of assembler. The BEQ instruction doesn't actually branch on equal, it branches if the Z (zero) flag is set. The EOR instruction sets the Z flag if the result of the EOR operation is 0. The result of the EOR operation is 0 when both numbers are the same. So:Darendor wrote: ↑Fri Feb 22, 2019 8:58 pmThe BEQ is a brance on equal, which means that it would branch to [somewhere] if it was #$84. I think.Code: Select all
LDA #$80 ; Load #$80 into A EOR #$04 ; Do an exclusive or on A (#$80) and #$04 BEQ [somewhere] ; The result of which is #$84 so do not branch RTS ; Return
Thank you for the patience.
Code: Select all
LDA #$80 ; Load #$80 into A
EOR #$80 ; Do an exclusive or on A (#$80) and #$(80)
BEQ [somewhere] ; The result of which is 0 so branch to [somewhere]
RTS ; Not reached
Code: Select all
LDA $#00 ; Load #$00 into A
BEQ [somewhere] ; Branch to [somewhere] is Z is set
RTS ; Not reached