Search found 104 matches

by qus
Tue Jun 30, 2020 6:37 am
Forum: Programming
Topic: Wolin - a minimal Kotlin-like language compiler for 65xx
Replies: 170
Views: 22872

Re: Wolin - a minimal Kotlin-like language compiler for 65xx

With such optimizations one has to wonder why are they turned off by default...
by qus
Mon Jun 29, 2020 3:19 pm
Forum: Programming
Topic: Wolin - a minimal Kotlin-like language compiler for 65xx
Replies: 170
Views: 22872

Re: Wolin - a minimal Kotlin-like language compiler for 65xx

Heh, thanks. It will probably be good for 6502 asm optimization phase, though.
by qus
Mon Jun 29, 2020 10:34 am
Forum: Programming
Topic: Wolin - a minimal Kotlin-like language compiler for 65xx
Replies: 170
Views: 22872

Re: Wolin - a minimal Kotlin-like language compiler for 65xx

Yep:

Code: Select all

__wolin_lab_loop_start_1:

; 12: add 53280[ubyte] = 53280[ubyte] , #1[ubyte] 


    inc 53280

; 13: evalless CPU.NC[bool] = 53280[ubyte] , #255[ubyte] 


    lda 53280
    cmp #255

; 14: bift CPU.NC[bool] , __wolin_lab_loop_start_1<while_start>[uword] 


	bcc __wolin_lab_loop_start_1
by qus
Mon Jun 29, 2020 9:55 am
Forum: Programming
Topic: Wolin - a minimal Kotlin-like language compiler for 65xx
Replies: 170
Views: 22872

Re: Wolin - a minimal Kotlin-like language compiler for 65xx

OK, what I came up with is "storing" equality evaluation results in CPU regs. So when doing simple comparisons, instead of allocating new SP reg and using it as comparison destination, I'll set proper CPU flag as current Woling reg. I.e.

Insteade of this:

alloc SP, #1 // new reg
evaleq SP(0 ...
by qus
Sun Jun 28, 2020 8:01 am
Forum: Programming
Topic: Wolin - a minimal Kotlin-like language compiler for 65xx
Replies: 170
Views: 22872

Re: Wolin - a minimal Kotlin-like language compiler for 65xx

I'm thinking about something like this:

Instead of:

; 14: evalless SP(2)<__wolin_reg2>[bool] = 53280[ubyte] , #255[ubyte]

lda #1 ; mniejsze
sta 2,x
lda 53280
cmp #255
bcc :+
lda #0 ; jednak wieksze
sta 2,x
:
; 15: beq SP(0)<__wolin_reg2>[bool] = #1[bool] , __wolin_lab_loop_start_1<label ...
by qus
Sun Jun 28, 2020 7:21 am
Forum: Programming
Topic: 6502 port of the vbcc C compiler
Replies: 31
Views: 22288

Re: 6502 port of the vbcc C compiler

Hi HERE, Volker. Hope you find this at least a bit interesting:

viewtopic.php?f=2&t=5622&p=76787#p76787
by qus
Sun Jun 28, 2020 7:11 am
Forum: Programming
Topic: Wolin - a minimal Kotlin-like language compiler for 65xx
Replies: 170
Views: 22872

Re: Wolin - a minimal Kotlin-like language compiler for 65xx

Some compiler fun. I've compiled the same code with Wolin, cc65 and vbcc:

Wolin:


do {
border++
} while ( border < 255)


C (generated by Wolin C frontend :D)


do {
(*(unsigned char *)(53280))++;
} while ( (*(unsigned char *)(53280)) < 255);


And the results:

Wolin:

__wolin_lab_loop ...
by qus
Fri Jun 19, 2020 5:40 pm
Forum: Programming
Topic: Wolin - a minimal Kotlin-like language compiler for 65xx
Replies: 170
Views: 22872

Re: Wolin - a minimal Kotlin-like language compiler for 65xx

OK, so it's actually not that simple - mixing Wolin code with C code that uses some special C ZP locations will require a dedicated linker config, special Wolin startup code, and losing some Wolin stack space for C registers, but it's absolutely doable. Maybe later. Meanwhile you can get the length ...
by qus
Wed Jun 17, 2020 2:51 pm
Forum: Programming
Topic: Wolin - a minimal Kotlin-like language compiler for 65xx
Replies: 170
Views: 22872

Re: Wolin - a minimal Kotlin-like language compiler for 65xx

Anyone fluent in cc65? I was thinking about interfacing with its libs, since I'm using cl65 and ca65 anyway. So as we know the call convention is:

i = baz(int i, char c)

will result in:

lda _i
ldx _i+1
jsr pushax
lda _c
jst pusha

jsr _baz

sta _i
stx _i+1

While:

.proc pushax

pha ; (3 ...
by qus
Tue Jun 16, 2020 1:50 pm
Forum: Programming
Topic: Wolin - a minimal Kotlin-like language compiler for 65xx
Replies: 170
Views: 22872

Re: Wolin - a minimal Kotlin-like language compiler for 65xx

A small step ahead - I was able to mark registers used to dereference a pointer unoptimizable. Look at below code:


setup HEADER
label __wolin_pl_qus_wolin_plot = 65520
label __wolin_pl_qus_wolin_chrout = 65490
setup SPF = 251[ubyte] , 40959[uword]
setup SP = 114[ubyte]
setup HEAP = 176[ubyte ...
by qus
Mon Jun 08, 2020 12:27 pm
Forum: Programming
Topic: Wolin - a minimal Kotlin-like language compiler for 65xx
Replies: 170
Views: 22872

Re: Wolin - a minimal Kotlin-like language compiler for 65xx

Heh, after playing with long register chains for a few days I discovered that nothing beats my "naive" replacement by pairs. But at least I've learned some logic in reference flow... Anyway - here you can see source and optimized diagram of the very same print function.
by qus
Sat Jun 06, 2020 12:58 pm
Forum: Programming
Topic: Wolin - a minimal Kotlin-like language compiler for 65xx
Replies: 170
Views: 22872

Re: Wolin - a minimal Kotlin-like language compiler for 65xx

With improved flow diagram now the optimizer is able to find long chains of optimizable registers (compare with attached diagram):

#0 -> __wolin_reg2 -> pl.qus.wolin.print..i
#0 -> __wolin_reg11 -> __wolin_reg9
__wolin_reg5 -> __wolin_reg4 -> pl.qus.wolin.print..char -> __wolin_reg10 -> __wolin ...
by qus
Sun May 31, 2020 5:09 pm
Forum: Programming
Topic: Wolin - a minimal Kotlin-like language compiler for 65xx
Replies: 170
Views: 22872

Re: Wolin - a minimal Kotlin-like language compiler for 65xx

And here's a neat chart I was able to generate for print function with the new optimizer.
by qus
Sun May 31, 2020 7:17 am
Forum: Programming
Topic: Wolin - a minimal Kotlin-like language compiler for 65xx
Replies: 170
Views: 22872

Re: Wolin - a minimal Kotlin-like language compiler for 65xx

Small update - reworked optimizer to use real data flow trees. Up until now, the optimization was rather... erm... guerilla-style... Now I will be able to copy pointer received in function arguments to ZP stack and keep them there thanks to smarter logic in eliminating tree nodes.
by qus
Mon May 04, 2020 4:50 pm
Forum: Programming
Topic: Wolin - a minimal Kotlin-like language compiler for 65xx
Replies: 170
Views: 22872

Re: Wolin - a minimal Kotlin-like language compiler for 65xx

Is it an assembler directive? Nope... Let me look that up...

Ha! That was it!