mirror of
https://github.com/nathanriggs/AppleIIAsm-Collection.git
synced 2024-11-28 03:52:10 +00:00
299 lines
6.6 KiB
Plaintext
299 lines
6.6 KiB
Plaintext
*
|
|
********************************
|
|
* *
|
|
* -< ARRAYS DEMO >- *
|
|
* *
|
|
* VERSION 00.02.00 *
|
|
* *
|
|
* 12-DEC-2018 *
|
|
* *
|
|
********************************
|
|
* *
|
|
* NATHAN D. RIGGS *
|
|
* NATHAN.RIGGS@OUTLOOK.COM *
|
|
* *
|
|
********************************
|
|
*
|
|
** ASSEMBLER DIRECTIVES
|
|
*
|
|
CYC AVE
|
|
EXP ONLY
|
|
DSK ARRAYS.DEMO
|
|
OBJ $BFE0
|
|
ORG $6000
|
|
*
|
|
*``````````````````````````````*
|
|
* TOP INCLUDES (HOOKS,MACROS) *
|
|
*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*
|
|
*
|
|
PUT REQUIRED.HOOKS
|
|
USE REQUIRED.MAC
|
|
USE ARRAYS.MAC
|
|
PUT ARRAYS.HOOKS
|
|
*
|
|
*``````````````````````````````*
|
|
* PROGRAM MAIN BODY *
|
|
*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*
|
|
*
|
|
ARRAY1 EQU $300
|
|
ARRAY2 EQU $4000
|
|
*
|
|
** DIM81 CLEARS THE MEMORY AT THE SPECIFIED
|
|
** LOCATION AND SETS UP THE DATA CONFIGURATION
|
|
** FOR A 1D ARRAY (ARRAY LENGTH, ELEMENT LENGTH, DATA)
|
|
*
|
|
** MACRO: DIM81 ADDRESS;ARRAY_SIZE;ELEMENT_LENGTH
|
|
*
|
|
LDA #>ARRAY1 ; HIGH LOCATION FOR ARRAY
|
|
PHA
|
|
LDA #<ARRAY1 ; LOW LOCATION
|
|
PHA
|
|
LDA #06 ; ARRAY LENGTH
|
|
PHA
|
|
LDA #2 ; ELEMENT LENGTH
|
|
PHA
|
|
JSR ADIM81
|
|
*
|
|
** NOW CHECK $300 TO SEE RESULT
|
|
*
|
|
JSR __P
|
|
HEX 8D8D
|
|
ASC "1-DIMENSIONAL ARRAY AFTER INITIALIZING"
|
|
HEX 8D8D
|
|
ASC " "
|
|
ASC "0 1 2 3 4 5 "
|
|
HEX 8D00
|
|
LDA #>$300
|
|
PHA
|
|
LDA #<$300
|
|
PHA
|
|
LDA #14 ; ARRAY LENGTH + 2
|
|
PHA
|
|
JSR __DUMP
|
|
JSR __W
|
|
*
|
|
** NOTE THAT INDEXING STARTS AT 0, SO AN ARRAY
|
|
** OF TEN ELEMENTS WOULD BE LISTED AS 0..9
|
|
*
|
|
** APUT81 COPIES DATA FROM ONE SPECIFIED LOCATION
|
|
** TO THE ELEMENT INDEXED IN AN ARRAY AT ANOTHER
|
|
** LOCATION.
|
|
*
|
|
*** MACRO: PUT81 $SRC_ADDR;ARRAY_ADDR;INDEX
|
|
*
|
|
LDA #$44
|
|
STA ARRAY2
|
|
LDA #$55
|
|
STA ARRAY2+1
|
|
LDA #>ARRAY2 ; ADDRESS TO COPY
|
|
PHA
|
|
LDA #<ARRAY2
|
|
PHA
|
|
LDA #>ARRAY1 ; ARRAY ADDRESS
|
|
PHA
|
|
LDA #<ARRAY1
|
|
PHA
|
|
LDA #2
|
|
PHA ; INDEX
|
|
JSR APUT81
|
|
JSR __P
|
|
HEX 8D8D8D
|
|
ASC "AFTER PUTTING #4455 AT INDEX 2"
|
|
HEX 8D00
|
|
LDA #>ARRAY1
|
|
PHA
|
|
LDA #<ARRAY1
|
|
PHA
|
|
LDA #14
|
|
PHA
|
|
JSR __DUMP
|
|
JSR __W
|
|
*
|
|
** AGET81 RETURNS THE MEMORY ADDRESS WHERE
|
|
** AN ELEMENT AT THE SPECIFIED INDEX IN
|
|
** Y (LOW) AND X (HIGH), AS WELL AS COPIES
|
|
** THAT ELEMENT TO THE [RETURN] LOCATION
|
|
*
|
|
*** MACRO: GET81 $ARRAY_ADDRESS;INDEX
|
|
*
|
|
LDA #>ARRAY1
|
|
PHA
|
|
LDA #<ARRAY1
|
|
PHA
|
|
LDA #02 ; INDEX CONTAINS #4455
|
|
PHA ; OR "DU" INVERTED
|
|
JSR AGET81
|
|
*
|
|
JSR __P
|
|
HEX 8D8D
|
|
ASC "RETURN VALUE OF GET81: "
|
|
HEX 00
|
|
LDA RETURN
|
|
JSR $FDF0 ; COUT1
|
|
LDA RETURN+1
|
|
JSR $FDF0
|
|
JSR __P
|
|
HEX 8D00
|
|
JSR __W
|
|
*
|
|
** DIM82 CREATES AN 8BIT, 2D ARRAY AT THE
|
|
** SPECIFIED LOCATION WITH THE LENGTH AND
|
|
** HEIGHT PASSED VIA THE STACK
|
|
*
|
|
** MACRO: DIM82 $ARRAY_ADDR;ROWS;COLUMNS;ELEMENT_LENGTH
|
|
*
|
|
LDA #>ARRAY2
|
|
PHA
|
|
LDA #<ARRAY2 ; ARRAY ADDRESS
|
|
PHA
|
|
LDA #4 ; X-DIMENSION
|
|
PHA
|
|
LDA #4 ; Y-DIMESION
|
|
PHA
|
|
LDA #1 ; ELEMENT SIZE
|
|
PHA
|
|
JSR ADIM82
|
|
*
|
|
JSR __P
|
|
HEX 8D8D
|
|
ASC "2-DIMENSIONAL ARRAY, FIRST INITIALIZED"
|
|
HEX 8D
|
|
HEX 00
|
|
LDA #>ARRAY2
|
|
PHA
|
|
LDA #<ARRAY2
|
|
PHA
|
|
LDA #3
|
|
PHA
|
|
JSR __DUMP
|
|
LDA #>ARRAY2+3
|
|
PHA
|
|
LDA #<ARRAY2+3
|
|
PHA
|
|
LDA #4
|
|
PHA
|
|
JSR __DUMP
|
|
LDA #>ARRAY2+7
|
|
PHA
|
|
LDA #<ARRAY2+7
|
|
PHA
|
|
LDA #4
|
|
PHA
|
|
JSR __DUMP
|
|
LDA #>ARRAY2+11
|
|
PHA
|
|
LDA #<ARRAY2+11
|
|
PHA
|
|
LDA #4
|
|
PHA
|
|
JSR __DUMP
|
|
LDA #>ARRAY2+15
|
|
PHA
|
|
LDA #<ARRAY2+15
|
|
PHA
|
|
LDA #4
|
|
PHA
|
|
JSR __DUMP
|
|
JSR __W
|
|
*
|
|
** APUT82 PUTS THE DATA STORED IN ONE LOCATION
|
|
** INTO THE ARRAY AT THE SPECIFIED INDEX X,Y.
|
|
*
|
|
** MACRO: PUT82 SRC_ADDR;ARRAY_ADDR;ROW_INDEX;COLUMN_INDEX
|
|
*
|
|
LDA #180
|
|
STA ARRAY1
|
|
|
|
LDA #>ARRAY1 ; SRC
|
|
PHA
|
|
LDA #<ARRAY1
|
|
PHA
|
|
LDA #>ARRAY2 ; DEST
|
|
PHA
|
|
LDA #<ARRAY2
|
|
PHA
|
|
LDA #2 ; X INDEX
|
|
PHA
|
|
LDA #3
|
|
PHA ; Y INDEX
|
|
JSR APUT82
|
|
*
|
|
JSR __P
|
|
HEX 8D8D
|
|
ASC "2D ARRAY AFTER PUTTING '04' AT LOCATION 2,3"
|
|
HEX 8D
|
|
HEX 00
|
|
LDA #>ARRAY2
|
|
PHA
|
|
LDA #<ARRAY2
|
|
PHA
|
|
LDA #3
|
|
PHA
|
|
JSR __DUMP
|
|
LDA #>ARRAY2+3
|
|
PHA
|
|
LDA #<ARRAY2+3
|
|
PHA
|
|
LDA #4
|
|
PHA
|
|
JSR __DUMP
|
|
LDA #>ARRAY2+7
|
|
PHA
|
|
LDA #<ARRAY2+7
|
|
PHA
|
|
LDA #4
|
|
PHA
|
|
JSR __DUMP
|
|
LDA #>ARRAY2+11
|
|
PHA
|
|
LDA #<ARRAY2+11
|
|
PHA
|
|
LDA #4
|
|
PHA
|
|
JSR __DUMP
|
|
LDA #>ARRAY2+15
|
|
PHA
|
|
LDA #<ARRAY2+15
|
|
PHA
|
|
LDA #4
|
|
PHA
|
|
JSR __DUMP
|
|
JSR __W
|
|
*
|
|
** AGET82 GETS THE MEMORY LOCATION OF THE ELEMENT
|
|
** STORED AT INDEX X,Y IN THE GIVEN ARRAYS AND
|
|
** RETURNS IT IN Y (LOW) AND X (HIGH); DATA
|
|
** IN ELEMENT IS ALSO COPIED TO [RETURN]
|
|
*
|
|
** MACRO: GET82 $ARRAY_ADDR;ROW_INDEX;COLUMN_INDEX
|
|
*
|
|
LDA #>ARRAY2
|
|
PHA
|
|
LDA #<ARRAY2
|
|
PHA
|
|
LDA #2 ; X INDEX
|
|
PHA
|
|
LDA #3 ; Y INDEX
|
|
PHA
|
|
JSR AGET82
|
|
*
|
|
LDA RETURN
|
|
JSR __P
|
|
HEX 8D8D
|
|
ASC "VALUE AT 2,3 VIA AGET82: "
|
|
HEX 00
|
|
LDA RETURN
|
|
JSR $FDF0
|
|
JSR __W
|
|
*
|
|
JMP REENTRY
|
|
*
|
|
*``````````````````````````````*
|
|
* BOTTOM INCLUDES (ROUTINES) *
|
|
*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*
|
|
*
|
|
PUT ARRAYS81.LIB
|
|
PUT ARRAYS82.LIB
|
|
PUT REQUIRED.LIB
|
|
*
|