MainComputersSystemsAtari › 8-bit ATARI Assembly Language

8-bit ATARI Assembly Language

Edit Page
Report
Scan day: 07 February 2014 UTC
18
Virus safety - good
Description: Assembly language tips and tricks.
If you ever have occasion to write relocatable code for use in machine language subroutines for BASIC, or want to, below are some routines and tools that might help. Writing relocatable code in 6502 assembly language has always been difficult. As routines get larger the difficulties become greater. The JMP and JSR opcodes use absolute addresses which are not relocatable. The branch is the only relocatable jump available on the 6502. A branch can only jump forward 127 bytes or backward 128 bytes. The two files below address this problem. The first one is RELJMP and the second is RELJSR. They both will jump up to 32,768 ($8000) bytes in both directions. I haven't tried them that far. I have only tested them with jumps of only a few bytes, so far . They have both been tested for relocatability. RELJMP uses the RTS opcode as a software programable jump. At runtime (the time when the machine code is actually running), your code is fixed in memory. The only thing RELJMP needs to know is the starting address of the code at runtime. The RELJMP macro is placed in code like this: RELJMP ORGADR, LABEL, RELSTART ORGADR is the origin of the program as it is assembled. Place a label at the start of your program, so that it has the same address as the *= or ORG opcodes. LABEL is the label you want to jump to. RELSTART is location of the starting address at runtime. At assembly RELJMP subtacts ORGADR from LABEL. This is the displacement to LABEL. It then subtracts 1. This is because RTS adds 1 to the address. To the resultant number it adds the runtime address. The total is the current address of of LABEL-1. This number is now pushed into the stack. RTS pulls the number from the stack, adds one to it then jumps to LABEL. ORGADR and LABEL are pretty straight forward, but where do you find RELSTART. You can get it from memory at $D4 or pass it directly from BASIC. When BASIC passes control to your code, it stores the runtime starting address at $D4 and $D5 in the usual low-byte, high-byte format. You can use $D4 as RELSTART.
Size: 2048 chars

Contact Information

Phone&Fax:
Address:
Extended:

WEBSITE Info

Page title:8-bit ATARI Assembly Language
Keywords:atari, 8-bit, utilities, 6502, assembler, assembly, assembly language, 400, 800, XL, XE
Description:8-bit ATARI Assembly Language
IP-address:66.117.151.58

WHOIS Info

NS
Name Server: A.DNS.GANDI.NET
Name Server: B.DNS.GANDI.NET
Name Server: C.DNS.GANDI.NET
WHOIS
Status: clientTransferProhibited
Date
Creation Date: 14-apr-1998
Expiration Date: 13-apr-2019