which compiler should I use to compile this code? C64

2 posts / 0 new
Last post
Offline
Last seen: 4 hours 14 min ago
Joined: Jan 11 2025 - 14:57
Posts: 12
which compiler should I use to compile this code? C64
AttachmentSize
Plain text icon Code C64.txt6.63 KB

here is the file 

mmphosis's picture
Online
Last seen: 54 min 45 sec ago
Joined: Aug 18 2005 - 16:26
Posts: 446
assembler

That code looks like output from a 6502 assembler. We usually compile code written in a programming language to assembly code using a compiler. The next step in compiling can be assembling this output assembly code to a binary. I would filter that assembler output into assembly code that an assembler can use and then assemble it using a 6502 assembler.

 

Download:

curl -o code-c64.txt https://www.applefritter.com/files/Code%20C64.txt

 

Filter:

The following piped sed commands will remove carriage returns,  covert hex labels to origin (ORG) hex addresses, covert CA65-style .byte directives into Merlin32-style ASC directives, remove the assembler output so that there is only assembly code, covert the LAX undocumented opcode into an ASC directive for Merlin32.

sed -e 's/\r$//' \

-e 's/^[0-9a-f][0-9a-f][0-9a-f][0-9a-f] / ORG $&\n/' code-c64.txt \

| sed -e 's/.byte / ASC /' \

-e 's/.C:[0-9a-f][0-9a-f][0-9a-f][0-9a-f]   .. .. ..   / /' \

-e 's/ LAX / ASC $A7,/' > code.txt

 

Assemble:

merlin32 '' code.txt

 

Run:

6502 PC=80d 800 code

                              A=AA X=00 Y=00 S=00 P=22 PC=080D  0

080D- A9 0F     LDA #$0F      A=0F X=00 Y=00 S=00 P=20 PC=080F  2

080F- A8        TAY           A=0F X=00 Y=0F S=00 P=20 PC=0810  4

0810- A2 08     LDX #$08      A=0F X=08 Y=0F S=00 P=20 PC=0812  6

0812- 20 00 FE  JSR $FE00     A=0F X=08 Y=0F S=FE P=20 PC=FE00  12

FE00! end

 

Log in or register to post comments