home *** CD-ROM | disk | FTP | other *** search
/ ticalc.org / ticalc_org_rev_b.iso / archives / 83 / asm / source / routines / gsinput.asm < prev    next >
Encoding:
Assembly Source File  |  2001-07-01  |  1.6 KB  |  54 lines

  1. Getting String Input
  2. ==============================================================
  3.                                               by Linus Akesson
  4.  
  5. First of all, we put a prompt at 821ch. Max 16 chars.
  6.  
  7.         ld      de,821ch                ;put the prompt here
  8.         ld      hl,prompt
  9.         ld      bc,prompt_len           ;length of prompt, max = 16
  10.         ldir
  11.  
  12. Then we call PGMIO_EXEC with the String Input command.
  13.  
  14.         ld      a,0                     ;code for STRING input
  15.         ld      (ASM_IND_CALL),a
  16.  
  17.         call    PGMIO_EXEC              ;defined in squish.inc
  18.  
  19. Now OP1 contains the name of a temporary string variable. The string contains
  20. tokens, but if you're only interested in alphanumeric input that doesn't
  21. matter, because uppercase letters and digits are still ascii.
  22.  
  23. This routine is an example of how to display the string without checking for
  24. tokens line sin(.
  25.  
  26.         call    _CHKFINDSYM
  27.  
  28.         ex      de,hl                   ;hl is start of string data
  29.         ld      c,(hl)
  30.         inc     hl
  31.         ld      b,(hl)
  32.         inc     hl                      ;bc is length of string
  33.  
  34.         ld      a,b
  35.         or      c                       ;length = 0 ?
  36.         ret     z                       ;return if so
  37.  
  38. loop:
  39.         push    bc
  40.         ld      a,(hl)                  ;get a character
  41.         call    _putc
  42.         pop     bc
  43.         dec     bc
  44.         ld      a,b
  45.         or      c                       ;done yet?
  46.         jr      nz,loop                 ;no -> loop back
  47.  
  48.         call    _newline
  49.         ret
  50.  
  51. And ofcourse:
  52.  
  53. prompt:         .db "Inp:",0
  54. prompt_len      =   $-prompt