Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,2 @@
Array:
db 5,10,15,20,25,30,35,40,45,50

View file

@ -0,0 +1,2 @@
Array:
db 5,10,15,20,25,30,35,40,45,50

View file

@ -0,0 +1,11 @@
Array:
db 5
db 10
db 15
db 20
db 25
db 30
db 35
db 40
db 45
db 50

View file

@ -0,0 +1,6 @@
Array:
db 5,10
db 15,20
db 25,30
db 35,40
db 45,50

View file

@ -0,0 +1,6 @@
Array:
db 5,10
db 15,20
db 25,30
db 35,40
db 45,50

View file

@ -0,0 +1,8 @@
LDA #3 ;desired row
ASL A ;Times 2 bytes per row (if the array's row size wasn't a multiple of 2 we'd need to actually do multiplication)
;which the 6502 doesn't have in hardware but can be simulated by repeated adding.
CLC
ADC #1 ;desired column (since it's 1 byte per column, we can skip the part where we multiply desired column by bytes per column)
TAX ;move A to X so we can use it as the index
LDA Array,x ;evaluates to LDA #40

View file

@ -0,0 +1,5 @@
char foo()
{
char array[5] = {3,6,9,12,15};
return array[2];
}

View file

@ -0,0 +1,7 @@
foo:
LDX #2 ;load the desired index
LDA array,x ;load the second (zero-indexed) entry in array, i.e. 9
RTS ;return. The return value is stored in A.
array: ;this is the array we're reading from.
db 3,6,9,12,15

View file

@ -0,0 +1,3 @@
LDX #$80
LDA $80,x ;evaluates to LDA $00
LDA $0480,x ;evaluates to LDA $0500

View file

@ -0,0 +1,2 @@
wordArray:
dw $ABCD,$BEEF,$CAFE,$DADA

View file

@ -0,0 +1,2 @@
wordArray:
db $CD,$AB,$EF,$BE,$FE,$CA,$DA,$DA

View file

@ -0,0 +1,7 @@
LDX #2 ;load the 1st (zero-indexed) WORD from the array (which is why this is 2 not 1)
LDA wordArray,X ;evaluates to LDA #$EF
STA $00 ;store in a zero page temporary variable
INX ;point X to the high byte
LDA wordArray,X ;evaluates to LDA #$BE
STA $01 ;store in a different zero page temporary variable. If your word data is a pointer you want to dereference,
;you'll need to store the low byte in $nn and the high byte in $nn+1 like I did here.

View file

@ -0,0 +1,5 @@
wordArray_Lo:
db $CD,$EF,$FE,$DA
wordArray_Hi:
db $AB,$BE,$CA,$DA ;both this version and the above versions are 8 bytes of memory.

View file

@ -0,0 +1,5 @@
LDX #1 ;with split arrays we DON'T need to double our index.
LDA wordArray_Lo,x ;evaluates to LDA #$EF
STA $00
LDA wordArray_Hi,x ;evaluates to LDA #$BE
STA $01