mirror of
https://github.com/PDP-10/its.git
synced 2026-03-24 01:27:33 +00:00
123 lines
1.8 KiB
Plaintext
123 lines
1.8 KiB
Plaintext
; C:MINSRT.MID
|
|
|
|
; This file provides useful macros for hand-coded midas programs designed
|
|
; to be loaded with "new" c programs.
|
|
|
|
.insrt c:cinsrt.mid
|
|
|
|
rtn=popj p,
|
|
|
|
define inform a,b
|
|
if1,[printx \ a = b
|
|
\]
|
|
termin
|
|
|
|
; support routines
|
|
|
|
define %len [list]
|
|
%count==0
|
|
irp elem,,list
|
|
%count==%count+1
|
|
termin
|
|
termin
|
|
|
|
define defvar name,#offset
|
|
define name
|
|
<offset>&777777'(ep)termin
|
|
termin
|
|
|
|
; define c-callable procedure (renamed as compiler would)
|
|
|
|
define centry name,[args],[vars]
|
|
prolog $!name,name,args,vars
|
|
termin
|
|
|
|
; define c-callable procedure (not renamed)
|
|
|
|
define mentry name,[args],[vars]
|
|
prolog name,name,args,vars
|
|
termin
|
|
|
|
; define globally accessible C variable
|
|
|
|
define cdata name
|
|
$!name":termin
|
|
|
|
; define globally accessible internal (non-renamed) variable
|
|
|
|
define mdata name
|
|
name":termin
|
|
|
|
; prolog macro
|
|
|
|
define prolog cname,pname,[args],[vars]
|
|
%len args
|
|
%a==%count
|
|
%len vars
|
|
%v==%count
|
|
%off== -2
|
|
irp argnam,,args
|
|
defvar argnam,%off
|
|
%off==%off-1
|
|
termin
|
|
%off==1
|
|
irp varnam,,vars
|
|
defvar varnam,%off
|
|
%off==%off+1
|
|
termin
|
|
<%a&77',,[asciz/pname/]>
|
|
cname": push p,ep ; stash frame pointer
|
|
movei ep,(p) ; get new frame pointer
|
|
ifn %v,[adjsp p,%v] ; allocate locals
|
|
termin
|
|
|
|
; define midas-accessible data
|
|
|
|
; fatal error
|
|
|
|
define croak string/
|
|
pushj p,[
|
|
hrroi 1,[asciz \?!string \]
|
|
psout
|
|
haltf ]
|
|
termin
|
|
|
|
; return statement
|
|
|
|
define return
|
|
move ep,(ep)
|
|
adjsp p,-<%v+1>
|
|
popj p,
|
|
termin
|
|
|
|
; call statement (call a C-compiled procedure)
|
|
|
|
define ccall name,[args]
|
|
nn==0
|
|
pushem args
|
|
pushj p,$!name"
|
|
adjsp p,-nn
|
|
termin
|
|
|
|
; midas-call statement (call a non-renamed procedure)
|
|
|
|
define mcall name,[args]
|
|
nn==0
|
|
pushem args
|
|
pushj p,name"
|
|
adjsp p,-nn
|
|
termin
|
|
|
|
; push a bunch of args on the stack
|
|
|
|
define pushem [args]
|
|
irp arg,arglst,args
|
|
ifb [arg],.istop
|
|
pushem [arglst]
|
|
push p,arg
|
|
nn==nn+1
|
|
.istop
|
|
termin
|
|
termin
|
|
|