(hide navigation)
  • Swedish content
Fund my projects
Patreon
Steady
Don't miss
Page thumbnail
A case against syntax highlighting
Forum
Register
Log in
Latest comments
Syndication
RSS feed
Feedback

Getting string input

Back to the TI-83 page

First of all, we put a prompt at 821ch. Max 16 chars.

        ld      de,821ch                ;put the prompt here
        ld      hl,prompt
        ld      bc,prompt_len           ;length of prompt, max = 16
        ldir

Then we call PGMIO_EXEC with the String Input command.

        ld      a,0                     ;code for STRING input
        ld      (ASM_IND_CALL),a

        call    PGMIO_EXEC              ;defined in squish.inc"}

Now OP1 contains the name of a temporary string variable. The string contains tokens, but if you're only interested in alphanumeric input that doesn't matter, because uppercase letters and digits are still ascii.

This routine is an example of how to display the string without checking for tokens like sin(.

        call    _CHKFINDSYM

        ex      de,hl                   ;hl is start of string data
        ld      c,(hl)
        inc     hl
        ld      b,(hl)
        inc     hl                      ;bc is length of string

        ld      a,b
        or      c                       ;length = 0 ?
        ret     z                       ;return if so

loop:
        push    bc
        ld      a,(hl)                  ;get a character
        call    _putc
        pop     bc
        dec     bc
        ld      a,b
        or      c                       ;done yet?
        jr      nz,loop                 ;no -> loop back

        call    _newline
        ret

And of course:

prompt:         .db \"Inp:\",0
prompt_len      =   $-prompt

Discuss this page

Disclaimer: I am not responsible for what people (other than myself) write in the forums. Please report any abuse, such as insults, slander, spam and illegal material, and I will take appropriate actions. Don't feed the trolls.

Jag tar inget ansvar för det som skrivs i forumet, förutom mina egna inlägg. Vänligen rapportera alla inlägg som bryter mot reglerna, så ska jag se vad jag kan göra. Som regelbrott räknas till exempel förolämpningar, förtal, spam och olagligt material. Mata inte trålarna.

Anonymous
Wed 25-Mar-2009 17:56
INPUT AND OUTPUT STRING ASSEMBLY FOR NASM 32 BIT FOR LINUX ?

HOW TO?
Anonymous
Wed 25-Mar-2009 17:57
INPUT AND OUTPUT STRING ASSEMBLY FOR NASM 32 BIT FOR LINUX ?

HOW TO?
lft
Linus Åkesson
Thu 26-Nov-2009 16:04
INPUT AND OUTPUT STRING ASSEMBLY FOR NASM 32 BIT FOR LINUX ?

HOW TO?

man 3 fgets

(or use read(2) if you don't want to link with libc)
Anonymous
Sun 26-May-2013 17:21
How to do in x86 assembly ?
Anonymous
Tue 14-Aug-2018 19:12
could you teach me swedish