This page is a mirror of Tepples' nesdev forum mirror (URL TBD).
Last updated on Oct-18-2019 Download

KickC BETA

KickC BETA
by on (#237823)
People here seem to enjoy using C to make 6502 content, so this might be of interest. Camelot have released a new KickC which is a slight variant of C rather than ANSI C to help with optimizing 6502 code

https://csdb.dk/release/?id=176985

It is a pre pass system, similar to my MLA, so it generates a Kick Assembler file for you to then assemble using Kick Assembler http://theweb.dk/KickAssembler/Main.html#frontpage
Re: KickC BETA
by on (#237831)
I looked over the C documentation, I did not see support for banks that are often used for NES. Am I correct?

From my understanding, even if I compile two banks as separate binaries, I would have to extract and use hardcoded address to reference data/subroutines between the bank1 and bank2.

There is support of segments in the assembler itself[0] but I'm not sure how to use them in KickC.

[0] http://theweb.dk/KickAssembler/webhelp/content/ch10s02.html
Re: KickC BETA
by on (#237841)
Oziphantom wrote:
People here seem to enjoy using C to make 6502 content, so this might be of interest. Camelot have released a new KickC which is a slight variant of C rather than ANSI C to help with optimizing 6502 code


Developers of compilers for the 6502 could benefit from seeing how Keil's compiler for the 8051 handled the quirks of that architecture. Perhaps most importantly, automatic objects are statically overlaid so that they behave like automatic variables except that recursion is not allowed, and qualifiers can place objects in either fast storage (which is limited to about 120 bytes on that platform) or larger storage areas. If one adds qualifiers for integer arrays whose address will never be taken and whose size will be known even on extern declarations, something like:

Code:
    int wow[4] = { 0xCAFE, 0xBABE, 0x1234, 0x5678};
    int foo(unsigned char __abs x, int *__zp y)
    {
       return wow[x] + *y;
    }

could yield something like:

Code:
    .function foo 2,1 ; Uses two bytes of automatic objects in ZP; 1 in non-ZP storae
foo:
      ldx ?foo_abs+0
      lda __lo_wow,x
      clc
      ldy #0
      adc (?foo_zp+0),y
      sta __retval
      lda __hi_wow,x
      iny
      adc (?foo_zp+0),y
      sta __retval+1
      rts
__lo_wow: .byte $FE, $BE, $34, $78
__hi_wow: .byte $CA, $BA, $12, $56

Nothing insanely complicated should be required to yield that kind of generated code once the proper declarations are in place.
Re: KickC BETA
by on (#237862)
I've not looked at in depth, however you don't have to live with its hardcoded offsets. It does not make a binary file, it makes KickAssembler .asm files. So you are able to put them in segments etc as you please. The C code won't automatically handle the bank switching for you though, so you will probably need to add it by hand, with inline asm.
Re: KickC BETA
by on (#240562)
Hi there,

I am the author of KickC.

The ASM generated by the KickC-compiler for supercat's foo()-function example is pretty similar to what you are hoping for. Here it is copied straight from the compiler output.

Code:
// foo(byte register(X) x, signed word* zeropage(2) y)
foo: {
    .label return = 2
    .label y = 2
    txa
    asl
    tax
    clc
    ldy #0
    lda wow,x
    adc (return),y
    pha
    iny
    lda wow+1,x
    adc (return),y
    sta return+1
    pla
    sta return
    rts
}
  wow: .word $cafe, $babe, $1234, $5678


If you are interested in coding 6502 using a C-family language that produces efficient ASM have a look at KickC https://gitlab.com/camelot/kickc

Kind regards,
Jesper Gravgaard
Rex/Camelot