Jump to content
IGNORED

Does the console ROM have an inverse to CFI? An int to float routine, instead of float to int?


jedimatt42

Recommended Posts

I've got code... but if the console ROM has callable code, I'd rather do that. 

 

I'm not seeing anything, but I wouldn't be surprised if user input always starts as a string, converted to a float, instead of ever needing to go directly from int to float.

  • Like 1
Link to comment
Share on other sites

Extended Basic ROM has CIF and CFI, it does use the Console ROM for part of the CFI

 

2739 74AA              AORG >74AA   
  2741                
  2742            ************************************************************
  2743            * CIF     - Convert integer to floating   
  2744            *           Assume that the value in the FAC is an integer  
  2745            *            and converts it into an 8 byte floating point  

 99/4 ASSEMBLER
CIFS                                                         PAGE 0063
  2746            *            value  
  2747            ************************************************************
  2748 74AA 0204  CIF    LI   R4,FAC            Will convert into the FAC   
       74AC 834A  
  2749 74AE C014         MOV  *R4,R0            Get integer into register   
  2750 74B0 C184         MOV  R4,R6             Copy pointer to FAC to clear i
  2751 74B2 04F6         CLR  *R6+              Clear FAC & FAC+1   
  2752 74B4 04F6         CLR  *R6+              In case had a string in FAC   
  2753 74B6 C140         MOV  R0,R5             Is integer equal to zero?   
  2754 74B8 1323         JEQ  CIFRT             Yes, zero result and return   
  2755 74BA 0740         ABS  R0                Get ABS value of ARG  
  2756 74BC 0203         LI   R3,>40            Get exponent bias   
       74BE 0040  
  2757 74C0 04F6         CLR  *R6+              Clear words in result that  
  2758 74C2 04D6         CLR  *R6                might not get a value  
  2759 74C4 0280         CI   R0,100            Is integer less than 100?   
       74C6 0064  
  2760 74C8 1A13         JL   CIF02             Yes, just put in 1st fraction 
  2761            *                              part   
  2762 74CA 0280         CI   R0,10000          No, is ARG less then 100^2?   
       74CC 2710  
  2763 74CE 1A08         JL   CIF01             Yes, just 1 division necessary
  2764            *                             No, 2 divisions are necessary 
  2765 74D0 0583         INC  R3                Add 1 to exponent for 1st   
  2766 74D2 C040         MOV  R0,R1             Put # in low order word for th
  2767            *                              divide   
  2768 74D4 04C0         CLR  R0                Clear high order word for the 
  2769            *                              divide   
  2770 74D6 3C20         DIV  @C100,R0          Divide by the radix   
       74D8 6008  
  2771 74DA D920         MOVB @R1LB,@3(R4)  ~@  Move the radix digit in   
       74DC 83E3  
       74DE 0003  
  2772 74E0 0583  CIF01  INC  R3                Add 1 to exponent for divide  
  2773 74E2 C040         MOV  R0,R1             Put in low order for divide   
  2774 74E4 04C0         CLR  R0                Clear high order for divide   
  2775 74E6 3C20         DIV  @C100,R0          Divide by the radix   
       74E8 6008  
  2776 74EA D920         MOVB @R1LB,@2(R4)  ~@  Put next radix digit in   
       74EC 83E3  
       74EE 0002  
  2777 74F0 D920  CIF02  MOVB @R0LB,@1(R4)  ~@  Put highest order radix digit 
       74F2 83E1  
       74F4 0001  
  2778 74F6 D520         MOVB @R3LB,*R4         Put exponent in   
       74F8 83E7  
  2779 74FA 0545         INV  R5                Is result positive?   
  2780 74FC 1101         JLT  CIFRT             Yes, sign is correct  
  2781 74FE 0514         NEG  *R4               No, make it negative  
  2782 7500 045B  CIFRT  RT   
  2783            ************************************************************
  2784                

 

CFI     >12B8 is the GPL Console ROM routine used by TI Basic and XB to Convert Floating Point to Integer

Edited by RXB
Spelling
  • Like 2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...