initial
[fpgammix.git] / regression-tests / test-div / test-div-kernel.mms
blobb6368d546f871a999af01a5813b87cf76d1b0960
1 % Run some simple tests on DIV (signed)
3 % This depends on working GETA, LDOU, PUT
4 % TRAP, SETL, CMP, BZ
6         LOC     #80000000
8 Main    GETA    $255,Traphandler
9         BNN     $255,1F
10         PUT     rT,$255                 % We only try this in supervisor mode
11 1H      GETA    $255,FailMsg
12         GETA    $0,Numbers
13 Loop    PUT     rA,0                    % clear current exception
14         LDOU    $1,$0,0                 % Quotent
15         LDOU    $2,$0,8                 % Divisor
16         LDOU    $3,$0,16                % Expected result
17         LDOU    $4,$0,24                % Expected remainder
18         LDOU    $7,$0,32                % Expected exception
20         DIV     $5,$1,$2                % check result
21         CMPU    $6,$5,$3
22         BNZ     $6,Done
24         GET     $5,rR                   % check remainder
25         CMPU    $6,$5,$4
26         BNZ     $6,Done
28         GET     $5,rA                   % check current exception
29         AND     $5,$5,(1<<6)|(1<<7)     % keep only DV bits
30         CMPU    $6,$5,$7
31         BNZ     $6,Done
33         ADDU    $0,$0,40                % move to next data tuple
34         GETA    $1,End
35         CMP     $1,$0,$1
36         BNZ     $1,Loop
38         GETA    $255,PassMsg
40 Done    TRAP    0,Fputs,StdOut
41         TRAP    0,Halt,0
43 PassMsg BYTE    "Passed",#a,0
44 FailMsg BYTE    "Failed!",#a,0
46 Numbers OCTA    -17092006
47         OCTA         2020
48         OCTA        -8462
49         OCTA         1234
50         OCTA    #0
52         OCTA     17092006
53         OCTA        -2020
54         OCTA        -8462
55         OCTA        -1234
56         OCTA    #0
59         OCTA    #8000000000000017
60         OCTA    #0
61         OCTA    #0
62         OCTA    #8000000000000017
63         OCTA    1<<7                    % expect the D divide exception
65         OCTA    20060917
66         OCTA        1646
67         OCTA       12187
68         OCTA        1115
69         OCTA           0
71         OCTA    -17092006
72         OCTA        -2020
73         OCTA         8461
74         OCTA         -786
75         OCTA    #0
77         OCTA    #8000000000000000
78         OCTA    #FFFFFFFFFFFFFFFF
79         OCTA    #8000000000000000
80         OCTA    #0
81         OCTA    1<<6                    % expect the V integer overflow exception
83         OCTA    #8000000000000017
84         OCTA    #0
85         OCTA    #0
86         OCTA    #8000000000000017
87         OCTA    1<<7                    % expect the D divide exception
89 End     OCTA           0
91 % XXX This should be a separate module prefixed to .txt files
92 % XXX I just need to pick a good address for the Traphandler
93 % This has no impact on mmix simulation, but is for RTL
94 Traphandler     GET     $255,rBB
95                 LDBU    $0,$255
96                 SETH    $1,1
97 1H              LDO     $2,$1
98                 PBOD    $2,1B
99                 STO     $0,$1
100                 PUT     255,255