+jedimatt42 Posted September 22 Share Posted September 22 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. 1 Quote Link to comment Share on other sites More sharing options...
Reciprocating Bill Posted September 22 Share Posted September 22 No such routine in ROM. However, a CIF routine is loaded into low memory by the E/A loader and is available via XMLLNK in that environment. Also true for the MiniMemory loader, but not the Extended BASIC loader. 1 Quote Link to comment Share on other sites More sharing options...
+Lee Stewart Posted September 22 Share Posted September 22 The way TI Basic does it is to call a small console-GROM1 routine that converts the integer to a string followed by calling the console-ROM0 CSN routine via XML. ...lee 1 Quote Link to comment Share on other sites More sharing options...
apersson850 Posted September 24 Share Posted September 24 On pages 23-24 in this newsletter scan you can see how you can do this in Extended BASIC, well, in an assembly program supporting Extended BASIC is more correct to say. nittinian_1985_nr3.pdf (nivelleringslikaren.eu) Look for CFI and CIF at the top right of page 23 and middle left on page 24. 1 Quote Link to comment Share on other sites More sharing options...
RXB Posted September 24 Share Posted September 24 (edited) 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 September 24 by RXB Spelling 2 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.