-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathinout.mms
77 lines (72 loc) · 1.66 KB
/
inout.mms
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
* Coroutine example for 1.4.2
t IS $255
in GREG
out GREG
* Input and output buffers
LOC Data_Segment
GREG @
OutBuf TETRA " ",#a,0
Period BYTE '.'
InArgs OCTA InBuf,1000
InBuf LOC #100
* Subroutine for character input
inptr GREG
1H LDA t,InArgs
TRAP 0,Fgets,StdIn
LDA inptr,InBuf
0H GREG Period
CSN inptr,t,0B
NextChar LDBU $0,inptr,0
INCL inptr,1
BZ $0,1B
CMPU t,$0,' '
BNP t,NextChar
POP 1,0
* First coroutine
count GREG
1H GO in,out,0
In1 PUSHJ $0,NextChar
CMPU t,$0,'9'
PBP t,1B
SUB count,$0,'0'
BN count,1B
PUSHJ $0,NextChar
1H GO in,out,0
SUB count,count,1
PBNN count,1B
JMP In1
* Second coroutine
outptr GREG
1H LDA t,OutBuf
TRAP 0,Fputs,StdOut
Out1 LDA outptr,OutBuf
2H GO out,in,0
STBU $0,outptr,0
CMP t,$0,'.'
BZ t,1F
GO out,in,0
STBU $0,outptr,1
CMP t,$0,'.'
BZ t,2F
GO out,in,0
STBU $0,outptr,2
CMP t,$0,'.'
BZ t,3F
INCL outptr,4
0H GREG OutBuf+4*16
CMP t,outptr,0B
PBNZ t,2B
JMP 1B
3H INCL outptr,1
2H INCL outptr,1
0H GREG #a
1H STBU 0B,outptr,1
0H GREG 0
STBU 0B,outptr,2
LDA t,OutBuf
TRAP 0,Fputs,StdOut
TRAP 0,Halt,0
* Initialization
Main LDA inptr,InBuf
GETA in,In1
JMP Out1