Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
 Welcome to our latest new user psenough ! (Registered 2024-05-21) 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: 575
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...
 
... 10 posts hidden. Click here to view all posts....
 
2018-03-20 21:50
Raistlin

Registered: Mar 2007
Posts: 575
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......!.``
Previous - 1 | 2 - Next
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
Hok/Remember
Bitbreaker/Performers
Tom-Cat/Nostalgia
Dano/Padua
bepp/ΤRIΛD
Visage/Lethargy
c0zmo
Tim/Silicon Limited
hedning/G★P
Guests online: 102
Top Demos
1 Next Level  (9.8)
2 13:37  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Mojo  (9.6)
6 Comaland 100%  (9.6)
7 Uncensored  (9.6)
8 No Bounds  (9.6)
9 Bromance  (9.5)
10 Wonderland XII  (9.5)
Top onefile Demos
1 Layers  (9.6)
2 Cubic Dream  (9.6)
3 Party Elk 2  (9.6)
4 Copper Booze  (9.6)
5 TRSAC, Gabber & Pebe..  (9.5)
6 Rainbow Connection  (9.5)
7 It's More Fun to Com..  (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 Booze Design  (9.3)
3 Censor Design  (9.3)
4 Crest  (9.3)
5 Performers  (9.3)
Top Webmasters
1 Slaygon  (9.7)
2 Perff  (9.6)
3 Morpheus  (9.5)
4 Sabbi  (9.5)
5 CreaMD  (9.1)

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