6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Thu Nov 21, 2024 8:33 am

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: U<
PostPosted: Mon Jul 29, 2024 3:23 pm 
Offline

Joined: Sat Jun 22, 2024 6:21 am
Posts: 14
I have some trouble with the implemented U< in my figforth for the 6502.
For example :
$7FFF $D800 U< true
$4000 $D800 U< true
$0400 $D800 U< false
$E000 $D800 U< false

The code is :

Code:
1472   0C0E             ;                                       U<
1473   0C0E             ;                                       Unsigned less than
1474   0C0E             ;
1475   0C0E 82 55 BC    L1246     .BYTE $82,"U",$BC
1476   0C11 02 0C                       .WORD L1244    ; link to =
1477   0C13 D6 09       ULESS      .WORD DOCOL
1478   0C15 FA 0B                       .WORD SUB      ; subtract two values
1479   0C17 88 08                       .WORD ZLESS    ; test sign
1480   0C19 0C 08                       .WORD SEMIS


Is there a better code to do this comparision/


Top
 Profile  
Reply with quote  
 Post subject: Re: U<
PostPosted: Mon Jul 29, 2024 6:08 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8543
Location: Southern California
I have it as a primitive:
Code:
    LDA  3,X
    CMP  1,X
    BNE  1$

    LDA  2,X
    CMP  0,X
1$: BCS  2$
    JMP  POP-TRUE

2$: JMP  POP-FALSE


_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
 Post subject: Re: U<
PostPosted: Tue Jul 30, 2024 8:00 pm 
Offline

Joined: Fri May 05, 2017 9:27 pm
Posts: 895
So do I.
Code:
CODE U< ( N1 N2 -- F )
   2 ,X LDA  0 ,X CMP
   3 ,X LDA  1 ,X SBC
   CS NOT IF  DEY  THEN
   LABEL FLAG.POP
   2 ,X STY  3 ,X STY
   POP JMP  END-CODE

Note: Other primitives in the kernel source use the label FLAG.POP as a branch or jump destination.


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

All times are UTC


Who is online

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