ca65汇编器和ld65链接器 [英] ca65 assembler and ld65 linker

查看:136
本文介绍了ca65汇编器和ld65链接器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

然后我开始在Windows上使用ca65汇编器和ld65链接器为在VICE模拟器上运行的Commodore C64计算机创建二进制代码。

I'm beginning to use then ca65 assembler and ld65 linker on WIndows to create binary code for Commodore C64 computer, running on VICE emulator.

我在文件 basic2.s中写了这个小的 hello world源代码。

I write this small "hello world" source on file "basic2.s"

;--------------------------------------
; objetivo: assembly a header BASIC program
;           to run binary code
;
; assembler: ca65
; http://cc65.github.io/doc
;
; v101-c101 2018-08-09 13:50:53 A.Alonso
;-----------------------------------------------------
PRINTTOKEN   = $99
SYSTOKEN     = $9e
chrout       = $ffd2

            .org  $0801
            ;
Linea10:    .word Linea20
            .word 10
            .byte PRINTTOKEN
            .byte 39," NOMBRE PROGRAMA  ",39
            .byte 0
            ;--
Linea20:     .word LineaEnd
            .word 20
            .byte SYSTOKEN
            .byte " 2089"
            .byte 0
            ;--
LineaEnd:   .word 0    ; fin de lineas
            .word 0    ; fin de programa
            ;--
            ;
Main:       ldx #0
ciclo1:     lda saludo,x
            jsr chrout
            inx
            cpx #<(saludofin-saludo)
            bcc ciclo1
salida:     rts
saludo:    .byte "--- HOLA MUNDO! -----"
saludofin: .byte 0

我可以使用以下命令进行组装:

I can assemble with the command:

ca65 -t c64 basic2.s

ca65 -t c64 basic2.s

并生成 basic2.o

And generate "basic2.o"

我阅读了链接器ld65的文档,这令人困惑

I read the documentation of the linker ld65 and it's confusing

我尝试失败:

1-使用命令

ld65 basic2.o

错误是:

ld65: Error: Memory configuration missing

2-使用命令

ld65 -C c64-asm.cfg basic2.o

错误是:

ld65: Warning: c64-asm.cfg(21): Segment `LOADADDR' does not exist
Unresolved external `__LOADADDR__' referenced in:
  c64-asm.cfg(5)
ld65: Error: 1 unresolved external(s) found - cannot create output file

谢谢

推荐答案

文档有点分散,但是

当您指定配置时,它将确定输出对象的格式。在c64-asm.cfg中是:

When you specify a config it determines the format of the output object. And in c64-asm.cfg is:

__LOADADDR__: type = import;

此配置期望某些内容可以导出LOADADDR以便构建PRG标头。如果链接到c64.lib(等),则将其导出(硬编码为$ 801)。否则,您需要自己提供。

This config expects something to export LOADADDR so it can build the PRG header. If you link with c64.lib (etc) then that exports it (hardcoded to $801). Otherwise you need to supply it yourself.

一种方法是在命令行上使用--start-addr作为Laurent H.和文档建议,但这很奇怪。相反,您可以获取汇编语言源以将其导出。我不太了解CC65,但是:

One way is on the command line with --start-addr as Laurent H. and the docs suggest, but that's fiddly. Instead you can get your assembly language source to export it. I don't know CC65 well, but:

.org    $0801
.export LOADADDR = *

此外,您还可以使用以下代码生成一行:

Also, you can build in one line with:

cl65.exe -o basic2.prg -t c64 -C c64-asm.cfg basic2.s

这篇关于ca65汇编器和ld65链接器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