📄 inptty.asm
字号:
TITLE INPTTY - console input
page ,132
;***
;inptty - console input
;
; Copyright <C> 1986, Microsoft Corporation
;
;Purpose:
;
;BASIC Syntax mapping to included runtime entry points
;
;i) INPUT[;]["prompt";|,]variable[,variable]...
;
; BASCOM 2.0 generates calls to IN0A, IPUA, and a call to IPUB for
; each variable. Now it will generate the following calls :
;
; 1. void B$INPP (sd *psdPrompt, I2 FAR *pBlock)
;
; Where pBlock is a far pointer to a block
; with the following information :
;
; word 1 .... word count of the length of this block
; byte 3 .... an encoded flag having information about
; CRLF and the ?. It is described below.
; bytes 4 to n+3 .... have the n types.
;
; the block would look like :
;
; 1 2 3 4
; ----------------------------------------------
; | n+3 | fCRLFqMark|<---------n types-------->|
; ______________________________________________
; ^
; |
; |
; |
; pBlock
;
; The CRLFqMark flag can take the following values :
;
; 0 .... no ';' before prompt and ';' after prompt.
; 1 .... no ';' before prompt and ',' after prompt.
; 2 .... ';' before prompt and ';' after prompt.
; 3 .... ';' before prompt and ',' after prompt.
;
; Note: the above has the same meaning as:
; bit 0 set if NO question mark will be displayed
; bit 1 set if NO no carriage return will be forced.
;
; The types are as follows :
;
; I2 .... 2H \
; I4 .... 14H \ This is what the runtime is
; R4 .... 4H using.
; R8 .... 8H /
; SD .... 3H /
;
; (INPP stands for INPut Preamble)
;
; The value of b$FInput will be:
;
; default 0FFH
; inptty 0H
; inpdsk 1H
;
; 2. void B$RD<type> (<type> *pDest)
;
; Where,
; <type> = I2: Two byte integer
; I4: Four byte integer
; R4: Single precision real
; R8: Double precision real
; SD: String descriptor
;
; This will be called once for each variable.
;
; The B$RD<type> routines are going to be shared between
; the READ and INPUT statements and they need to know whether
; they are called from an INPUT statement or a READ
; statement. This is done by setting a flag (say b$FInput)
; in B$DSKI.
; (The default value of b$FInput would be used for READ)
;
; (Note:
; In the case of interpreted code, the B$RD<type>
; routines will call the interpreter to get a pointer to
; the next DATA item and return the # of bytes consumed.)
;
; 3. void B$PEOS(void)
;
; The flag b$FInput gets cleared in B$PEOS.
;
;ii) INPUT #filenum, variable [,variable]...
;
; BASCOM 2.0 generates calls to IN0B, IPUA and IPUB. Now it will
; generate the following calls :
;
;
; 1. void B$DSKI (I2 channel)
;
; 2. void B$RD<type> (<type> *pDest)
;
; Refer to the description above.
;
; 3. void B$PEOS(void)
;
; Refer to the description above.
;
;iii) LINE INPUT [;]["prompt";|,] stringvar
;
; BASCOM 2.0 generates calls to IN0A and LIPA. Now it will generate
; a call to B$LNIN. (see routine documentation).
;
;iv) LINE INPUT #filenum, stringvar
;
; BASCOM 2.0 generates calls to IN0B and LIPA. Now it will generate
; calls to B$DSKI followed by B$LNIN.
;
; Since B$LNIN is shared between LINE INPUT and LINE INPUT #, B$DSKI
; sets b$FInput telling B$LNIN that this is disk input. b$FInput gets
; cleared before exiting B$LNIN.
;
; B$INPP is in inptty.asm
; B$DSKI is in inpdsk.asm
; B$LNIN is in lininp.asm
; B$RD<type> is in read.asm
;
; - RANDOMIZE Statement - calls B$RNZ0 if no parm
;
; RANDOMIZE
; ---------
; |
; B$RNZ0
;
;******************************************************************************
INCLUDE switch.inc
INCLUDE rmacros.inc
;Code segments
useSeg DK_TEXT
useSeg CN_TEXT
useSeg MT_TEXT
useSeg ST_TEXT
useSeg ER_TEXT
useSeg RT_TEXT
;data segments
useSeg _DATA
useSeg _BSS
INCLUDE seg.inc
INCLUDE messages.inc
INCLUDE const.inc ; b$IOFLAG field definitions
INCLUDE rtps.inc
INCLUDE string.inc
INCLUDE idmac.inc
SUBTTL local constants
page
InpTTY EQU 0H ;console input
SUBTTL data definitions
page
sBegin _DATA
externW b$GetOneVal
externB b$FInput
externW B$AC
externB b$IOFLAG ; Misc. IO flags. Defined in GWINI.ASM
externW b$nuldes ; Null string descriptor
externW b$RndVar ; random number seed.
labelW RandpBlock ; information block needed by B$INPP
staticW ,2 ; total 4 bytes
staticB ,0 ; need '?' and CR
staticB ,2 ; var type is I2
sEnd ;_DATA
sBegin _BSS
globalW b$DATAPT,,1
externW b$StkBottom ; for clean stack
externB b$Buf1 ; 256+1 bytes of temp storage
labelD BlockPt
staticW BlockOff,,1 ;points to the block of type list
staticW BlockSeg,,1
staticW SaveDI,,1 ;save registers
staticW SaveSI,,1
staticW SaveES,,1
staticW SaveBP,,1 ; save old BP, NOTE: SaveBP, RetOff & RetSeg
; should be in this order
labelD RetAddr
staticW RetOff,,1 ;return address
staticW RetSeg,,1
staticW TYPCNT,,1
staticW VALCNT,,1
staticW PROMPT,,1
staticB INFLG,,1
externW b$errvec ; error vector (0=none, else address)
externW b$PTRFIL
externW b$curlevel
externB b$VTYP
sEnd ;_BSS
SUBTTL code externals
page
sBegin CN_TEXT
externNP B$TYPSTR
externNP B$$WCHT
externNP B$$TCR
externNP B$KEYDSP ; Trick to pull in B$KEYDSP code
externNP B$INPCRLF ; moved to out.asm
externNP B$RDLIN
sEnd ;CN_TEXT
sBegin MT_TEXT
externNP B$FIN
sEnd
sBegin ER_TEXT
externNP B$PUTNUM
sEnd
sBegin ST_TEXT
externNP B$STDALCTMP ; deallocate if temp string
externNP B$STDALCALLTMP ; deallocate all string temps
sEnd
sBegin RT_TEXT
sEnd
assumes CS,DK_TEXT
sBegin DK_TEXT
externFP B$PEOS ; input/output generate reset routine
externFP B$RDI2 ; read one item
SUBTTL console input interfaces -- B$INPP & B$INPA
page
;***
;B$INPP -- console input preamble
;void B$INPP(sd sdPrompt, I2 far *pBlock)
;
;Purpose:
; This is the preamble for console input. This routine sets up some
; flags, and checks types of inputs. If anything goes wrong, print
; "?Redo from start" and start over. Values will be saved in stack,
; and will be assigned to variables by the succeeding calls to
; B$RD<type>.
;
; We need special care to handle the stack, since all input values
; are stored in stack and are used across the interfaces. In order
; to have a clean stack for storage, registers and stack frame, which
; are usually saved in stack, are stored in memory. Note that the
; stack frame has to be in stack whenever there is the possiblity
; that an uncontrolled error would happen. In this routine, the read
; line routine, B$RDLIN, is the possible troulbe spot.
;
; The following is the illustration of the stack frame and the
; stack situation when the routine exits.
;
; | | | |
; High |---------------| High |---------------|
; | | | |
; |---------------|[b$StkBottom]>|---------------|
; | | / | value |
; |---------------| [b$DATAPT] |---------------|
; | | | |
; \ \ \ \
; \ \ \ \
; |---------------| |---------------|
; | | | value |
; |---------------| |---------------|
; | Return Segment| | value |
; |---------------| |---------------|
; | Return Offset | | (R4 high) |
; |---------------| |---------------|
; | BP | | (R4 low) |
; BP ->|---------------| |---------------|
; \ \ \ . \
; \ \ \ . \
; | | | value |
; Low |---------------| Low |---------------|
;
; Note: the way to store the value here (in stack) is the same as
; to store in any memory location. Look the example for R4.
;
; The algorithm is split into three parts:
; (I) Set up
; save registers (e.g. ES,SI,DI) in memory location
; save stack frame (BP RetOff RetSeg) in memory location
; save the pointer of the stack bottom in [b$StkBottom] &
; in [b$DATAPT]
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -