6502 Assembly Language Subroutines by Lance A. Leventhal

By Lance A. Leventhal

OOsborne/McGraw-Hill 1982. Wrap fresh with area put on. Binding tight, publication sq.. most sensible of publication has a few soiling. Pages are fresh without names, marks or highlights. Proceeds profit the Oro Valley Library.

Show description

Read or Download 6502 Assembly Language Subroutines PDF

Similar mathematics books

Mathematik für Ingenieure und Naturwissenschaftler

Lothar P. Mathematik fuer Ingenieure und Naturwissenschaften, Band 1 (Vieweg, 2001)(ISBN 3528942363)(de)

Additional info for 6502 Assembly Language Subroutines

Example text

Use the base address START-1, where START is the lowest address actually occupied by the array. If, for example, we want to perform a summation starting at address START and continuing through LENGTH elements, we use the program ADBYTE LDX #LENGTH LDA #0 ;START AT THE END OF THE ARRAY ;CLEAR THE SUM INITIALLY START-1,X ;ADD THE NEXT ADBYTE ;COUNT CLC ADC ELEMENT DEX BNE ELEMENTS CHAPTER 1: GENERAL PROGRAMMING METHODS 31 Manipulating array elements becomes more difficult if you need more than one element during each iteration (as in a sort that requires interchanging of ele ments), if the elements are more than one byte long, or if the elements are them selves addresses (as in a table of starting addresses).

OPTION 2: Jump Through the Stack LDA ASL INDEX A ;GET INDEX ;DOUBLE IT BASE,X :GET FOR TWO-BYTE ENTRIES DESTINATION ADDRESS TAX INX LDA PHA ;SAVE MSB MSB OF IN STACK DEX LDA BASEfX ;GET LSB LSB OF DESTINATION PHA ;SAVE IN RTS ;TRANSFER CONTROL TO ADDRESS STACK DESTINATION This alternative is awkward for the following reasons: • RTS adds 1 to the program counter after loading it from the stack. Thus, the addresses in the table must all be one less than the actual values to which you wish to transfer control.

LDA INDEX ;GET ASL A ;DOUBLE INDEX INDEX FOR 2-BYTE ENTRIES TAX LDA (BASE,X) ;LOAD FROM INDEXED INDIRECT ADDRESS You can handle indexing into longer arrays by using the postindexed (indirect indexed) mode. Here we must construct a base address with an explicit addition before indexing, since the 6502's index registers are only 8 bits long. Example Load the accumulator from the element of an array defined by a starting address BASE (BASEH more significant byte, BASEL less significant byte) and a 16-bit index in memory locations INDEX and INDEX+1 (MSB in INDEX-f 1).

Download PDF sample

Rated 4.79 of 5 – based on 32 votes