Assembler
From C64-Wiki
Assembler is a language which translates a CPUs native code in a human readable form. Not only the language but also the compiler is called Assembler. Turning the assembly source code into machine language is called "assemble". The reverse procedure is called "disassemble" which turns machine code in readable code.
Contents |
[edit] General
Every processor architecture (e.g. x86, risc) has its own functions and thereby differing assembler commands. Still most of them show similarities. Machine commands are built from numbers which are stored as Binary code in the computers memory. To make it possible to program with this commands each opcode has a short symbol called Mnemonics.
A assembler (compiler) translates these Mnemonics into their corresponding opcodes and data. An example:
*=$c000 lda #$00 ; load the number 0 into the accumulator register sta $d020 ; store the content of the accumulator in the register for the border color ...
... inside the RAM of the C64 this is represented like this:
Address Opcode + Operator(s) c000 A9 00 ; "C000" is the memory address, "A9" the Opcode, "00" the Operator c002 8D 20 D0 ; "C002" is the memory address, "8D" the Opcode, "20" and "D0" are Operators ...
... as Binary code from $c000
1010100100000000100011010010000011010000
Some assemblers for the C64 (e.g. TurboAssembler, ACME (crosscompiler)) translate not only the mnemonics but also provide macros to reduce the common workload.
[edit] Advantages / Disadvantages
[edit] Advantages
- As close to the machine as possible
- depending on the skill of the programmer extremely fast
- assembly programs are usually rather small
[edit] Disadvantages
- difficult to learn
- high workload
- not portable
Still assembler is worth learning. As byproduct you get to understand the inner workings of a computer. Assembler still has its uses today. Programming of drivers would be almost impossible without assembler.
[edit] Examples
Set screen colors to black ... (sys 49152)
*=$c000
lda #$00
sta $d020
sta $d021
rts
Play music (expecting player routine at $1000) ... (sys 49152)
*=$c000
sei
lda #<irq
ldx #>irq
sta $0314
stx $0315
cli
lda #$00
tay
tax
jsr $1000
rts
irq lda $d012
cmp #100
bne irq
jsr $1003
jmp $ea31
[edit] Critique
[edit] Links & Literature
- INPUT64 Assembler-Schule
- Codebase64
(Comprehensive collection of coding info for the C64)
- Assemble It!
- Downloadseite für den Smon und Infos zum Buch "Assembler ist keine Alchemie" (Buch, mit Leseproben)
