LASERACTIVEGUY wrote:
I am hopeless with 6502... I come from the Apple II world but for the most part I think 6502 is universal, at least to my understanding.
Have you read the official Western Design Center
programming manual? It covers virtually all aspects of programming the 6502, 65C02 and 65C816 in assembly language and should be part of your library. It's a well-written manual that doesn't assume very much on the part of the reader.
Quote:
Here is an example...the numbers are expressed in DEC although I know they need to be in hex when compiling...
WARNING! Pedantry Alert!One of the first steps in becoming a good programmer is understanding and using the correct terminology. Doing so, especially in print, will assist in getting across your thoughts when discussing programming topics in an on-line forum.
- Assembly language is called assembly language, not assembly, assembler or machine language.
- Your program as written in a text editor is the source code.
- You assemble your source code, not compile it.
- Assembly is the process of translating the human-readable instructions in your source code into the binary equivalents that are specific to the particular microprocessor being programmed.
- The program that assembles your source code is referred to as an assembler, not a compiler (they are two very different animals).
- The output from the assembler is (usually) written into an object file, which contains object code. Object code may be raw binary that can be executed if loaded into memory, or may be some sort of textual representation of the raw binary. If the object code is the latter, it must be processed by a loader to produce an executable binary.
As Garth noted, most assemblers will cheerfully accept numbers in decimal, hexadecimal, binary or more rarely, octal. In some cases, one number base may be preferable over another. For example, when writing code that will be processing I/O chip registers I often use binary, as it helps me to visualize which bits are being handled. Experience will eventually teach you when to use a particular number base.
GARTHWILSON wrote:
...although I've never seen any practical use in octal in this equipment.
My first encounter with octal was on the DEC PDP-11, which seemed to strongly favor octal notation. Linux and UNIX continue to perpetuate octal notation, for example, in the
chmod command, which changes file mode bits. As the permissions bits are acted upon in groups of three, octal notation makes some sense, since the largest numeral in octal is
7, which is
%111 in binary. However, I personally find it a nuisance to have to mentally convert binary to octal when I know which file mode bits I want to change.
As you noted, octal is very seldom used in 65xx programs. If writing in assembly language it's just as easy to express masks and such in binary.