chronicleroflegends
Member
Hi guys, I wish I could offer this all myself, but having never programmed in ASM before I have been starting from nothing.
I know a lot of people are looking at the ASM code and seeing hieroglyphics, and I couldn't find a good quick reference guide myself.
So instead, I have been slowly deciphering it from the tutorial videos we have so far and playing around with scripts.
I figured I would post my notes here in case it helps someone else.
I think it would be helpful to have a stickied quick reference guide for this board. Just so those who know nothing can actually read a line and understand what it means.
That way we can start to learn by reading the existing code.
Here is what I have so far:
I will try and update this as I learn more, but I hope I may be able to get some help from those more experienced.
Edit: Updated to include new info.
I know a lot of people are looking at the ASM code and seeing hieroglyphics, and I couldn't find a good quick reference guide myself.
So instead, I have been slowly deciphering it from the tutorial videos we have so far and playing around with scripts.
I figured I would post my notes here in case it helps someone else.
I think it would be helpful to have a stickied quick reference guide for this board. Just so those who know nothing can actually read a line and understand what it means.
That way we can start to learn by reading the existing code.
Here is what I have so far:
Code:
ASM REFERENCE
#$00 - Literal numer
myVar - Variable
myLabel:- Label
; - comment, all after the semicolon is ignored
GAMEPAD BITS:
00000000
LRDUSSBA
||
StartSelect
LDA arg - Load Argument into accumulator A
- Can be a literal or a variable
LDA arg1, arg2 - effectively: load value of type arg1 from object arg2
(actually uses arg2 as an offset to find arg1) store in accumulator
LDX arg1, arg2 - effectively: load value of type arg1 from object arg2
(actually uses arg2 as an offset to find arg1) store in x
LDY arg1, arg2 - effectively: load value of type arg1 from object arg2
(actually uses arg2 as an offset to find arg1) store in y
STA arg1 - Store accumulator in variable arg1
STA arg1, arg2 - Store value in arg2's arg1 type
STX arg1 - Store x in arg1
STY arg1 - Store y in arg1
TAX - Transfer value of accumulator to x
TAY - Transfer value of accumulator to y
TXA - self explanatory
TYA - self explanatory
LDX arg - same as LDA for the X address
LDY arg - same as LDA for the Y address
CMP arg - compare arg to accumulator and set flags for branching
CPX arg - same for X address
CPY arg - same for Y address
BEQ arg - if stored result is true, jump to label arg
BNE arg - if stored value is false, jump to label arg
BCC arg - if stored accumulator value is evaluated to less than, jump to arg
BCS arg - if stored accumulator value is evaluated to greater than, jump to arg
JMP arg - jump directly to label arg
NOTE: There is a physical distance limitation in code for these commands
JMP can reach much further than BEQ or BNE
Take this in mind when creating your branches, Branch to nearby code, Jump to faraway code.
RTI - return from interrupt
RTS - return from subroutine
DEC arg - decrease arg by 1
INC arg - increase arg by 1
CLC - clear carry bit for arithmetic
ADC arg - Add with carry. Add arg to the number in the accumulator
SBC arg - Subtract with carry. Subtract arg from number in the accumulator
AND arg - Logical AND, leaves accumulator with only those bits in common between it and the arg.
0010 + 1100 = 0000
0100 + 1100 = 0100
ORA arg - Logical OR, leaves the accumulator with all true bits in both accumulator and arg
0100 + 0010 = 0110
I will try and update this as I learn more, but I hope I may be able to get some help from those more experienced.
Edit: Updated to include new info.