📄 lsrules.asm
字号:
; (5)opPrintTab
; (y)opPrintItemEos
;
;-----------------------------------------------------------------------
;push PRINT [#n] to root stack if 1st time this has been called for this stmt
;if FBOS_PrintSemi is set, push "; " to the root stack
;
PushPrintIfBos PROC NEAR
sub ax,ax
test [lsBosFlags],FBOS_Channel
je NoPrintChan ;brif not PRINT #n
and [lsBosFlags],0FFH - FBOS_Channel
call PopRoot ;ax = channel node
NoPrintChan:
push ax ;save 0/channel
mov ax,ORW_PRINT
call PushStmtRwIfBos
pop ax ;ax = 0/channel
or ax,ax
je NoPrintChan1 ;brif no channel
call PushRoot ;list channel again (after PRINT)
call PushRootCommaSpc ;list ", "
NoPrintChan1:
test [lsBosFlags],FBOS_PrintSemi
je NoSemi
and [lsBosFlags],0FFH - FBOS_PrintSemi
;tell next PushPrintIfBos not to list
mov al,';'
call PushRootCharSpc ;list "; "
NoSemi:
ret
PushPrintIfBos ENDP
; [exp] ==> [exp [[n #] PRINT]]
;
ListRule LrPrintItemEos
call PopRootPushTemp ;move exp from root to temp stack
call PushPrintIfBos ;list PRINT [#n] if appropriate
jmp PushListStg1 ;push temp list to root as 1 node
; and return to outer loop
ListRule LrPrintEos
call PushPrintIfBos ;list PRINT [#n] if appropriate
jmp SHORT J4_Stg1Loop ;return to outer loop
; [exp] ==> [; ( exp ) TAB/SPC ]
;
ListRule LrPrintSpc
ListRule LrPrintTab
call PushTempOpRw ;list "TAB" or "SPC"
call PushTempLParen ;list "("
call PopRootPushTemp ;list exp
call PushTempRParen ;list ")"
call PushPrintIfBos ;list PRINT [#n] if appropriate
or [lsBosFlags],FBOS_PrintSemi
;tell next print item's call to
; PushPrintIfBos to list ";"
; if no interviening ","
jmp PushListStg1 ;push temp list to root as 1 node
; and return to outer loop
ListRule LrPrintSemi
or [lsBosFlags],FBOS_PrintSemi
;tell next print item's call to
; PushPrintIfBos to list ";"
; if no interviening ","
J4_Stg1Loop:
jmp Stg1Loop ;return to outer loop
; [...] ==> [,]
;
ListRule LrPrintComma
call PushPrintIfBos ;list PRINT [#n] if appropriate
call PushRootOpChars ;list ","
call PushRootSpc ;list " "
and [lsBosFlags],0FFH - FBOS_PrintSemi
;tell next PushPrintIfBos not to list
jmp SHORT J4_Stg1Loop ;return to outer loop
; [exp] ==> [,/; exp]
;
ListRule LrPrintItemComma
ListRule LrPrintItemSemi
call PopRootPushTemp ;move exp from root to temp stack
call PushTempOpChars ;list opcode's char(s) (,/:)
call PushTempSpc ;list " "
call PushPrintIfBos ;list PRINT [#n] if appropriate
jmp PushListStg1 ;push temp list to root as 1 node
; and return to outer loop
; [exp] ==> [; exp USING]
;
ListRule LrUsing
call PushTempOpRwSpc ;list "USING "
call PopRootPushTemp ;list exp
mov al,';'
call PushTempCharSpc ;list "; "
call PushPrintIfBos ;list PRINT [#n] if appropriate
jmp PushListStg1 ;push temp list to root as 1 node
; and return to outer loop
ListRule LrStLprint
ListRule LrStWrite
or [lsBosFlags],FBOS_StmtRw ;remember not to list "PRINT"
jmp LrRwSpc ;list "LPRINT " and return to outer loop
ListRule LrInputChan
ListRule LrChanOut
or [lsBosFlags],FBOS_Channel ;remember to list [#]n,
jmp SHORT J4_Stg1Loop ;return to outer loop
subttl Graphics related pcodes
;------------------------------------------------------------------
; Graphics related pcodes
;------------------------------------------------------------------
; [exp2 exp1] ==> [( exp1 , exp2) ]
;
ListCoords PROC NEAR
call PushTempRParen ;list ")"
call PopPushCommaSpc ;move exp2 node from root to temp stack
;list ", "
call PopRootPushTemp ;move exp1 node from root to temp stack
jmp PushTempLParen ;list "("
;and return to caller
ListCoords ENDP
;copy 1st coord to temp stack if any
;
PushPop1stCoord PROC NEAR
mov al,'-'
call PushTempChar ;list "-" for 2nd coord pair
test [lsBosFlags2],FBOS2_1stCoord
je No1stCoord ;brif stmt like LINE -(x,y) instead
; of LINE (x,y)-(x,y)
call PopRootPushTemp ;copy [STEP (x,y)] to temp stack
No1stCoord:
ret
PushPop1stCoord ENDP
; [exp2 exp1] ==> [[) exp2 , exp1 ( -]]
;
ListRule LrCoordSecond
call ListCoords ;list (exp1, exp2) to temp stack
call PushPop1stCoord ;copy 1st coord to temp stack if any
jmp SHORT J2_PushRevListStg1 ;push temp list to root in rev order
; and return to outer loop
; [exp2 exp1] ==> [[) exp2 , exp1 ( STEP -]]
;
ListRule LrCoordStepSecond
call ListCoords ;list (exp1, exp2) to temp stack
mov ax,ORW_STEP
call PushTempRw ;list "STEP"
call PushPop1stCoord ;copy 1st coord to temp stack if any
J2_PushRevListStg1:
jmp PushRevListStg1 ;push temp list to root in rev order
; and return to outer loop
; [exp2 exp1] ==> [[) exp2 , exp1 ( STEP]]
;
ListRule LrCoordStep
call ListCoords ;list (exp1, exp2) to temp stack
mov ax,ORW_STEP
call PushTempRw ;list "STEP"
jmp SHORT LrCoord1
; [exp2 exp1] ==> [[) exp2 , exp1 (]]
;
ListRule LrCoord
call ListCoords ;list (exp1, exp2) to temp stack
LrCoord1:
or [lsBosFlags2],FBOS2_1stCoord
jmp SHORT J2_PushRevListStg1 ;push temp list to root in rev order
; and return to outer loop
;*************************************************************************
;LineBfArg
;Purpose:
; consume [B[F]] arg and list it
;Exit:
; condition codes: ZERO if no arg was present
;
;*************************************************************************
LineBfArg PROC NEAR
lods WORD PTR es:[si] ;ax = [B[F]] arg
or ax,ax
je LineBfExit ;brif no BF arg
dec al
mov al,'B'
je GotLineB ;brif got B arg
mov ah,'F' ;else it must have been BF
GotLineB:
call PushTempChars
or sp,sp ;set nz exit condition code
LineBfExit:
ret
LineBfArg ENDP
; [coord] ==> [[BF ,,] coord LINE]
;
ListRule LrStLine
call LineBfArg ;consume and list [B[F]] arg
je LineNoArg ;brif no BF arg
call PushTempCommaSpc ;list ", "
jmp SHORT LineComma ;list comma and coord arg
; [color coord] ==> [[BF,] color , coord LINE]
;
ListRule LrStLineColor
call LineBfArg ;consume and list [B[F]] arg
je LineArg ;brif no BF arg
jmp SHORT LineCommaArg ;list comma, color and coord arg
; [style coord] ==> [style , [BF] ,, coord LINE]
;
ListRule LrStLineStyle
call PopPushCommaSpc ;move style from root to temp stk
;list ", " between BF and style
call LineBfArg ;consume and list [B[F]] arg
call PushTempCommaSpc ;list ", " between color and BF
jmp SHORT LineComma ;list comma and coord arg
; [style color coord] ==> [style ,[BF], color, coord LINE]
;
ListRule LrStLineStyleColor
call PopPushCommaSpc ;move style from root to temp stk
;list ", "
call LineBfArg ;consume and list [B[F]] arg
jmp SHORT LineCommaArg ;list color and coord arg
;Table for mapping PUT function to reserved word
tRwPutFunc LABEL WORD
DW ORW_OR
DW ORW_AND
DW ORW_PRESET
DW ORW_PSET
DW ORW_XOR
; [array coord] ==> [function array coord PUT]
;
; [color coord] ==> [color coord PSET/PRESET]
;
; [array coord] ==> [array coord GET]
;
; [coord] ==> [coord PSET/PRESET]
;
ListRule LrStGraphicsPut
lods WORD PTR es:[si] ;ax = function mask
shl ax,1 ;ax = function * 2
js NoPutFunc ;brif no function specified
; i.e. if ax was UNDEFINED
xchg bx,ax
mov ax,tRwPutFunc[bx] ;ax = ORW_OR .. ORW_XOR
call PushTempRw ;list OR .. XOR
LineCommaArg:
call PushTempCommaSpc ;list ", "
NoPutFunc:
ListRule LrStPresetColor
ListRule LrStPsetColor
ListRule LrStGraphicsGet
LineArg:
call PopRootPushTemp ;move color from root to temp stk
LineComma:
call PushTempCommaSpc ;list ", "
ListRule LrStPreset
ListRule LrStPset
LineNoArg:
call PopRootPushTemp ;move coord from root to temp stk
call PushRootOpRwSpc ;list "PSET " or "PRESET "
jmp PushRevListStg1 ;move temp stk to root in reverse order
; and return to outer loop
;---------------------------------------------------------------------
; The statement:
; CIRCLE (x,y),r,c,astart,astop,aspect
; generates pcode:
; (x)(y)opCoord
; (r)(c)
; (astart)opCircleStart
; (astop)opCircleEnd
; (aspect)opCircleAspect
; opStCircleColor
; where (r)(c) are operands for opStCircleColor
;
; CIRCLE (x,y),r,,,,aspect
; generates pcode:
; (x)(y)opCoord
; (r)
; opNull opCircleStart
; (aspect)opCircleAspect
; opStCircle
; NOTE: opCircleEnd not generated because runtime can't tell
; opNull from whether user supplied value
;
;---------------------------------------------------------------------
;------------------------------------
; [expStart] ==> [expStart ,]
;
ListRule LrCircleStart
call PopRootPushTemp ;copy expStart to temp stack
call PushTempCommaSpc ;emit ", "
or [lsBosFlags2],FBOS2_Circle1
;tell LrCircle[Color] that it
; has a startEndAspect node
jmp SHORT J3_PushRevListStg1 ;copy temp stk to root in rev order
;------------------------------------
; [expEnd [expStart ,]] ==> [expEnd ,[expStart ,]]
;
ListRule LrCircleEnd
or [lsBosFlags2],FBOS2_Circle2
;remember we've gotten an opCircleEnd
call PopRootPushTemp ;copy expEnd to temp stack
call PushTempCommaSpc ;emit ", "
CE_CopyStart:
call PopRootPushTemp ;copy [expStart ,] from root to temp
J3_PushRevListStg1:
jmp PushRevListStg1 ;copy temp stk to root in rev order
;-------------------------------------------
; [expAspect ] ==> [expAspect , , ,]
; or
; [expAspect [expStart ,]] ==> [expAspect , ,[expStart ,]]
; or
; [expAspect [expEnd ,[expStart ,]]] ==>
; [expAspect ,[expEnd ,[expStart ,]]]
;
ListRule LrCircleAspect
call PopRootPushTemp ;copy expAspect to temp stack
call PushTempCommaSpc ;emit ", " between aspect and start
test [lsBosFlags2],FBOS2_Circle2
jne CE_CopyStart ;brif stmt has opCircleEnd
call PushTempCommaSpc ;emit ", " between aspect and start
jmp SHORT CE_CopyStart
;----------------------------------------------------
; [[startEndAspect] expRadius coord] ==>
; [[startEndAspect] expRadius ,coord CIRCLE]
;
ListRule LrStCircle
test [lsBosFlags2],FBOS2_Circle1
je CirCont2 ;brif no start/end/aspect args
jmp SHORT CirCont1 ;copy expAspect from root to temp
;--------------------------------------------------------------
; [[startEndAspect] expColor expRadius coord] ==>
; [[startEndAspect] expColor ,expRadius ,coord CIRCLE]
;
ListRule LrStCircleColor
test [lsBosFlags2],FBOS2_Circle1
je CirCont1 ;brif no start/end/aspect args
call PopRootPushTemp ;copy startEndAspect from root to temp
CirCont1:
call PopPushCommaSpc ;copy expColor to temp stack
; or startEndAspect from root to temp
; if LrStCircle
;list ", "
CirCont2:
call PopPushCommaSpc ;copy expRadius to temp stack
;list ", "
call PopRootPushTemp ;copy coord to temp stack
call PushTempSpc
call PushTempOpRw ;list CIRCLE
jmp SHORT J3_PushRevListStg1 ;move temp stk to root in reverse order
; [exp3 exp2 exp1 coord] ==> [exp3, exp2, exp1, coord PAINT]
;
ListRule LrStPaint
ListRule LrStPaint3
call PopNilExp ;copy exp3 and "," to temp stack
ListRule LrStPaint2
call PopNilExp ;copy exp2 and "," to temp stack
call PopNilExp ;copy exp1 and "," to temp stack
call PopRootPushTemp ;copy coord to temp stack
call PushTempSpc
call PushTempOpRw ;list PAINT
jmp SHORT J4_PushRevListStg1 ;move temp stk to root in reverse order
PushCoordPair PROC NEAR
call ListCoords ;list (exp4 ,exp3) to temp stack
mov al,'-'
call PushTempChar ;list "-"
jmp ListCoords ;list (exp2 ,exp1) to tmp stack & return
PushCoordPair ENDP
; [exp6 exp5 exp4 exp3 exp2 exp1] ==>
; [exp6 ,exp5 ,(exp4 ,exp3)-(exp2 ,exp1) VIEW]
;
ListRule LrStView
call PopNilExp ;copy exp6 and "," to temp stack
call PopNilExp ;copy exp5 and "," to temp stack
ListRule LrStWindow
call PushCoordPair ;list (exp4 ,exp3)-(exp2 ,exp1)
call PushTempSpc
call PushTempOpRw ;list VIEW/WINDOW
jmp SHORT J4_PushRevListStg1 ;move temp stk to root in reverse order
; [exp6 exp5 exp4 exp3 exp2 exp1] ==>
; [exp6 ,exp5 ,(exp4 ,exp3)-(exp2 ,exp1) SCREEN VIEW]
;
ListRule LrStViewScreen
call PopNilExp ;copy exp6 and "," to temp stack
call PopNilExp ;copy exp5 and "," to temp stack
ListRule LrStWindowScreen
call PushCoordPair ;list (exp4 ,exp3)-(exp2 ,exp1)
call PushTempSpc
mov ax,ORW_SCREEN
call PushTempRwSpc ;list SCREEN
call PushTempOpRw ;list VIEW/WINDOW
J4_PushRevListStg1:
jmp PushRevListStg1 ;move temp stk to root in reverse order
; [exp2 exp1 ...] ==> [exp2 TO exp1 PRINT VIEW ...]
;
; [...] ==> [PRINT VIEW ...]
;
ListRule LrStViewPrint2
call PopRootPushTemp ;move exp2 from root to temp stack
call PushTempSpc ;list " "
mov ax,ORW_TO
call PushTempRwSpc ;list "TO "
call PopRootPushTemp ;move exp1 from root to temp stack
call PushTempSpc ;list " "
ListRule LrStViewPrint0
mov ax,ORW_PRINT
call PushTempRw ;list "PRINT"
call PushRootOpRwSpc ;list "VIEW "
jmp SHORT J4_PushRevListStg1 ;move temp stk to root in reverse order
sEnd LIST
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -