OpenCores
URL https://opencores.org/ocsvn/eco32/eco32/trunk

Subversion Repositories eco32

[/] [eco32/] [trunk/] [fp/] [implementation/] [mmix/] [inout.mms] - Blame information for rev 244

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 15 hellwig
* Coroutine example for 1.4.2
2
t        IS    $255
3
in       GREG
4
out      GREG
5
 
6
* Input and output buffers
7
         LOC  Data_Segment
8
         GREG  @
9
OutBuf   TETRA "               ",#a,0
10
Period   BYTE  '.'
11
InArgs   OCTA  InBuf,1000
12
InBuf    LOC   #100
13
 
14
* Subroutine for character input
15
inptr    GREG
16
1H       LDA   t,InArgs
17
         TRAP  0,Fgets,StdIn
18
         LDA   inptr,InBuf
19
0H       GREG  Period
20
         CSN   inptr,t,0B
21
NextChar LDBU  $0,inptr,0
22
         INCL  inptr,1
23
         BZ    $0,1B
24
         CMPU  t,$0,' '
25
         BNP   t,NextChar
26
         POP   1,0
27
 
28
* First coroutine
29
count    GREG
30
1H       GO    in,out,0
31
In1      PUSHJ $0,NextChar
32
         CMPU  t,$0,'9'
33
         PBP   t,1B
34
         SUB   count,$0,'0'
35
         BN    count,1B
36
         PUSHJ $0,NextChar
37
1H       GO    in,out,0
38
         SUB   count,count,1
39
         PBNN  count,1B
40
         JMP   In1
41
 
42
* Second coroutine
43
outptr   GREG
44
1H       LDA   t,OutBuf
45
         TRAP  0,Fputs,StdOut
46
Out1     LDA   outptr,OutBuf
47
2H       GO    out,in,0
48
         STBU  $0,outptr,0
49
         CMP   t,$0,'.'
50
         BZ    t,1F
51
         GO    out,in,0
52
         STBU  $0,outptr,1
53
         CMP   t,$0,'.'
54
         BZ    t,2F
55
         GO    out,in,0
56
         STBU  $0,outptr,2
57
         CMP   t,$0,'.'
58
         BZ    t,3F
59
         INCL  outptr,4
60
0H       GREG  OutBuf+4*16
61
         CMP   t,outptr,0B
62
         PBNZ  t,2B
63
         JMP   1B
64
3H       INCL  outptr,1
65
2H       INCL  outptr,1
66
0H       GREG  #a
67
1H       STBU  0B,outptr,1
68
0H       GREG  0
69
         STBU  0B,outptr,2
70
         LDA   t,OutBuf
71
         TRAP  0,Fputs,StdOut
72
         TRAP  0,Halt,0
73
 
74
* Initialization
75
Main     LDA   inptr,InBuf
76
         GETA  in,In1
77
         JMP   Out1

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.