Dan Moos wrote:
Why DO I have to give a specific program counter location? If I put the binary in ROM, isn't it at the specific address I burn it to no matter what I say in the code?
An explanation might help.
My POC V1.1 has ROM from $00E000-$00FFFF. I use a 256Kb × 8 EPROM, whose internal addresses extend from $0000-$7FFF. In order for the ROM to appear at $00E000 in MPU address space, A0-A12 of the ROM are wired to A0-A12 of the MPU. The ROM's chip select is wired to the glue logic so it is asserted any time the address is $00E000-$00FFFF, that is, if A15-A13 is
%111. That makes a byte at $0000 in the ROM appear at $00E000 in MPU address space, a byte at $0001 in the ROM appear at $00E001, etc. Hence the code that is to be burned into the ROM must be assembled with a starting address of $E000 in order for jump targets and static data references (e.g., text strings) to make sense to the MPU. If the code were assembled at $0000, none of the jump target addresses would be valid, since it is seeing the code at $00E000, not $0000. Ditto for static data references.
Hence when I assembled POC V1.1 firmware I use $00E000 as the starting address, using the assembler directive
*= $00E000. The resulting object code is written into a binary file, starting at byte $00 in the file. The EPROM burner software loads that binary file into a buffer at $0000 and then into the EPROM starting at $0000.
Quote:
In imple (sic) terms, what is the purpose of the *= statement? I assume it's an assembler directive, and not an opcode, right?
The
* = statement sets the program's origin so the assembler will know where to start assembly. In almost all assemblers,
* refers to the current address at which instructions and data are being assembled. The need for this feature is due to the fact that many instructions refer to specific locations from which to load data, or to jump to (e.g.,
JSR SOME_SUBROUTINE). These absolute addresses are dependent on at what point assembly started, which you set with
* =.
Quote:
Why does the ACME assembler give my an error unless I have a *= $(some address) at the beginning. Is this a neccesity of 6502 assembly, or ACME?
The assembler doesn't know at which address to start assembly unless you tell it. Hence the error.
Quote:
what does .ORG do specfically, and how come if I put , say, .ORG $4000 in my code, I get a "implicit label definition not in left most column" error.?
Some assemblers recognize
.ORG as a synonym for
* =. I'm not familiar with Acme, so I can't tell you why that error is occurring. It could be because Acme has some requirements on how fields are place in a line of code. As general rule, labels and symbols should start at the left-most column, and all other fields at least one column away from the left margin, e.g.,:
Code:
LABEL = 12345 ;set LABEL to 12345
;
SYMBOL LDA #LABEL ;load accummulator with 12345
The above is the format that I have used for some 40 years.
Incidentally, it's helpful to know and use the correct terminology when discussing programming. The above is a simple example of an
assembly language (not "assembly," which term refers to a process, or "assembler," which is a piece of software) program. The above code is called
source code. You use an
assembler to
assemble (not "compile") your source code, resulting in the generation of
object code. The object code may be
machine-executable (i.e.,
machine code) or may be in a
relocatable format that is subsequently processed by a
linker to generate machine code. The machine code is what is loaded into memory (RAM or ROM) for the MPU to execute. Most 65C02 machine code is position-dependent, which means it can be run from only one location in memory without error. Position-independent code can be loaded into memory at any convenient location and will run without error.