home *** CD-ROM | disk | FTP | other *** search
- ; newFrac v1.0 by Keith Batten
- ;
- ; Input:
- ; store the real you want to conver into 'inFrac'
- ; Output:
- ; 'Ans' holds 0 if failed or 1 if successful
- ; 'num' holds the numberator if successful
- ; 'den' holds the denominator if successful
- ;
-
- #include "asm86.h"
- #include "Ti86asm.inc"
- #include "Ti86ops.inc"
- #include "ti86abs.inc"
- #include "ti86math.inc"
-
- _ioPrompt equ 0C324h
- _PTempCnt equ 0D293h
- _CLEANTMP equ 0D295h
- _ASAP_IND equ 0D623h
-
- .org _asm_exec_ram
-
- nop
- jp Start
- .dw 0000h
- .dw Description ; set the description for a shell
- Description:
- .db $05,"NewFrac v1.0 KWB",0
-
- Start:
-
- checkfor_inFrac:
- ld hl, inFrac_op ; check for 'inFrac' variable
- rst 20h ; ld (op1) with (hl)
- call _FINDSYM ; is there a variable 'inFrac'?
- jp c, nofrac ; no, so quit
-
- ex de, hl
- ld a, b
- call _SET_ABS_SRC_ADDR
-
- ld hl, _OP2
- xor a
- call _SET_ABS_DEST_ADDR
- ld hl, 10
- xor a
- call _SET_MM_NUM_BYTES
- call _mm_ldir
-
- write_vars:
- ld hl, num_op ; check for 'num' variable
- rst 20h ; ld (op1) with (hl)
- call _FINDSYM ; is there a variable 'num'?
- jr c, check_den ; no, so continue
- call _delvar ; delete 'num' using data from _FINDSYM
- jr check_den
-
- check_den:
- ld hl, den_op ; check for 'den' variable
- rst 20h ; ld (op1) with (hl)
- call _FINDSYM ; is there a variable 'den'?
- jr c, continue ; no, so continue
- call _delvar ; delete 'den' using data from _FINDSYM
- jr continue
-
- continue:
- ; /begin prompt/
- ; ld de,_ioPrompt
- ; ld hl,str_prmpt
- ; call _mov10B ; move prompt to prompt buffer , 21 max
-
- ; LD HL,(_CLEANTMP)
- ; PUSH HL ; SAVE CURRENT CLEANTMP VALUE
- ; LD HL,(_PTempCnt)
- ; LD (_CLEANTMP),HL ; CLEANTMP=PTEMPCNT
- ;SO INPUT ERRORS SAVE TMP VAR
-
- ; ld a,0Dh ; set for 'input'
- ; ld (_ASAP_IND),a
-
- ; call _exec_pg3 ; get input, op1 = var containing input
-
- ; POP HL ; HL=PREVIOUS CLEANTMP
- ; ld (_CLEANTMP),hl
- ; /end prompt/
-
- call _OP2TOOP1
-
- ; check if number is a real
- ld a, (_OP1)
- cp $80
- jr z, frac
- cp $0
- jr z, frac
-
- jp nofrac
-
- ; check if number will have denominator of 1
-
- frac:
- call _OP1TOOP3
- call _FRAC
- call $449B ; cp op1, 0
- jr nz, setops
- call _OP3SET1
- call _OP3TOOP5
- call _OP2TOOP3
- jr checkforfrac
-
- ; ld op3 with numerator
- ; ld op5 with denominator
-
- setops:
- call _OP3TOOP1
- call $4b93
- call _OP1TOOP3
- call _OP2TOOP5
-
- checkforfrac:
- call _OP3TOOP1
- call _FRAC
- call $449B
- jr nz, nofrac
-
- loadvars:
- ld hl, num_op
- rst 20h ; ld (op1) with (hl)
- call _CREATEREAL ; create real variable 'num'
-
- ex de, hl
- ld a, b
- call _SET_ABS_DEST_ADDR
-
- ld hl, _OP3
- xor a
- call _SET_ABS_SRC_ADDR
- ld hl, 10
- xor a
- call _SET_MM_NUM_BYTES
- call _mm_ldir
-
- ld hl, den_op
- rst 20h ; ld (op1) with (hl)
- call _CREATEREAL ; create real variable 'den'
-
- ex de,hl
- ld a,b
- call _SET_ABS_DEST_ADDR
-
- ld hl, _OP5
- xor a
- call _SET_ABS_SRC_ADDR
- ld hl,10
- xor a
- call _SET_MM_NUM_BYTES
- call _mm_ldir
-
- call _op1set1 ; store float 0 into op1
-
- exit:
- call _stoans ; return answer 0=failed, 1=successful
- ret
- jp $409c ; clean exit
-
-
- nofrac:
- call _OP1SET0
- jr exit
-
- num_op:
- .db $12,$3
- .db "num",0
- den_op:
- .db $12,$3
- .db "den",0
- inFrac_op:
- .db $12,$6
- .db "inFrac",0
-
-
- str_prmpt:
- ; .db "Prompt = ",0
-
- .end
-