-
Notifications
You must be signed in to change notification settings - Fork 0
/
k11nhd.mac
85 lines (76 loc) · 1.73 KB
/
k11nhd.mac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
; K11NHD.MAC
;
; 10-Apr-84 09:37:15 Brian Nelson
;
; macros for defing things that may not be available
; for RT11 systems, like MUL, DIV, ASH and SOB. This
; must be prefixed in front of all assembly commands
; for RT version of Kermit-11.
.macro mul src,reg
.ntype $$,reg
mov src ,-(sp)
mov reg ,-(sp)
.globl k11$mul
call @k11$mul
.iif eq ,$$-1 ,mov (sp)+ ,r1
.iif eq ,$$-3 ,mov (sp)+ ,r3
.iif eq ,$$-5 ,mov (sp)+ ,r5
.iif ne ,<$$+1>&1, .error ; bad dst reg for MUL macro
.endm mul
.macro div src,reg
.ntype $$,reg
mov src ,-(sp)
.iif eq ,$$, mov r1 ,-(sp)
.iif eq ,$$-2, mov r3 ,-(sp)
.iif eq ,$$-4, mov r5 ,-(sp)
.globl k11$div
call @k11$div
.if eq, $$
mov (sp)+ ,r1
mov (sp)+ ,r0
.endc
.if eq, $$-2
mov (sp)+ ,r3
mov (sp)+ ,r2
.endc
.if eq, $$-4
mov (sp)+ ,r5
mov (sp)+ ,r4
.endc
.endm div
.macro sob reg,dst
dec reg
bne dst
.endm sob
;- .macro ash amount,reg
;- mov reg ,-(sp)
;- mov amount ,-(sp)
;- .globl $ash
;- call $ash
;- mov (sp)+ ,reg
;-
;- .endm ash
.macro ash amount ,reg
.ntype $$$0 ,amount
.iif ne, 27-$$$0, .error ; must be auto PC for ASH macro
$$type = 1 ; assume left shift
$$size = 0 ; how may asl/asr's to generate
.irpc $a ,<amount> ; parse the first argument
$c = ''$a ; get the character as a literal
.iif eq ,$c - '- , $$type = -1 ; if a minus sign then assume right
.iif eq ,$c - '. , .error ; only use octal in ash macro please
.iif eq ,$c - '^ , .error ; only use default octal radix in ASH
$c = $c - '0 ; check for a digit now
.if ge ,$c ; perhaps a digit
.ift ; well ?
.if le ,$c-7 ; got a digit
.ift ; add into accum then
$$size = <$$size * 10>+$c; simple
.endc
.endc
.endr
.rept $$size
.iif gt, $$type, asl reg
.iif lt, $$type, asr reg
.endr
.endm