Jump to content
IGNORED

Input Parser in assembly langauge?


adamantyr

Recommended Posts

Text. As in, the INPUT statement in assembly.

RXB has CALL USER that loads TEXT as input and includes being used in INPUT FILE or INPUT KEYBOARD text.

And in RXB demo can do both while running all from a Batch text file.

 

For example you could write a text file with Assembly bytes in that text and then move them to RAM or Scratch Pad RAM then run that program and still have access to dump that and run more....

Link to comment
Share on other sites

I'll just write my own but to clarify:

 

I'm looking for assembly source that puts a cursor on the screen, blinks the cursor, does left, right, input, delete. Like the INPUT statement in TI BASIC. Scrolling and multiple lines is not required.

 

Ah... I love clarity...

I did that in assembly for my SkyChart program. I'll dig it up.

Link to comment
Share on other sites

There is a GPL routine that does just what you want, provided you don't mind using 28 columns. (I think you can use 32 columns as long as you are not on the bottom row.) Very simple to use. I have to look up the details tonight before I can tell you how to use it, but someone will probably beat me to it before than.

Link to comment
Share on other sites

There is a GPL routine that does just what you want, provided you don't mind using 28 columns. (I think you can use 32 columns as long as you are not on the bottom row.) Very simple to use. I have to look up the details tonight before I can tell you how to use it, but someone will probably beat me to it before than.

 

Thanks, but I need it in assembly language. I'm not using GPL. Not even using GPLLNK!

Link to comment
Share on other sites

Here is one: http://atariage.com/forums/topic/207087-coding/page-1?do=findComment&comment=2670337, in "sokoban asm.zip".

 

The comments are in french. If you are interested in using it, I could isolate it from my library. Arrows, insert, delete, clear and multiline (4 lines) are implemented.

 

The routine is in "LIB" file, it's called "INPUT". The return value is in "INPSTR", the first byte is the string length.

 

If you want to watch it running, load the ea5 file "SOKOBAN" and press "L".

  • Like 1
Link to comment
Share on other sites

Ah

 

Here is one: http://atariage.com/forums/topic/207087-coding/page-1?do=findComment&comment=2670337, in "sokoban asm.zip".

 

The comments are in french. If you are interested in using it, I could isolate it from my library. Arrows, insert, delete, clear and multiline (4 lines) are implemented.

 

The routine is in "LIB" file, it's called "INPUT". The return value is in "INPSTR", the first byte is the string length.

 

If you want to watch it running, load the ea5 file "SOKOBAN" and press "L".

 

Ah thanks!

Link to comment
Share on other sites

This was originally written for one of my Geneve programs, then modified for 80 column use with a V9938. Feel free to use or cannibalize the code. I would do some things differently if I rewrote this routine today. ;)

 

 

 

 

**DOSIN_S
*      BL   @ACCEPTAT
*      DATA 1            cursor row (0-23 or 0-25)
*      DATA 1            cursor column (0-79)
*      DATA 10           Maximum Length (1-80) should NOT exceed last column!
*                        a NEGATIVE length will cause the existing data in
*                        the field to not be cleared.
*                        PLEASE NOTE that invalid characters present in the
*                        field are not screen out.  Use at your own risk!
*
*      DATA 0            CAPSFLAG (0=both; <>0 converts to UPPER)
*      DATA 0            NUMFLAG  (0=all; <>0 accept ONLY numbers)
*      DATA ACCEPTED     NULL terminated string of accepted characters
*      DATA BUFFER       Location to put the keyed data
*
*      OUT: R0 - length of input (LSB)
*
*      DESTROYS: R0,R1,R2,R3
*      SAVES: whatever registers it uses.
*-------------------------------------------------------------------------------
            DEF  ACCEPTAT
            DEF  ESCAPED
            REF  VMBW,VMBR,VSBW,VSBR
            REF  KSKAN
