Hi, i'm from argentina and i need help with some stuff that i cannot understand with a difference that i found between the files that i assembled with two diferents assemblers.
(Ah, btw, sorry for my bad english, if you don't understand something, i'll try to explain my thoughts in a better (or diferent) way)
Ok, this is the problem.
I was coding in NESASM for a while and without problems, when i realized that exist a REAL assembler called ca65 (from cc65.org).
I was very happy with my discover until i began having serious problems with it.
The same code (NesASM code and ca65 code) put the exact SAME info in the .nes file, but only ONE byte changes between them.
It's the mysterious byte $80 at $40D0, that nesasm put in the .nes file and ca65 not. Obiously i'm doing something wrong and i can't figure out where is the problem.
I'm going to put here my config file for ca65 and my source code:
here goes now my source code:
; -
; Work.asm
; -
; Alekhine d-phenze*
; Para CC65 (ca65.exe & ld65.exe), Nintendo
; -
; Consta de los siguientes archivos:
; ----------------------------------
; % romstrct.cfg (Estructura del rom)
; % work.asm (este archivo)
; % make.bat (crea la rom)
; ----------------------------------
;
; Esto genera algo en pantalla, demostrando
; que esta configuracion genera la ROM nes :)
; o sea, si anda, tenemos una rom Nes para
; codear ;)
; ******************************************************
; Header iNES 10 bytes
; ******************************************************
.SEGMENT "HEADER"
.byte $4e, $45, $53, $1a ; 'NES' + 1A
.byte $01 ; 16kb PRG-ROM Numero de paginas
.byte $01 ; 8kb CHR-ROM Numero de paginas
.byte $01 ; Byte de control de la Rom #1
.byte $00 ; Byte de control de la Rom #2
; Byte #1: $MO
; M Define el numero de mapper
; O Define las opciones de la rom.
; El byte #2 es preferible
; dejarlo en $00 hasta ahora
.byte $00, $00, $00, $00 ; Muchos ceros
.byte $00, $00, $00, $00 ; muchos ceros mas
.SEGMENT "CODE"
STARTUP = $80
; *****
; This is a routine ONLY to make sure that it worked in a
; random emulator
; *****
lda #%00001000 ; Los seteos se pueden
sta $2000 ; ver en documentos
lda #%01011110 ; tecnicos sobre el PPU
sta $2001
; sonido
lda #$FF ; typical
sta $4000 ; write
lda #%11011011 ; % means binary number, remember the '#' for immediate values.
sta $4001 ; immediate means "not an address, just a number".
lda #$A5
sta $4002
lda #$AB
sta $4003
lda #%00000001
sta $4015
infinito:
jmp infinito
.SEGMENT "CODE"
.SEGMENT "RODATA"
;********
; Here i put garbage for viewing where the linker put
; the info in the binary file
; i comment the .byte statament where are garbage
; every time i compile the source
;********
.byte $AA,$AA,$AA ; Basura para identificar
; segmentos
.SEGMENT "DATA"
ourpal: .incbin "our.pal"
.byte $BB,$BB,$BB ; Basura para identificar
; segmentos
.SEGMENT "VECTORS"
.word 0
.word STARTUP
.word 0 ; Basura para identificar
; segmentos
.SEGMENT "CHARS"
.incbin "our.bkg"
.incbin "our.spr"
.SEGMENT "BSS"
; *** more garbage, remember, i comment this
; before compile
; i use these bytes to trace where the linker put the info
; in the final binary
.byte $EE,$EE,$EE ; Basura para identificar
; segmentos
and now, the .bat
Ok, when i compile this, the ca65 make a exact .nes with the .nes
that i make with nesasm
Any clue?
tnx for your time =)
(Ah, btw, sorry for my bad english, if you don't understand something, i'll try to explain my thoughts in a better (or diferent) way)
Ok, this is the problem.
I was coding in NESASM for a while and without problems, when i realized that exist a REAL assembler called ca65 (from cc65.org).
I was very happy with my discover until i began having serious problems with it.
The same code (NesASM code and ca65 code) put the exact SAME info in the .nes file, but only ONE byte changes between them.
It's the mysterious byte $80 at $40D0, that nesasm put in the .nes file and ca65 not. Obiously i'm doing something wrong and i can't figure out where is the problem.
I'm going to put here my config file for ca65 and my source code:
Code:
# romstruct.cfg (for the linker)
# Distribucion de SEGMENTos la ROM de Nintendo
# Alekhine d-phenze
# Asignacion de cachos de memoria
MEMORY
{
ZP:
start $02
size $1A
type rw
define yes;
# Header iNES
HEADER:
start $00
size $10
file %O
fill yes;
# 2 bancos ROM de 16kb
# - startup
# - code
# - rodata
# - data (load)
BANK0:
start $8000
size $7FF4
file %O
fill yes
define yes;
# Vectores de Hardware al final
# de el segundo ROM de 2kb
BANK1:
start $FFF4
size $C
file %O
fill yes;
# 1 Banco CHR de 8kb
CHRBANK:
start $0000
size $2000
file %O
fill yes;
# SRAM 2k standard (-zeropage)
# $0100-$0200 cpu stack
# $0200-$0500 3 paginas para el buffer de escritura de la PPU
# $0500-$0800 3 paginas para stack de parametros de cc65
SRAM:
start $0500
size $0300
define yes;
# SRAM banco 8k adicionales
# - data (run)
# - bss
# - heap
RAM:
start $6000
size $2000
define yes;
}
# Estructura de la ROM de Nintendo
SEGMENTS {
HEADER: load = HEADER, type = wprot;
STARTUP: load = BANK0, type = wprot, define = yes;
CODE: load = BANK0, type = wprot, define = yes;
RODATA: load = BANK0, type = wprot, define = yes;
DATA: load = BANK0, run = RAM, type = rw, define = yes;
VECTORS: load = BANK1, type = rw;
CHARS: load = CHRBANK, type = rw;
BSS: load = RAM, type = bss, define = yes;
ZEROPAGE: load = ZP, type = zp;
}
FEATURES {
CONDES: segment = RODATA,
type = constructor,
label = __CONSTRUCTOR_TABLE__,
count = __CONSTRUCTOR_COUNT__;
CONDES: segment = RODATA,
type = destructor,
label = __DESTRUCTOR_TABLE__,
count = __DESTRUCTOR_COUNT__;
}
SYMBOLS {
__STACKSIZE__ = $0300; # Stack de 3 paginas
}
# Distribucion de SEGMENTos la ROM de Nintendo
# Alekhine d-phenze
# Asignacion de cachos de memoria
MEMORY
{
ZP:
start $02
size $1A
type rw
define yes;
# Header iNES
HEADER:
start $00
size $10
file %O
fill yes;
# 2 bancos ROM de 16kb
# - startup
# - code
# - rodata
# - data (load)
BANK0:
start $8000
size $7FF4
file %O
fill yes
define yes;
# Vectores de Hardware al final
# de el segundo ROM de 2kb
BANK1:
start $FFF4
size $C
file %O
fill yes;
# 1 Banco CHR de 8kb
CHRBANK:
start $0000
size $2000
file %O
fill yes;
# SRAM 2k standard (-zeropage)
# $0100-$0200 cpu stack
# $0200-$0500 3 paginas para el buffer de escritura de la PPU
# $0500-$0800 3 paginas para stack de parametros de cc65
SRAM:
start $0500
size $0300
define yes;
# SRAM banco 8k adicionales
# - data (run)
# - bss
# - heap
RAM:
start $6000
size $2000
define yes;
}
# Estructura de la ROM de Nintendo
SEGMENTS {
HEADER: load = HEADER, type = wprot;
STARTUP: load = BANK0, type = wprot, define = yes;
CODE: load = BANK0, type = wprot, define = yes;
RODATA: load = BANK0, type = wprot, define = yes;
DATA: load = BANK0, run = RAM, type = rw, define = yes;
VECTORS: load = BANK1, type = rw;
CHARS: load = CHRBANK, type = rw;
BSS: load = RAM, type = bss, define = yes;
ZEROPAGE: load = ZP, type = zp;
}
FEATURES {
CONDES: segment = RODATA,
type = constructor,
label = __CONSTRUCTOR_TABLE__,
count = __CONSTRUCTOR_COUNT__;
CONDES: segment = RODATA,
type = destructor,
label = __DESTRUCTOR_TABLE__,
count = __DESTRUCTOR_COUNT__;
}
SYMBOLS {
__STACKSIZE__ = $0300; # Stack de 3 paginas
}
here goes now my source code:
Code:
; -
; Work.asm
; -
; Alekhine d-phenze*
; Para CC65 (ca65.exe & ld65.exe), Nintendo
; -
; Consta de los siguientes archivos:
; ----------------------------------
; % romstrct.cfg (Estructura del rom)
; % work.asm (este archivo)
; % make.bat (crea la rom)
; ----------------------------------
;
; Esto genera algo en pantalla, demostrando
; que esta configuracion genera la ROM nes :)
; o sea, si anda, tenemos una rom Nes para
; codear ;)
; ******************************************************
; Header iNES 10 bytes
; ******************************************************
.SEGMENT "HEADER"
.byte $4e, $45, $53, $1a ; 'NES' + 1A
.byte $01 ; 16kb PRG-ROM Numero de paginas
.byte $01 ; 8kb CHR-ROM Numero de paginas
.byte $01 ; Byte de control de la Rom #1
.byte $00 ; Byte de control de la Rom #2
; Byte #1: $MO
; M Define el numero de mapper
; O Define las opciones de la rom.
; El byte #2 es preferible
; dejarlo en $00 hasta ahora
.byte $00, $00, $00, $00 ; Muchos ceros
.byte $00, $00, $00, $00 ; muchos ceros mas
.SEGMENT "CODE"
STARTUP = $80
; *****
; This is a routine ONLY to make sure that it worked in a
; random emulator
; *****
lda #%00001000 ; Los seteos se pueden
sta $2000 ; ver en documentos
lda #%01011110 ; tecnicos sobre el PPU
sta $2001
; sonido
lda #$FF ; typical
sta $4000 ; write
lda #%11011011 ; % means binary number, remember the '#' for immediate values.
sta $4001 ; immediate means "not an address, just a number".
lda #$A5
sta $4002
lda #$AB
sta $4003
lda #%00000001
sta $4015
infinito:
jmp infinito
.SEGMENT "CODE"
.SEGMENT "RODATA"
;********
; Here i put garbage for viewing where the linker put
; the info in the binary file
; i comment the .byte statament where are garbage
; every time i compile the source
;********
.byte $AA,$AA,$AA ; Basura para identificar
; segmentos
.SEGMENT "DATA"
ourpal: .incbin "our.pal"
.byte $BB,$BB,$BB ; Basura para identificar
; segmentos
.SEGMENT "VECTORS"
.word 0
.word STARTUP
.word 0 ; Basura para identificar
; segmentos
.SEGMENT "CHARS"
.incbin "our.bkg"
.incbin "our.spr"
.SEGMENT "BSS"
; *** more garbage, remember, i comment this
; before compile
; i use these bytes to trace where the linker put the info
; in the final binary
.byte $EE,$EE,$EE ; Basura para identificar
; segmentos
and now, the .bat
Code:
ca65 work.asm
ld65 -C romstrct.cfg work.o
copy /Y a.out work.nes
ld65 -C romstrct.cfg work.o
copy /Y a.out work.nes
Ok, when i compile this, the ca65 make a exact .nes with the .nes
that i make with nesasm
Any clue?
tnx for your time =)