Re: [pidp8] Digest for pidp-8@googlegroups.com - 2 updates in 1 topic

31 views
Skip to first unread message

Robert Evans

unread,
Sep 18, 2025, 5:15:24 PM (10 days ago) Sep 18
to pid...@googlegroups.com
I put the OP's full question into perplexity.ai.  I never asked it to write code before.  The answer follows.  I don't use PAL-8 and can not vouch for the usefulness of the answer.

 -RE

---------
/ PAL-8 Line Input Routine
/ Features:
/ - Converts lowercase to uppercase
/ - Accepts backspace and rubout
/ - Accepts linefeed to redisplay current line
/ - Accepts ESC or ^X to abort and restart
/ - Optional terminating nul or length storage
/ - Rings bell when buffer is full
/ - Prompt before input
/ - Max length = 80 chars

*0200                / Start address

BUF     = 0300       / Input buffer
BUFLEN  = 0100       / Max length (128, but use 80)
LIMIT   = 0120       / 80 characters
CR      = 015        / Carriage return
LF      = 012        / Line feed
BS      = 010        / Backspace (CTRL/H)
DEL     = 177        / Rubout
BEL     = 007        / Bell
ESC     = 033        / Escape
CTRLX   = 030        / Control-X
SPC     = 040        / Space

START,  JMS INLINE   / Call input line
        HLT          / Halt after input

/ ---------------------- Input Line Routine ----------------------
INLINE, 0
        CLA CLL
        TAD PROMPT
        JMS PSTR     / Print prompt

        CLA
        DCA LEN      / Zero length counter
        TAD BUF
        DCA PTR      / Initialize buffer pointer

INCHR,  JMS GETCH    / Wait for char
        DCA CH

/ Handle CR = end of line
        TAD CH
        CIA
        TAD MCR
        SNA
        JMP INEOL

/ Handle LF = redisplay line
        TAD CH
        CIA
        TAD MLF
        SNA
        JMP REDISP

/ Handle BS or DEL = backspace
        TAD CH
        CIA
        TAD MBS
        SNA
        JMP BKSP
        TAD CH
        CIA
        TAD MDEL
        SNA
        JMP BKSP

/ Handle ESC or ^X = abort
        TAD CH
        CIA
        TAD MESC
        SNA
        JMP ABORT
        TAD CH
        CIA
        TAD MCTRLX
        SNA
        JMP ABORT

