Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
 Welcome to our latest new user maak ! (Registered 2024-04-18) You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > Kick Assembler: Creating Binary Header
2018-03-20 08:58
Raistlin

Registered: Mar 2007
Posts: 549
Kick Assembler: Creating Binary Header

Does anyone know if there's an easy way to append a binary-format header to a Kick Assembler generated file..?

At the top of my ASM, I have:-

// efo header
.byte 'E','F','O','2' // fileformat magic:4
.byte 0,0
.byte <Entry, >Entry
.. more data ..

*= $0200 "MainEntry"
Entry:
lda #$3e
.. rest of code


However .... unless I put "*= $01e4" at the top of the file, the binary header ends up defaulting to $1000 .. and goes -after- my code block in the binary file.

I use the "-binfile" option in KickAssembler to generate a binary file - all that this does, of course, is to strip the 2-byte header from the PRG:-

java -jar KickAss.jar SourceCode\Main.asm -odir ..\Intermediate -o Intermediate\main.efo -binfile

It "sort of" works to do the *=$01e4 thing .. but it just feels like a huge unnecessary hack...
2018-03-20 13:44
Cruzer

Registered: Dec 2001
Posts: 1048
Don't think you can generate some data without specifying where to put it.

All I can help with is to reduce this line:
.byte <Entry, >Entry
To this:
.word Entry
:)
2018-03-20 14:07
lft

Registered: Jul 2007
Posts: 369
I haven't tried KickAss myself, so I don't know to achieve that. I'm sure it's possible somehow.

But, at least for the time being, does your part really have to start at $200? Is it a problem if it starts one EFO-header's worth of bytes later?
2018-03-20 15:20
TWW

Registered: Jul 2009
Posts: 541
Uncertain if this helps, but I use kickass to generate cartridge headers and bank headers. Look at the easyflash topic for info if relevant.
2018-03-20 15:59
Raistlin

Registered: Mar 2007
Posts: 549
@LFT: yeah, that's what I'm doing now... it just feels like KickAss should be able to do this - but I can't see from the docs that it can...

@TWW: I took a look. Some nice work there - but it doesn't look quite the same...
2018-03-20 16:12
Scan

Registered: Dec 2015
Posts: 110
Quote: @LFT: yeah, that's what I'm doing now... it just feels like KickAss should be able to do this - but I can't see from the docs that it can...

@TWW: I took a look. Some nice work there - but it doesn't look quite the same...


It should work, are you using the most recent version of Kick Assembler? Here it compiles without problem to $01e4 when I put *= $01e4 in front of it.

If you need to use -binary option you can just put this on top of your source:
.word $01e4
, so the first 2 bytes of the binary will point to the offset where you want the header to be loaded.

2018-03-20 16:27
Raistlin

Registered: Mar 2007
Posts: 549
Yep. The problem is, though, that the EFO Header is of a variable size and needs to lie exactly before the code so that Spindle (LFT's IRQ Loader) can handle it. As your example has $01ec-$01ff unused, ie. blank space in the resultant file, it won't work with Spindle currently.

Plus, as I add more files to the project, I always need to think about the size of the header I'm using and the start address of the code..

-if- Kick Assembler could output something to the output file, ignoring .pc completely, then that would be fantastic .. or if Spindle could cope with this otherwise somehow.

The alternative is that I switch assembler to use XA, which Spindle uses, but I've already switched assembler twice in the last month and have grown quite fond of Kick Assembler now ;-)
2018-03-20 17:08
Cruzer

Registered: Dec 2001
Posts: 1048
Is generating the header as a separate file and appending the two binaries together with a script an option? Otherwise, I would sugges asking in the Facebook group Retro Assembler, as that's where Slammer hangs out these days.
2018-03-20 17:20
TWW

Registered: Jul 2009
Posts: 541
Can't you calculate the size of the header file by subtracting Label_end - Label_start and pad if necessary?
2018-03-20 17:21
Raistlin

Registered: Mar 2007
Posts: 549
Yeah, that could be a way to do it. I’d rather KA let me do it more cleanly - but that would definitely work. Thanks :-)
2018-03-20 20:18
TWW

Registered: Jul 2009
Posts: 541
Here's one way to create a fixed size header/binary:

    .const FillByte    = $00
    .const BinarySize  = $20
    .const TextString  = "BlaBlaBla"

    .text TextString
    .fill BinarySize - textstring.size(),FillByte
2018-03-20 21:50
Raistlin

Registered: Mar 2007
Posts: 549
I don't believe fixed size will work .. the header includes an "information stream" at the end of variable size.. and the "actual" machine code must follow directly after that.

Sorry to trouble everyone .. I think, for now, appending the binary data outside of Kick Ass, for now, is probably the best solution...

Either that or I modify the Spindle source code to use a fixed size header instead (I can just make that fixed size larger than I'll ever need)...
2023-05-08 19:33
fidel

Registered: Feb 2016
Posts: 3
Hi,
probably my first post on CSDB so welcome everyone.

As I have started to learn myself how to use spindle+kickass I was trying to find out the answer for the same question recently and search engine pointed to this thread (I know it is old but I will share in case someone else will also trying to find the answer). It seems that the same method as for CRT generation should work quite well.

`// efo header
.byte 'E','F','O','2' // fileformat magic:4
.byte 0,0
.byte <main, >main

.pseudopc $1234 {
main:
lda #$3e
jmp main
}`
`[Default]
2000: 45 46 4f 32 - .byte 'E','F','O','2' // fileformat magic:4
2004: 00 00 - .byte 0,0
2006: 34 12 - .byte <main, >main
2008: a9 3e - lda #$3e
200a: 4c 34 12 - jmp main
`
java -jar C:\c64\kickass\v525\KickAss.jar -binfile -bytedump -showmem test.ka

As it is BIN output it does not matter that it starts emitting from $2000 as long as it is not exceeding $FFFF, but in that case I belive it could be set to start even from $0000. It will not change anything as well.
2023-05-11 10:21
fidel

Registered: Feb 2016
Posts: 3
Or in another way:

test2.ka

.label LOADADDR = $1000

.segment HEADER [start=$0000]

.text "EFO2" // fileformat magic
.word prepare // prepare routine
.word setup // setup routine
.word interrupt // irq handler
.word main // main routine
.word fadeout // fadeout routine
.word cleanup // cleanup routine
.word music_play // location of playroutine call
.byte 'M', 0, 0
.byte 0
.word LOADADDR

.segment CODE [start=LOADADDR]

main:
inc $d021
rts

dummy:
rts

.label prepare = dummy
.label setup = dummy
.label interrupt = dummy
.label fadeout = dummy
.label cleanup = dummy
.label music_play = dummy


.segment EFO [outBin="test2.efo", start=$0000]
.segmentout [segments = "HEADER"]
.segmentout [segments = "CODE"]


ByteDump.txt

******************************* Segment: Default *******************************
******************************* Segment: HEADER ********************************
[HEADER]
0000: 45 46 4f 32 - .text "EFO2" // fileformat magic
0004: 04 10 - .word prepare // prepare routine
0006: 04 10 - .word setup // setup routine
0008: 04 10 - .word interrupt // irq handler
000a: 00 10 - .word main // main routine
000c: 04 10 - .word fadeout // fadeout routine
000e: 04 10 - .word cleanup // cleanup routine
0010: 04 10 - .word music_play // location of playroutine call
0012: 4d 00 00 - .byte 'M', 0, 0
0015: 00 - .byte 0
0016: 00 10 - .word LOADADDR
******************************** Segment: CODE *********************************

1000: ee 21 d0 - main: inc $d021
1003: 60 - rts
1004: 60 - dummy,prepare,setup,interrupt,fadeout,cleanup,music_play:rts
********************************* Segment: EFO *********************************
[EFO]
0000: 45 46 4f 32 04 10 04 10 04 10 00 10 04 10 04 10 - .segmentout [segments = "HEADER"]
0010: 04 10 4d 00 00 00 00 10
0018: ee 21 d0 60 60 - .segmentout [segments = "CODE"]

test2.efo

PS C:\c64\tmp> xxd .\test2.efo
00000000: 4546 4f32 0410 0410 0410 0010 0410 0410 EFO2............
00000010: 0410 4d00 0000 0010 ee21 d060 60 ..M......!.``
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
Guests online: 96
Top Demos
1 Next Level  (9.8)
2 Mojo  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Comaland 100%  (9.6)
6 No Bounds  (9.6)
7 Uncensored  (9.6)
8 Wonderland XIV  (9.6)
9 The Ghost  (9.6)
10 Bromance  (9.6)
Top onefile Demos
1 It's More Fun to Com..  (9.9)
2 Party Elk 2  (9.7)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.5)
5 Rainbow Connection  (9.5)
6 TRSAC, Gabber & Pebe..  (9.5)
7 Onscreen 5k  (9.5)
8 Dawnfall V1.1  (9.5)
9 Quadrants  (9.5)
10 Daah, Those Acid Pil..  (9.5)
Top Groups
1 Oxyron  (9.3)
2 Nostalgia  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Logo Graphicians
1 Sander  (10)
2 Facet  (9.7)
3 Mermaid  (9.4)
4 Pal  (9.4)
5 Shine  (9.3)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.043 sec.