Emu64 Help Banner

Emu64 Portal Emu64 Forum Emu64 Download Emu64 Help
 


Tools: Cross Assembler

Menu: Tools → Cross Assembler

Quotes from the C64 wiki article: Assembly language



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. […]

Source: http://www.c64-wiki.com/index.php/Assembler


Quotes from the C64 wiki article: Crossassembler



A cross assembler is an assembler that runs on another host platform like MS-DOS, Windows or Linux and creates machine code for another platform, like the C64.[…]

Source: http://www.c64-wiki.de/index.php/Crossassembler (german)




When you click on Cross Assembler in the tools menu of Emu64 a new cross assembler window opens up. All programs coded run on Emu64 but also on a real C64.

Image: Cross Assembler Window (Editor/Compiler)

This window is split into two parts. The top part is an editor where you can write your source code and it is possible to assemble the code directly.

Use the menu item File to load or save source code. When loading files with .txt or .asm index are shown only. The Cross Assembler Editor saves yourcode as .asm files. The .asm file is the same as a text file and you can open it with other text editors.

The editor has all the features a normal texteditor has.

The Cross Assembler is a 2 Pass assembler that is inspired by TurboAss. You can compile your sourcecode with the menu item Assemble. The Code is then translated into 6510 machine code. You can run the program directly in the C64 screen and test it with the help of the Emu64 debugger. And you can also export the program as PRG.

The lower part shows information about the assembling.

Pseudo Ops

PseudoOpcodes are commands that influence the assembling. There has to at least one space character or tab after every Pseudo Opcode. Otherwise the assembler shows an error. It is not allowed to have a label definition within the same line in front of a Pseudo Opcode. Use an extra line for these. It doesn't matter of you capitalize your Pseudo Opcodes or not.

List of Emu64 Cross Assembler Pseudo Opcodes
.BYTE Values are loaded into memory 1:1
.TEXT a text is written into memory as byte value
.MESSAGE text output on the 2nd pass in the lower window part
.VAR variable output in the lower window part
.SAVE saves the program after assembling
.BASIC automatically creates a basic start
.BASICLOADER creates a BASIC-Loader that you can then input by hand

Pseudo Opcode: .BYTE

The values are loaded into the memory 1:1.

The values have to be between 0 - 255. All values are separated by a comma. You can use the following number formats: decimal, hex ($), binary (%) or string ('A').

Example for .BYTE



Rasterbas
.BYTE 0,1,3,5,2,3,7,14,5,7,0,2

sprite
.byte %00110011,%00011011

.BYTE 1,$23,$11,%00110011,'Z'

Pseudo Opcode: .TEXT

The text between the “ “ is written into memory as byte value.

Example for .TEXT



formatstring
.text „n:NEUE DISK,AA“

Pseudo Opcode: .MESSAGE

the text between the “ “ is put out on the 2nd pass in the lower window part.

Example for .MESSAGE



.message „start the program with SYS 49152“


Output in the lower window:

User Message: start the program with SYS 49152

Pseudo Opcode: .VAR

The value of a variable is put out in the lower window part.

Example for .VAR



*=$c000

vic = $d000

start

lda #$00
sta vic+21

end

.var vic
.var start
.var end


Output in the lower window:

vic 16Bit [$D000 (53248)] 8Bit [$00 (0)]
start 16Bit [$C000 (49152)] 8Bit [$00 (0)]
end 16Bit [$C005 (49157)] 8Bit [$05 (5)]

Pseudo Opcode: .SAVE

After the assembling was positive this saves the program under the name specified.

Example for .SAVE



.save c:\test.prg
*=$c000

start
inc $d020
jmp start



After the assembly was successful a file called „test.prg“ is in the root directory of C:\. This PRG can be used with every other Emulator now.

Pseudo Opcode: .BASIC

Automatically creates a basic start.

So then the program is at $0801 and you can start it with RUN. You can change the look of the BASIC-Line. The assignment *= is not necessary then.

The first paramter is for the BASIC line number of the starting line.

The second parameter is for the jump point. The BASIC Line then shows SYS (jump point).

The third parameter can be used for a small text.

Example for .BASIC



.basic 1974,start,“-= BY ANDONE [2007] =-„

start
lda #$00
sta $d020
sta $d021
rts



After the assembly was successful you can enter LIST in the C64.

Then you see:
1974 SYS2085 -= BY ANDONE [2007] =-

Pseudo Opcode: .BASICLOADER

Creates a BASIC-Loader to hack into the C64 later on.

The assembly program shpuld not start at $0801 otherwise the BASIC-Loader would overwrite itself, the assembler would create the loader though. The usual loader addresses are $C000 and $9000.

Example for .BASICLOADER



.basicloader c:\schwarz.txt

*=$c000

start
lda #$00
sta $d020
sta $d021
rts



After the assembly was successful a file called „schwarz.txt“ can be found in the root directory of C:\. You can open it with ever text editor.

The text file is created:

10 C=0:D=0:Z=100
20 FOR A=0 TO 8
30 READ B:D=D+B:POKE 49152+A,B:C=C+1
40 IF A=8 THEN READ B:IF B<>D GOTO 70
50 IF C<10 GOTO 90
55 IF A=8 THEN PRINT „ALLES OK“:END
60 READ B:IF B=D GOTO 80
70 PRINT „CHECKSUMMEN FEHLER IN“;Z:END
80 C=0:D=0:Z=Z+1
90 NEXT:PRINT „ALLES OK“
100 DATA 169,0,141,32,208,141,33,208,96,1028

The actual program is in the DATA lines. The assembler also creates checksums so that errors while entering the code are recognised and shown.




Emu64 Help V4.xx Navigation V4.xx: Table of Content
Portal: old-archiv

help text for Emu64 up to version 4.32.

en/old-archiv/emu64_v4/tools-cross_assembler.txt · Zuletzt geändert: 2013/04/20 11:26 (Externe Bearbeitung)
 
Falls nicht anders bezeichnet, ist der Inhalt dieses Wikis unter der folgenden Lizenz veröffentlicht: CC Attribution-NonCommercial-NoDerivs 3.0 Unported License
credits to Impressum