It is currently Tue Jul 16, 2019 5:17 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: KickC BETA
PostPosted: Tue Apr 23, 2019 6:41 am 
Offline

Joined: Tue Feb 07, 2017 2:03 am
Posts: 733
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


Top
 Profile  
 
 Post subject: Re: KickC BETA
PostPosted: Tue Apr 23, 2019 10:59 am 
Offline

Joined: Tue Aug 28, 2018 8:54 am
Posts: 143
Location: Edmonton, Canada
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


Top
 Profile  
 
 Post subject: Re: KickC BETA
PostPosted: Tue Apr 23, 2019 1:05 pm 
Offline

Joined: Thu Apr 18, 2019 9:13 am
Posts: 150
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.


Top
 Profile  
 
 Post subject: Re: KickC BETA
PostPosted: Wed Apr 24, 2019 1:49 am 
Offline

Joined: Tue Feb 07, 2017 2:03 am
Posts: 733
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.


Top
 Profile  
 
 Post subject: Re: KickC BETA
PostPosted: Fri Jul 05, 2019 3:08 pm 
Offline

Joined: Fri Jul 05, 2019 1:41 pm
Posts: 1
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group