FIRSTROW    DATA 0
FIRSTCOL    DATA 0
R6HACK DATA 0            HACK to allow R6 keypress return (KSKAN)
FIRSTRC     DATA 0
CURRC       DATA 0
MAXCOL      DATA 79
FIELDWIDTH  DATA 0
INSERTFLAG  DATA 0
CAPSFLAG    DATA 0       0=all chars; 1=caps only
NUMFLAG     DATA 0       0=all chars; 1=NUMBERs only
BUFCOUNT    DATA 0       total characters in the buffer
MYCHAR      DATA 0
LASTKEY     DATA 0
ESCAPED     DATA 0       0=NORMAL; 1=escaped input
BLINKON     DATA 1000
BLINKOFF    DATA 0500
ONOROFF     DATA 0
COUNT1      DATA 0
LENGTH      DATA 0
MYBUF       BSS  20
TEXTBUF     BSS  80
TEXTEND     EQU  $
            EVEN
SAVER4      DATA 0
SAVER5      DATA 0
SAVER6      DATA 0
SAVER8      DATA 0
SAVER9      DATA 0
SAVER10     DATA 0
SAVER10#2   DATA 0
SAVER11     DATA 0
UNDERLINE   DATA >1E1E     TEXT '__'
ESCAPEKEY   BYTE 27
ENTER       BYTE 13
LEFTARROW   BYTE >88
RIGHTARROW  BYTE >89
ERASE       BYTE >87
DELETE      BYTE >83
INSERT      BYTE >84
F9KEY       BYTE >8F
HOMEKEY     BYTE >A0     for TI, could use FCTN-UP and
ENDKEY      BYTE >A1     FCTN-DOWN?
H20         BYTE >20
            EVEN
ACCEPTAT
       CLR  @ESCAPED
       MOVB @H20,@MYCHAR
       CLR  @INSERTFLAG
       CLR  @LENGTH
       MOV  R6,@SAVER6
       MOV  R8,@SAVER8
       MOV  R9,@SAVER9
       MOV  R10,@SAVER10
**     MOV  *R11,@STOPBL      row1
**     MOV  *R11,@STOPBL+4    row2
       MOV  *R11+,@FIRSTROW
**     MOV  *R11,@STOPBL+2    col1
**     MOV  *R11,@STOPBL+6    col2 (add offset later)
       MOV  *R11+,@FIRSTCOL
       MOV  *R11+,@FIELDWIDTH
       MOV  *R11+,@CAPSFLAG
       MOV  *R11+,@NUMFLAG
       MOV  *R11+,R9          holds pointer to the accepted data field
       MOV  *R11+,R6          pointer to output buffer
       MOV  R11,@SAVER11      save it AFTER changing the address

       LI   R1,80
       MPY  @FIRSTROW,R1
       A    @FIRSTCOL,R2
       MOV  R2,@FIRSTRC
       MOV  @FIELDWIDTH,R0    check width
       JGT  ERASE1            if positive, clear field
       JNE  USE1              zero?
       B    @EXIT             Yes, can't do it - exit
USE1   BL   @USEFIELD         no, must be negative.  Now, go fix it!
       JMP  BLINKR       GETKEY2
ERASE1 BL   @CLEARFIELD       sets cursor, clears buffer, clears the field
BLINKR
**BLINKR A    @FIELDWIDTH,@STOPBL+6            **WAS (A)dd 6-14-95
**     DEC  @STOPBL+6
**ERASE9 BL   @NOBLNKRC         let's 'hilite' the input area!
**STOPBL DATA 0,0,0,0
ERASE9
GETKEY2
       MOV  @BLINKON,@COUNT1                 set ON time
       SETO @ONOROFF                         set to on
       BL   @PRINTCURSOR
SCAN   ABS  @ONOROFF          CURSOR ON/OFF?
       JEQ  COFF0             OFF...
       DEC  @COUNT1           ON, SO DEC COUNTER
       JNE  GETKEYPRESS            CURSOR STILL ON?  YES - CONTINUE SCAN
       CLR  @ONOROFF          NO, RESET TO OFF
       MOV  @BLINKOFF,@COUNT1   PUT DELAY FOR OFF-TIME INTO COUNTER
       BL   @PRINTCHAR
       JMP  GETKEYPRESS            SCAN SOME MORE..
COFF0  DEC  @COUNT1           DEC COUNTER
       JNE  GETKEYPRESS            CURSOR STILL OFF? YES - CONTINUE W/SCAN
       SETO @ONOROFF          NO..., RESET BLINK ON
       MOV  @BLINKON,@COUNT1
       BL   @PRINTCURSOR
GETKEYPRESS
*GETKEY BLWP @KEYXOP
*      JNE  SCAN
GETKEY MOV  R6,@R6HACK
       BL   @KSKAN
       MOV  R6,R1
       MOV  @R6HACK,R6
       ANDI R1,>FF00
       CI   R1,>FF00
       JEQ  SCAN
CHECKMORE
*      ANDI R1,>7F00
       CB   R1,@RIGHTARROW    >DONE<
       JEQ  MOVERIGHT
       CB   R1,@ESCAPEKEY
       JEQ  ABORTESC
       CB   R1,@F9KEY
       JEQ  ABORTESC
       CB   R1,@LEFTARROW     >DONE<
       JEQ  MOVELEFT
       CB   R1,@ERASE         >DONE<
       JEQ  ERASE8
       CB   R1,@DELETE
       JEQ  DELETECHAR
       CB   R1,@INSERT        >DONE<
       JEQ  INSERTCHAR
       CB   R1,@HOMEKEY  Home...
       JEQ  HOMECURSOR
       CB   R1,@ENDKEY   End...
       JEQ  ENDCURSOR
       CB   R1,@ENTER
       JNE  NOACC
       B    @ACCEPTDATA
NOACC  ANDI R1,>7F00
       CI   R1,>2000          some other control character?
*****  JL   GETKEY2           yes, go get another key
       JL   SCAN
       B    @GETDATA
ABORTESC
       CLR  R0                CLEAR length register
       SETO @ESCAPED
       B    @ACCEPTEND        restore char under cursor, then exit properly
ERASE8 BL   @CLEARFIELD
       JMP  ERASE9
MOVELEFT
       CLR  @INSERTFLAG
       C    @FIRSTRC,@CURRC
*      C    @FIRSTCOL,@CURCOL                at left column of field?
       JEQ  LFTEND                           yes, exit
       BL   @PRINTCHAR
       DEC  R10
       DEC  @CURRC
*      DEC  @CURCOL                          no, decrease column number
**     BL   @SETCURPOS                       reset cursor
LFTEND B    @GETKEY2                         return
MOVERIGHT
       CLR  @INSERTFLAG
       MOV  R10,R0            get position in buffer
       INC  R0
       C    R0,@FIELDWIDTH    equal to width?
*      C    R0,@LENGTH        gotta check LENGTH, not width...
       JHE  RITEND            yes, don't go any more
       BL   @PRINTCHAR
       INC  R10
*      INC  @CURCOL           NO, move cursor position RIGHT one
       INC  @CURRC
RITEND B    @GETKEY2          exit
ERASEFIELD
       MOV  @FIRSTRC,@CURRC
       CLR  @INSERTFLAG
       B    @ERASE1      jumps out of loop @ top and clears buffer/field
INSERTCHAR
       SETO @INSERTFLAG       set flag for INSERT <ON>
       B    @GETKEY2          return for processing
DELETECHAR
       CLR  @INSERTFLAG
       MOV  R10,@SAVER10#2
       MOV  R10,R1            get pointer
       INC  R1                adjust it
       C    R1,@LENGTH        same as width?
       JNE  DELET1            no, must be somewhere before the end
       MOVB @H20,@TEXTBUF(R10)   yes, put a space at this position
       JMP  DELRET
DELET1 MOVB @TEXTBUF(R1),@TEXTBUF(R10)
       INC  R10
       INC  R1
       C    R1,@LENGTH
       JLE  DELET1
       MOVB @H20,@TEXTBUF(R1)
       DEC  @LENGTH
DELRET MOV  @FIRSTRC,R0
       LI   R1,TEXTBUF
       MOV  @FIELDWIDTH,R2
       BLWP @VMBW
       MOV  @SAVER10#2,R10
       B    @GETKEY2
HOMECURSOR
       BL   @PRINTCHAR
       MOV  @FIRSTRC,@CURRC
       CLR  R10
       B    @GETKEY2
