Re: A83: Help with a problem


[Prev][Next][Index][Thread]

Re: A83: Help with a problem




On Sat, 7 Aug 1999 15:03:33 EDT, Ted21@aol.com wrote:
>
>I have encountered a bug in the following code that I can not figure out.
>This program checks whether or not a number is a perfect square, and if it
>is, display the square root.  It can detect if the number is a perfect 
>square
>or not, but when it displays the square root, it has a problem.  When I 
>enter
>in 4 it outputs 1.41421356 E -36 and that really isn't the square root of 
>4.
>Any help will be appreciated, as well as optimizations.  Here is the code:
>
>.NOLIST
>#define END .end
>#define end .end
>#define EQU .equ
>#define equ .equ
>#include "ti83asm.inc"
>#include "tokens.inc"
>.LIST
>PGMIO_EXEC equ 50B2h
>_formDisp equ 4D0Eh
>.org $9327
>     call _clrScrnFULL          ;Clears the screen
>     call _homeup                 ;Sets cursor to 0,0
>     ld de,821ch                   ;*********************
>     ld hl,prompt                      ;
>     ld bc,16                            ;System Input Routine
>     ldir                                  ;
>     ld a,1                            ;stores result in Op1
>     ld (ASM_IND_CALL),a    ;
>     call PGMIO_EXEC       ;*********************
>                                           ;The following checks if
>                                           ;the input is a perfect
>                                           ;Square while saving
>                                 ;op1 in op3 for further use
>                                           ;
>     call _op1toop3               ;op1 -> op3
>     call _sqroot                   ;square root of op1 -> op1
>     call _frac                       ;fpart(op1) -> op1
>     call _op2set0                 ;0 -> op2
>     call _cpop1op2              ;compare op1 and op2
>     jr z, perf_sqr                  ;goto perf_sqr if the same
>     ret                                ;return
>                                           ;*********************
>perf_sqr:
>     call _zerooop1               ;0 -> op1
>     call _op3toop1               ;op3 -> op1
>     call _sqroot                      ;square root of op1 -> op1
>     call _formdisp                ;Display op1
>     ret                                ;return
>prompt:
>     .db "Number= ",0
>.end
>END
>
>
>Thanks for any help,
>    Ted

Instead of having the "call _formdisp" to display Op1, try the following:

  ld a,4            ; display 4 chars. max
  call _dispop1a    ; display answer

That will display Op1 at (penrow,pencol) in small text. Alternatively, you 
could get rid of the "call _formdisp" and put:

  call _op1toop2    ; put op1 in op2
  call _setxxxxop2  ; hl=op2
  call _disphl      ; display answer

Hope that helps!

James Vernon
jimbob_v@hotmail.com


______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com


Follow-Ups: