Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

The following is a simple example program, which prints out the mathematical constant PI. It makes two FPP calls, one FP_PI to get the value, then a FP_STR to convert it to a string. This is then printed via the standard GN_Sop routine.

 

Code Block
languagenone
include "stdio.def"                 ; standard I/O definitions 
include "fpp.def"                   ; floating point definitions 

; routine assumes that IY points to small buffer on entry 
; buffer size at least 15 bytes

.print_pi   fpp  FP_PI              ; get value of PI in HLhlC
            push iy
            pop  de                 ; buffer address in DE
            exx                     ; swap to alternate registers
            ld   de, $000A          ; format control variable (10 digits)
            exx
            fpp  FP_STR             ; convert number to ASCII string
            xor  a
            ld   (de),a             ; null-terminate string
            push iy
            pop  hl                 ; buffer address in HL
            oz   GN_Sop             ; display number to standard output
            oz   GN_Nln             ; newline
            ret                     ; finished (return to caller)