home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
assemblr
/
library
/
edit
/
fremacsr
/
mint.asm
< prev
next >
Wrap
Assembly Source File
|
1987-02-19
|
9KB
|
539 lines
;History:513,2
.xlist
include mintdefs.asm
bios_seg segment at 40h
bios_conin label far
bios_status label far
bios_seg ends
BS equ 08h
LF equ 0ah
CR equ 0dh
ESC equ 1bh
DEL equ 07fh
data segment public
;the _mark constants mark where a particular type of string occurs in
; the linked list.
comma_marker equ 0 ;comma_marker must not have function_marker_mask set!
active_marker equ 1 ;active_marker must have function_marker_mask set!
neutral_marker equ 3 ;neutral_marker must have function_marker_mask set!
function_marker_mask equ 1
extrn trace: byte
extrn formb: word
extrn forme: word
extrn fbgn: word
extrn fend: word
extrn actptr: word
metachar db "'" ;metachar is initially '
extrn next_ids: word
public ids
ids db "#(ps,(",CR,LF,"))#(ps,#(rs))",0
ids_user db "#(ps,#(bk))",0
breakchar db 3 ;use ^C.
data ends
code segment public
assume cs:code, ds:data, es:data
public mint_init
mint_init:
ret
extrn init_ids: near
extrn nomem: near
;this routine should check for a break character. If it gets one, it
; gets rid of its return address and jump to init_ids. The check should
; be a non-destructive test, i.e. it should not suck up any characters
; except the chosen break character. Also, no registers should be changed.
public check_breakchar
check_breakchar:
push ax
call bios_status
jz check_breakchar_1
cmp al,breakchar
jne check_breakchar_1
call bios_conin ;get rid of the break character.
add sp,4 ;get rid of the return address.
jmp init_ids
check_breakchar_1:
pop ax
ret
da_prim:
da_prim_1:
mov bx,formb ;any forms left?
cmp bx,forme
je da_prim_2 ;no, exit.
call delete_form ;yes, delete one of them and continue.
jmp da_prim_1
da_prim_2:
jmp return_null
cs_prim:
call find_arg1
jnc cs_prim_1 ;if not found, return null.
jcxz cs_prim_2 ;if form pointer at end, return arg 2.
di_points_fbgn
cs_prim_3:
lodsb
cmp al,sgap
ja cs_prim_4 ;terminate on sgap1..127's.
je cs_prim_5 ;ignore sgap0's
chk_actptr
stosb
cs_prim_5:
loop cs_prim_3
jmp return_form ;we ran off the end.
cs_prim_4:
dec cx ;move past the sgap.
jmp return_form
cs_prim_2:
mov cx,2
jmp return_arg_active
cs_prim_1:
jmp return_null
cc_prim:
call find_arg1
jnc cc_prim_1 ;form not found.
jcxz cc_prim_2 ;no chars left.
lodsb ;get the character.
push ax
cc_prim_3:
lodsb ;get the next character
test al,sgap
loopne cc_prim_3 ;keep looking while we still have sgaps.
jne cc_prim_4 ;if the last character is a real character,
dec si ; make the form pointer point to it.
inc cx
cc_prim_4:
pop ax ;restore the character
di_points_fbgn
stosb ;no need to check for collision with actptr.
dec cx
jmp return_form
cc_prim_2:
mov cx,2
jmp return_arg_active
cc_prim_1:
jmp return_null
cn_prim:
call find_arg1
jnc cn_prim_1
jcxz cn_prim_2
push si ;save pointer, count to form.
push cx
push bx
mov cx,2 ;get number of chars to call.
call getarg
call get_decimal
mov dx,ax ;save in dx.
pop bx
pop cx
pop si
di_points_fbgn
cn_prim_3:
or dx,dx ;have we called the specified number of chars?
jz cn_prim_4
lodsb
or al,al ;don't move sgaps.
jl cn_prim_5
chk_actptr ;store the char.
stosb
dec dx ;decrement the count.
cn_prim_5:
loop cn_prim_3 ;keep going until we run out of chars.
jmp short cn_prim_6
;scan forwards until the next character is found.
cn_prim_4:
lodsb ;get the next character
test al,sgap
loopne cn_prim_4 ;keep looking while we still have sgaps.
jne cn_prim_6 ;if the last character is a real character,
dec si ; make the form pointer point to it.
inc cx
cn_prim_6:
jmp return_form
cn_prim_2:
mov cx,3
jmp return_arg_active
cn_prim_1:
jmp return_null
pf_prim:
call find_arg1
jnc pf_prim_1
mov cx,[bx].data_length
lea si,[size form + bx]
add si,[bx].name_length
mov dx,0
pf_prim_2:
cmp dx,[bx].form_pointer
jne pf_prim_3
call reverse_video
mov al,"^"
call printchar
call normal_video
pf_prim_3:
jcxz pf_prim_1
lodsb
cmp al,sgap
je pf_prim_5 ;ignore sgap0s.
jb pf_prim_4 ;print characters.
push ax
call reverse_video
pop ax
sub ax,sgap-"0"
call printchar
call normal_video
jmp pf_prim_5
pf_prim_4:
call printchar
pf_prim_5:
inc dx
dec cx
jmp pf_prim_2
pf_prim_1:
jmp return_null
rs_prim:
di_points_fbgn
mov cx,0
rs_prim_1:
call readchar ;reads without echo
cmp al,DEL ;delete?
je rs_prim_4
cmp al,BS ;backspace? if so, delete char.
jne rs_prim_2
rs_prim_4:
jcxz rs_prim_1 ;if no chars, ignore it.
cmp byte ptr [di-1],LF ;don't delete past lf.
je rs_prim_1
dec cx ;dec count
dec di ;dec pointer
mov al,BS ;erase char from screen.
call printchar
mov al," "
call printchar
mov al,BS
call printchar
jmp rs_prim_1
rs_prim_2:
cmp al,metachar ;end of input?
jne rs_prim_3
jmp return_tos
rs_prim_3:
cmp al,CR
jne rs_prim_6
call rs_prim_store
mov al,LF
call rs_prim_store
jmp rs_prim_1
rs_prim_6:
cmp al,breakchar ;break character?
jne rs_prim_5
jmp init_ids
rs_prim_5:
call rs_prim_store
jmp rs_prim_1
rs_prim_store:
stosb ;store the char
call printchar ;print the char
chk_actptr
inc cx ;bump the count
ret
cm_prim:
call getarg1
mov al,"'"
jcxz cm_prim_1
lodsb
cm_prim_1:
mov metachar,al
jmp return_null
um_prim:
mov next_ids,offset ids_user
jmp return_null
tn_prim:
call getarg1
mov trace,1
jcxz tn_prim_1 ;if arg not empty,
mov trace,2 ; do trace with pause.
tn_prim_1:
jmp return_null
tf_prim:
mov trace,0
jmp return_null
public reverse_video
reverse_video:
mov al,ESC
call printchar
mov al,"p"
call printchar
ret
public normal_video
normal_video:
mov al,ESC
call printchar
mov al,"q"
call printchar
ret
public trace_result
trace_result:
;enter with si->, cx=count of returning result of a primitive call.
;doesn't modify si or cx.
cmp trace,0
je trace_result_3
push si
push cx
call reverse_video
jcxz trace_result_1
trace_result_2:
lodsb
call printchar
loop trace_result_2
trace_result_1:
call normal_video
cmp trace,2 ;if pause,
jne trace_result_4
call readchar ;then wait for a character.
trace_result_4:
call printcrlf
pop cx
pop si
trace_result_3:
ret
public trace_invoke
trace_invoke:
;enter with bx->fbgn, al=function type (active or neutral)
cmp trace,0
je trace_invoke_6
push bx
cmp al,neutral_marker
jne trace_invoke_1
mov al,"#"
call printchar
trace_invoke_1:
mov al,"#"
call printchar
mov al,"("
call printchar
trace_invoke_3:
mov si,bx
mov bx,[bx]
cmp si,bx ;at end?
je trace_invoke_2 ;yes.
mov cx,bx
sub cx,si
sub cx,mark_overhead ;remove overhead.
add si,mark_overhead-1 ;skip past overhead.
jcxz trace_invoke_5
trace_invoke_4:
lodsb
call printchar
loop trace_invoke_4
trace_invoke_5:
cmp bx,[bx] ;last argument?
je trace_invoke_3 ;yes - don't print comma.
mov al,","
call printchar
jmp trace_invoke_3
trace_invoke_2:
mov al,")"
call printchar
pop bx
trace_invoke_6:
ret
public rc_prim
rc_prim:
call readchar
cmp al,breakchar
je rc_prim_1
di_points_fbgn
stosb
jmp return_tos
rc_prim_1:
jmp init_ids
ps_prim:
call getarg1
jcxz ps_prim_2
ps_prim_1:
lodsb
call printchar
loop ps_prim_1
ps_prim_2:
jmp return_null
extrn getarg1: near
extrn return_form: near
extrn return_arg_active: near
extrn getarg: near
extrn get_decimal: near
extrn return_null: near
extrn return_tos: near
extrn printchar: near
extrn printcrlf: near
extrn readchar: near
extrn find_arg1: near
extrn delete_form: near
code ends
data segment public
public function_name_table
public function_name_length
public function_address
function_name_table label word
db "ps"
db "rs"
db "cm"
db "hl"
db "eq"
db "um"
db "rc"
db "tn"
db "tf"
db "nc"
db "sc"
db "db"
db "dt"
db "tm"
;forms
db "ds"
db "ss"
db "pf"
db "cl"
db "cs"
db "cc"
db "cn"
db "cr"
db "in"
db "ln"
db "dd"
db "da"
db "sb"
db "fb"
db "nb"
;math
db "ad"
db "su"
db "ml"
db "dv"
db "gr"
function_name_length equ ($-function_name_table)/2
dw dflt
function_address label word
dw ps_prim
dw rs_prim
dw cm_prim
dw hl_prim
dw eq_prim
dw um_prim
dw rc_prim
dw tn_prim
dw tf_prim
dw nc_prim
dw sc_prim
dw db_prim
dw dt_prim
dw tm_prim
;forms
dw ds_prim
dw ss_prim
dw pf_prim
dw cl_prim
dw cs_prim
dw cc_prim
dw cn_prim
dw cr_prim
dw in_prim
dw ln_prim
dw dd_prim
dw da_prim
dw sb_prim
dw fb_prim
dw nb_prim
;math
dw ad_prim
dw su_prim
dw ml_prim
dw dv_prim
dw gr_prim
data ends
code segment public
extrn dflt: near
extrn hl_prim: near
extrn eq_prim: near
extrn nc_prim: near
extrn sc_prim: near
extrn db_prim: near
extrn dt_prim: near
extrn tm_prim: near
;forms
extrn ds_prim: near
extrn ss_prim: near
extrn cl_prim: near
extrn cr_prim: near
extrn in_prim: near
extrn ln_prim: near
extrn dd_prim: near
extrn sb_prim: near
extrn fb_prim: near
extrn nb_prim: near
;math
extrn ad_prim: near
extrn su_prim: near
extrn ml_prim: near
extrn dv_prim: near
extrn gr_prim: near
code ends
end