ENDCURSOR
       BL   @PRINTCHAR
       MOV  @FIELDWIDTH,R0    get maximum width
       LI   R1,TEXTBUF        then get the starting
       A    @FIELDWIDTH,R1    address plus width
       DEC  R1                adjust for base 0
       CLR  R2                clear our comparison register
CURE1  MOVB *R1,R2            move the 'last' byte to R2
       DEC  R1                point to previous byte
       CI   R2,>2000          was it a control or space?
       JH   CURE2             no, stop here.  Length is OK
       DEC  R0                yes, shorten the length
       JNE  CURE1             if length gets to zero, drop out, else try more
CURE2  C    R0,@FIELDWIDTH   Is the field full / cursor @ end of field?
       JL   CURE3             no
       DEC  R0               yes, can't go past the field!!!
CURE3  MOV  R0,R10            set text buffer pointer
       A    @FIRSTRC,R0       get first RC
*      A    R1,R0            add,
*      DEC  R0                then adjust
       MOV  R0,@CURRC         and make it so
       B    @GETKEY2
******************************
ACCEPTDATA
       MOV  @FIELDWIDTH,R0    get maximum width
       LI   R1,TEXTBUF        then get the starting
       A    @FIELDWIDTH,R1    address plus width
       DEC  R1                adjust for base 0
       CLR  R2                clear our comparison register
ACCPT1 MOVB *R1,R2            move the 'last' byte to R2
       DEC  R1                point to previous byte
       CI   R2,>2000          was it a control or space?
       JH   MOVEFF            no, stop here.  Length is OK
       DEC  R0                yes, shorten the length
       JNE  ACCPT1            if length gets to zero, drop out, else try more
MOVEFF MOV  @FIELDWIDTH,R1    length zero?
       LI   R2,TEXTBUF        no, get beginning of text buffer
MOVEMR MOVB *R2+,*R6+         move a byte
       DEC  R1                done with entire string?
       JNE  MOVEMR            no, keep moving
ACCEPTEND
       MOV  R0,@SAVELASTR0    9.5.94... AFTER MANY HOURS.. PRINTCHAR DESTROYS!
       BL   @PRINTCHAR   8.17.94 - get rid of cursor box!
       MOV  @SAVELASTR0,R0
       B    @EXIT
SAVELASTR0 DATA 0
*********************************************
*      CHARACTER RETRIEVAL
*
*      - handles all characters.
*      - checks for INSERT
*      - checks character acceptance  (if 0, other flags used)
*      - checks NUMFLAG
*      - checks CAPSFLAG      USED IN CHARACTER ACCEPTANCE
*
GETDATA
       ABS  @NUMFLAG          number?
       JEQ  CHECKCAPS         was zero, so we don't care
       CI   R1,'0'*256        yes, below 0?
       JL   BADNUM                yes, don't allow this character
       CI   R1,'9'*256            no, above 9?
       JLE  CHECKCAPS                no, allow it to pass
BADNUM B    @INVALID          BAD, exit this routine
CHECKCAPS
       ABS  @CAPSFLAG         convert to uppercase
       JEQ  CHECKCHARACC      no...
       CI   R1,'a'*256        Yes, check range
       JL   CHECKCHARACC      lower, exit
       CI   R1,'z'*256
       JH   CHECKCHARACC      higher, exit
       ANDI R1,>5F00          Ah hah! got a small letter; convert to upper
CHECKCHARACC
       MOV  R9,R0             if zero, no address given.  No acceptance field
       JEQ  VALIDCHAR
CHK2   MOVB *R0+,R2           is this character a NULL (end of field)
       JEQ  INVALID           yes, this char does not match.  Go get another key
       CB   R1,R2             no, does this character match the keypress?
       JNE  CHK2                  no, try another
VALIDCHAR
       MOV  R1,@MYCHAR
       ABS  @INSERTFLAG       insert ON?
       JEQ  NOINSERT          No (whew, easy to do)
       MOV  R10,R1            get pointer
       INC  R1                adjust for base 1
       C    R1,@FIELDWIDTH    are we at the last character of the field?
       JEQ  NOINSERT          yes, so just put it in normally
       MOV  @FIELDWIDTH,R2    get width
       MOV  R2,R3             place to move it to
       DECT R2           WHY 2????     get rid of one for move
       JEQ  NOINSERT          if width 1, then don't perform this move
       DEC  R3
