TGB1718 Posted April 16, 2020 Share Posted April 16, 2020 Many thanks to @Wrathchild and @Irgendwer who helped me resolve a few issues getting cc65 going. I decided to re-write a program I wrote back in 1986 in BASIC which produces DATA statement files from a binary file which can then be entered into your BASIC program and for Assembler where you may want picture/sprite data it produces .BYTE statements which again can be entered into Assembler/MAC65. The code wasn't written to produce a small footprint, nor for high speed, just for me to get used to the environment. The program allow user input, verifys for correct input data/filenames. Not tried it on "real hardware" yet, but works fine in Altirra. I've attahed the .XEX file and 'C' code It was compiled using the following command:- cl65 -t atari -Wl "-D__RESERVED_MEMORY__=1" --static-locals -o autodata.xex autodata.c autodata.xex AUTODATA.c 1 Quote Link to comment Share on other sites More sharing options...
Irgendwer Posted April 16, 2020 Share Posted April 16, 2020 (edited) You're welcome! Just a small remark: Your code becomes more readable and doesn't need comments if you use the definitions for the contents of memory location 764 (e.g. "getversion()" in your code). See: https://cc65.github.io/doc/atari.html#ss5.5 Keep on hacking! Edited April 16, 2020 by Irgendwer Quote Link to comment Share on other sites More sharing options...
tschak909 Posted April 16, 2020 Share Posted April 16, 2020 Very useful! -Thom Quote Link to comment Share on other sites More sharing options...
Wrathchild Posted April 16, 2020 Share Posted April 16, 2020 (edited) You will be fine adding the option '-O' (capital o) to your cl65 command to enable the optimizer. As an exercise for you, compile the C to assembler without optimizing, copy the '.s' generated aside, then repeat with '-O' and compare the two, e.g. cl65 -t atari -S -Wl "-D__RESERVED_MEMORY__=1" --static-locals autodata.c ren autodata.s autodata1.s cl65 -t atari -S -O -Wl "-D__RESERVED_MEMORY__=1" --static-locals autodata.c ren autodata.s autodata2.s [Edit] Thinking about it, you can just use the -o (output) in the command line: cl65 -t atari -S -Wl "-D__RESERVED_MEMORY__=1" --static-locals -o autodata1.s autodata.c cl65 -t atari -S -O -Wl "-D__RESERVED_MEMORY__=1" --static-locals -o autodata2.s autodata.c Edited April 16, 2020 by Wrathchild Quote Link to comment Share on other sites More sharing options...
TGB1718 Posted April 16, 2020 Author Share Posted April 16, 2020 (edited) Very interesting, nice to know the output can be .asm files, had a look through and yes, you can see a lot of inefficient code which the -O reduces. On the .xex file, its about 1K smaller with the optimizer. Edited April 16, 2020 by TGB1718 Quote Link to comment Share on other sites More sharing options...
tschak909 Posted April 16, 2020 Share Posted April 16, 2020 the best thing you can do for cc65 is to minimize local variable usage, and do --static-locals, I mean it, treat cc65 like C flavored ACTION! ...because the stack gymnastics are one of the biggest expanders of code. Also, more function parameters cause lots of stack juggling. And if you literally leverage Atari specific OS features, (And get rid of the very generalized usage of standard c I/O functions), that chomps off a lot, too. I made my own little routines e.g. for screen input and output that call CIO. some examples here: https://github.com/FujiNetWIFI/atariwifi/tree/master/fnc-tools/fconfig -Thom Quote Link to comment Share on other sites More sharing options...
TGB1718 Posted April 16, 2020 Author Share Posted April 16, 2020 Thanks Thom, I will have a look at that tomorrow Quote Link to comment Share on other sites More sharing options...
TGB1718 Posted April 17, 2020 Author Share Posted April 17, 2020 One question related to the .s output, looking through the code generated, I notice a strange Op Code jne, I found 3 occurances, I know what it's doing, but it's not a 6502 Op Code. Do you know why it's not bne, maybe the compiler treats it as bne ? L0223: lda L01DB ora L01DB+1 jne L0226 lda L01E0 L02CF: lda L0293 ora L0293+1 jne L02D2 lda L0298 L006D: lda _flag ora _flag+1 jne L00B2 jsr _clrscr Quote Link to comment Share on other sites More sharing options...
Irgendwer Posted April 17, 2020 Share Posted April 17, 2020 (edited) 1 hour ago, TGB1718 said: Do you know why it's not bne, maybe the compiler treats it as bne ? It's a macro, where the assembler examines the distance of the branch. In case it is in the branch range, a bne is used - otherwise a construct with the "opposite" branch and jump: .macro jne Target .if .match(Target, 0) beq *+5 jmp Target .elseif .def(Target) .and .const((*-2)-(Target)) .and ((*+2)-(Target) <= 127) bne Target .else beq *+5 jmp Target .endif .endmacro Edited April 17, 2020 by Irgendwer Quote Link to comment Share on other sites More sharing options...
Yaron Nir Posted April 20, 2020 Share Posted April 20, 2020 I owe @Wrathchild a lot for helping me while I was a beginner in CC65 heck, he is even helping me now when i'm more advanced 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.