Machine Code is the base code of the 6502 processor at the heart of the VIC20. It is composed purely of 8bit numbers which the processor reads and then executes according to the current state of the processor. Many VIC20 programs are written in Machine Code, the VICs BASIC interpreter and Kernal are Machine Code programs. Unlike BASIC machine code is very fast. To run a BASIC program the VIC20 must read and interpret each BASIC token. Which may take many Machine Code instructions.
The same 5 Byte machine code program written in Hexadecimal, Binary and Decimal
Hex A9 08 8D OF 90 Binary 10101001 00001000 10001101 00001111 10010000 Decimal 169, 8, 141, 15, 144
The rest of this article mainly uses Hexadecimal numbers, these are prefixed by the $ sign. So $80 is hex 80.
Assembly is just human readable machine code. It is converted into numbers by either a program or a human.
Assembly that the above machine code was created from lda #$08 sta $900F
In order to convert from Assembly to Machine code one needs to know the opcodes for the instructions used. $A9 is the code for load accumulator immediate.
See this page for a full listing.
|Mnemonic||Hex||Addressing type||Instruction length||Execution time|
|ADC #$44||$69||Immediate||2 bytes||2 cycles|
|ADC $44||$65||Zero Page||2 bytes||3 cycles|
|ADC $44,X||$75||Zero Page,X||2 bytes||4 cycles|
|ADC $4400||$6D||Absolute||3 bytes||4 cycles|
|ADC $4400,X||$7D||Absolute,X||3 bytes||4+ cycles|
|ADC $4400,Y||$79||Absolute,Y||3 bytes||4 cycles|
|ADC ($44,X)||$61||Indirect,X||2 bytes||6 cycles|
|ADC ($44),Y||$71||Indirect,Y||2 bytes||5+ cycles|