INS1   MOVB @TEXTBUF(R2),@TEXTBUF(R3)        mov the characters RIGHT
       DEC  R2                back each out
       DEC  R3
       C    R2,R10
       JGT  INS1
       MOVB @TEXTBUF(R2),@TEXTBUF(R3)
       MOV  @FIRSTRC,R0
       LI   R1,TEXTBUF
       MOV  @FIELDWIDTH,R2
       BLWP @VMBW
NOINSERT
       MOV  @CURRC,R0
       MOVB @MYCHAR,R1
       BLWP @VSBW
       INC  @CURRC
       MOV  R10,R0            now to check the position against field width
       INC  R0                adjust for base 1
       C    R0,@FIELDWIDTH    is it equal to the fieldwidth?
       JNE  NORM1             no
       DEC  @CURRC            yes, move cursor BACK one
       MOVB @MYCHAR,@TEXTBUF(R10)   save character, exit WITHOUT updating pointr
       MOV  @FIELDWIDTH,@LENGTH
       JMP  INEXIT
NORM1  MOVB @MYCHAR,@TEXTBUF(R10)            put it in the buffer
       INC  R10               update pointer into the buffer
       C    @LENGTH,@FIELDWIDTH              length at max?
       JEQ  INEXIT                           yes (possible negative width)
       INC  @LENGTH                          no, addd another
INVALID
INEXIT B    @GETKEY2

****************************************************
*  Time to exit - restore previously saved registers
*
EXIT
       MOV  @SAVER6,R6
       MOV  @SAVER8,R8
       MOV  @SAVER9,R9
       MOV  @SAVER10,R10
       MOV  @SAVER11,R11
       RT

PRINTCHAR
       MOV  @CURRC,R0
       MOVB @TEXTBUF(R10),R1
       BLWP @VSBW
       RT
PRINTCURSOR
       MOV  @CURRC,R0
       MOVB @UNDERLINE,R1
       BLWP @VSBW
       RT
SETFIRST
       MOV  @FIRSTRC,@CURRC
       RT
**************************
* Clear input buffer
*
CLEARBUFFER
       CLR  R10          pointer into the buffer
       LI   R0,TEXTBUF
CLEAR2 MOVB @H20,*R0+
       CI   R0,TEXTEND
       JNE  CLEAR2
       RT
*********************************************
*      Clear entire field
*
CLEART DATA 0            return value for r11
CLEARFIELD
       MOV  R11,@CLEART       save R11
       BL   @CLEARBUFFER      clear the buffer w/spaces
       BL   @SETFIRST         set cursor to first position
       MOV  @CURRC,R0
       LI   R1,TEXTBUF
       MOV  @FIELDWIDTH,R2
       BLWP @VMBW
       MOV  @CLEART,R11       restore r11
       RT                     return
USEFIELD
       MOV  R11,@CLEART
       NEG  @FIELDWIDTH            field was negative, make is positive again
       MOV  @FIELDWIDTH,@LENGTH    set length to maximum
       CLR  R10                    Clear pointer into text
       BL   @CLEARBUFFER      clear buffer (use spaces)
       BL   @SETFIRST         Set cursor positions
       MOV  @CURRC,R0         read into the text buffer!
       LI   R1,TEXTBUF
       MOV  @LENGTH,R2
       BLWP @VMBR
       MOV  @CLEART,R11                      and return
       RT
       END

 

 

  • Like 1
Link to comment
Share on other sites

All of the ALC for the 40/80 Column Editor is available on my fbForth website under “Source Code-->Bank 1-->40/80 Column Editor” and the complete ALC source listing for fbForth 2.0:10 is under “Source Code-->fbForth 2.0 Listing (PDF)”. RKEY is the key acquisition/repetition and cursor blinking routine. _VED is the main editor loop, which is called by the Forth word VED when the editor is invoked. Let me know if you need any clarification of the code. Some of it is a little convoluted.

 

...lee

Link to comment
Share on other sites

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...