/ Convert lowercase to uppercase
        TAD CH
        TAD MLOWER
        SNL
        JMP NOTLOW
        TAD (-40        / Subtract 40 octal to get uppercase
        TAD CH
        DCA CH
NOTLOW,

/ Store if room
        TAD LEN
        TAD (-LIMIT
        SMA
        JMP FULL
        TAD CH
        DCA I PTR
        ISZ PTR
        ISZ LEN
        JMS PUTCH      / Echo
        JMP INCHR

FULL,   CLA
        TAD BELL
        JMS PUTCH
        JMP INCHR

BKSP,   TAD LEN
        SZA CLA
        JMP BKDO
        JMP INCHR
BKDO,   ISZ MONE
        DCA LEN
        DAC PTR
        JMS PUTBS
        JMP INCHR

REDISP, JMS PNL
        TAD BUF
        DCA PTR2
REDO1,  TAD LEN
        SNA JMP INCHR
        TAD I PTR2
        JMS PUTCH
        ISZ PTR2
        ISZ LEN2
        JMP REDO1
        JMP INCHR

ABORT,  CLA
        TAD PNLMSG
        JMS PSTR
        JMP INLINE     / Restart

INEOL,  CLA
        DCA MNULL
        JMP I INLINE

/ ---------------------- Utility Routines --------------------------
PUTCH, 0             / Put character from AC
        TLS
WAITT,  TSF
        JMP WAITT
        TLS
        JMP I PUTCH

GETCH, 0             / Get character into AC
        KSF
        JMP GETCH
        KRB
        JMP I GETCH

PSTR,   0             / Print a string, zero terminated
        DCA PTR2
PS1,    TAD I PTR2
        SNA
        JMP I PSTR
        JMS PUTCH
        ISZ PTR2
        JMP PS1

PNL,    CLA
        TAD MCR
        JMS PUTCH
        TAD MLF
        JMS PUTCH
        JMP I PNL

PUTBS,  CLA
        TAD BS
        JMS PUTCH
        TAD SPC
        JMS PUTCH
        TAD BS
        JMS PUTCH
        JMP I PUTBS

/ ---------------------- Data ---------------------------
PROMPT,  ">",0
PNLMSG, "<aborted>",0

MCR,    CR
MLF,    LF
MBS,    BS
MDEL,   DEL
MESC,   ESC
MCTRLX, CTRLX
MLOWER, 0140        / 'a'
MNULL,  0
PTR,    0
PTR2,   0
LEN,    0
LEN2,   0
BELL,   BEL
MONE,   -1

*BUF
$



On Thu, Sep 18, 2025 at 4:56 PM <pid...@googlegroups.com> wrote:
Mike Katz <justme...@gmail.com>: Sep 17 06:33PM -0500

I'm rewriting a readable text paper tape punch program and I need PAL-8
routine that will input a line of text and return on carriage return.
 
The following features would be nice (for teletype, glass TTY or VT-100:
 
* Convert lower case to upper case
* Accept backspace and rubout
* Accept linefeed to display the line
* Accept control/X or ESC to delete the entry and start over again.
* Puts out a prompt
* Either null terminates the end of the string or stores the length of
the string somewhere
* Maximum line length of 60 to 80 characters.
* Ring the bell when the buffer is full.
 
I could write this myself but I'm trying to save some time.
 
If you know of a package or routine like this, please let me know.
 
Thanks,
 
     Mike
Steve Tockey <steve...@gmail.com>: Sep 18 12:07PM -0700

Mike,
More questions need to be answered to see if anything is available or how
easy it might be to write a new one:
 
1) Is this intended to be a completely stand-alone program (e.g., read in
using BIN Loader)? Or, is it intended to be a program that runs in the OS/8
environment? The reason this is important in that some of the functionality
you are looking for is already built into the OS/8 TTY: device handler but
that can only be used if the program is running in the OS/8 environment.
 
2) If stand-alone, i.e., outside of the OS/8 environment, does it matter if
it's running with interrupts on or not? I know for a fact that I have
written this kind of code in the past but it was in an interrupts on-based
application. OS/8 does not itself play well with interrupts on.
 
3) The string that gets returned should be unpacked? i.e., one 8-bit
character per memory word in the buffer? In many PDP-8 applications, to
save memory, characters get compressed to 6 bits then packed two in one
12-bit word. OS/8, by the way, packs three 8-bit characters into two 12-bit
words.
 
4) Behavior on a Teletype could be very different than on a VT-100
regarding backspace and rubout. Whereas the VT-100 can erase the last
character and move the cursor left, the "standard" PDP-8 behavior on a
Teletype is to print a slash on the first rubout/delete followed by the
character deleted for each rubout/delete press followed by another slash
when the next character is no longer a rubout/delete. For example, if the
user typed the sequence ABCEF<rubout><rubout>DEF it would get printed on
the Teletype as:
 
ABCEF/FE/DEF
 
5) The "standard" in PDP-8 land is to use Control/U to erase everything,
not Control/X
 
6) It is generally good practice to separate input from output in a
situation like this (AKA high cohesion & loose coupling / Single
Responsibility in the SOLID sense). I mean, printing a prompt should not be
a responsibility of this function because it limits its applicability. You
should have a separate output routine that prints stuff. Call the output
routine that prints the prompt, then call this routine to get the input.
 
Finally, how soon is this needed?
 
 
Cheers,
 
-- steve
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to pidp-8+un...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages