Post Reply 
(11C) (15C) Very fast binary converter + fast modulo
04-05-2018, 03:25 PM (This post was last modified: 04-06-2018 08:32 PM by Michael Zinn.)
Post: #7
RE: (11C) Very fast binary converter + fast modulo
I'm currently running out of labels and registers so here is a slow, compact version that only uses register I and .6 and only one extra label (for 15C):

Code:
; toBinary(x)
LBL 5:
  FIX 0
  0              ; put 0 on the stack as the result "variable"
  STO I          ; initialize exponent to 0
  x >< y

  LBL 6               ; begin while loop
    STO .6
    2
    GSB 2        ; (`mod` 2)
    RCL I
    10^x
    *
    +
    1
    STO + I
    R v
    RCL .6

    2              ;
    /              ; right shift
    INT            ;

    TEST 0 (x != 0)
      GTO 6         ; end while loop

  R v
  RTN
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: (11C) Very fast binary converter + fast modulo - Michael Zinn - 04-05-2018 03:25 PM



User(s) browsing this thread: 1 Guest(s)