6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Mon Apr 29, 2024 6:03 am

All times are UTC




Post new topic Reply to topic  [ 171 posts ]  Go to page Previous  1 ... 8, 9, 10, 11, 12
Author Message
PostPosted: Mon Jun 29, 2020 10:34 am 
Offline

Joined: Sat Apr 20, 2019 5:31 pm
Posts: 104
Yep:

Code:
__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


Top
 Profile  
Reply with quote  
PostPosted: Mon Jun 29, 2020 2:07 pm 
Offline

Joined: Thu Mar 12, 2020 10:04 pm
Posts: 690
Location: North Tejas
qus wrote:
; 13: evalless CPU.NC[bool] = 53280[ubyte] , #255[ubyte]

Code:
    lda 53280
    cmp #255



If X or Y is available, you can compare a byte with 255 (or 1) with something like:

Code:
    ldx    53280
    inx            ; (or dex)

    beq


Top
 Profile  
Reply with quote  
PostPosted: Mon Jun 29, 2020 3:19 pm 
Offline

Joined: Sat Apr 20, 2019 5:31 pm
Posts: 104
Heh, thanks. It will probably be good for 6502 asm optimization phase, though.


Top
 Profile  
Reply with quote  
PostPosted: Tue Jun 30, 2020 2:40 am 
Offline

Joined: Mon Sep 17, 2018 2:39 am
Posts: 132
Hi!

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

Wolin:

C (generated by Wolin C frontend :D)

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


cc65:
Code:
L0015:   ldx     #$00
   lda     $D020
   inc     $D020
   ldx     #$00
   lda     $D020
   cmp     #$FF
   jsr     boolult
   jne     L0015


I wonder if I can make my bool operations any smarter and use V/C/N flags somehow (and obviously win brevity competition)... But I do like the way it works now - by storing the final bool result of an operation in SP reg. MAYBE instead of storing it at SP,x I just pretend I "stored" it at 6502 V/C/N?


You compiled the CC65 example without optimizations, here I get (using "cc65 -Osir test.c":

Code:
L000B:  inc     $D020
        lda     $D020
        cmp     #$FF
        bcc     L000B


Have Fun!


Top
 Profile  
Reply with quote  
PostPosted: Tue Jun 30, 2020 6:37 am 
Offline

Joined: Sat Apr 20, 2019 5:31 pm
Posts: 104
With such optimizations one has to wonder why are they turned off by default...


Top
 Profile  
Reply with quote  
PostPosted: Tue Jun 30, 2020 10:36 am 
Offline

Joined: Mon May 21, 2018 8:09 pm
Posts: 1462
Most C compilers have no optimisation by default, so cc65 is not unusual in that respect. Unoptimised compilation results in code that does fewer unexpected things when single-stepping in a debugger.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 171 posts ]  Go to page Previous  1 ... 8, 9, 10, 11, 12

All times are UTC


Who is online

Users browsing this forum: No registered users and 25 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: