1*** Variables ***
2${REPL}=            SEPARATOR=
3...  """                                                                           ${\n}
4...  nvic: IRQControllers.NVIC @ {                                                 ${\n}
5...      sysbus new Bus.BusPointRegistration { address: 0xe000e000; cpu: cpu }     ${\n}
6...  }                                                                             ${\n}
7...  ${SPACE*4}-> cpu@0                                                            ${\n}
8...                                                                                ${\n}
9...  cpu: CPU.CortexM @ sysbus                                                     ${\n}
10...  ${SPACE*4}cpuType: "cortex-m7"                                                ${\n}
11...  ${SPACE*4}nvic: nvic                                                          ${\n}
12...  """
13
14*** Keywords ***
15Create Machine
16    Execute Command        using sysbus
17    Execute Command        mach create
18    Execute Command        machine LoadPlatformDescriptionFromString ${REPL}
19    Execute Command        cpu ExecutionMode SingleStep
20    Execute Command        cpu PC 0x0
21    Execute Command        machine LoadPlatformDescriptionFromString "mem: Memory.MappedMemory @ sysbus 0x0 { size: 0x8000000 }"
22
23*** Test Cases ***
24Signed Byte Addition Should Set GE Flag If And Only If The Result Is Greater Or Equal To Zero (sadd8)
25    ${prog}=               Catenate  SEPARATOR=\n
26    ...                    movw r0, #0x0000
27    ...                    movt r0, #0x0000
28    ...                    movw r1, #0xFFFF
29    ...                    movt r1, #0xFFFF
30    ...                    movw r2, #0x0C0A
31    ...                    movt r2, #0x0C0A
32    ...                    movw r3, #0xF5F5
33    ...                    movt r3, #0xF5F5
34    ...                    sadd8 r2, r2, r3
35    ...                    sel r4, r1, r0
36
37    Create Machine
38
39    Execute Command        sysbus.cpu AssembleBlock 0 "${prog}"
40
41    Execute Command        cpu Step 10
42
43    ${ret}=                Execute Command  sysbus.cpu GetRegister "R4"
44
45    Should Be Equal As Numbers  ${ret}  0xFF00FF00
46
47Signed Word Addition Should Set GE Flag If And Only If The Result Is Greater Or Equal To Zero (sadd16)
48    ${prog}=               Catenate  SEPARATOR=\n
49    ...                    movw r0, #0x0000
50    ...                    movt r0, #0x0000
51    ...                    movw r1, #0xFFFF
52    ...                    movt r1, #0xFFFF
53    ...                    movw r2, #0x0A23
54    ...                    movt r2, #0x0A25
55    ...                    movw r3, #0xF123
56    ...                    movt r3, #0xFAA2
57    ...                    sadd16 r2, r2, r3
58    ...                    sel r4, r1, r0
59
60    Create Machine
61
62    Execute Command        sysbus.cpu AssembleBlock 0 "${prog}"
63
64    Execute Command        cpu Step 10
65
66    ${ret}=                Execute Command  sysbus.cpu GetRegister "R4"
67
68    Should Be Equal As Numbers  ${ret}  0xFFFF0000
69
70Signed Byte Subtraction Should Set GE Flag If And Only If The Result Is Greater Or Equal To Zero (ssub8)
71    ${prog}=               Catenate  SEPARATOR=\n
72    ...                    movw r0, #0x0000
73    ...                    movt r0, #0x0000
74    ...                    movw r1, #0xFFFF
75    ...                    movt r1, #0xFFFF
76    ...                    movw r2, #0x0A0C
77    ...                    movt r2, #0x0A0C
78    ...                    movw r3, #0x0B0B
79    ...                    movt r3, #0x0B0B
80    ...                    ssub8 r2, r2, r3
81    ...                    sel r4, r1, r0
82
83    Create Machine
84
85    Execute Command        sysbus.cpu AssembleBlock 0 "${prog}"
86
87    Execute Command        cpu Step 10
88
89    ${ret}=                Execute Command  sysbus.cpu GetRegister "R4"
90
91    Should Be Equal As Numbers  ${ret}  0x00FF00FF
92
93Signed Word Subtraction Should Set GE Flag If And Only If The Result Is Greater Or Equal To Zero (ssub16)
94    ${prog}=               Catenate  SEPARATOR=\n
95    ...                    movw r0, #0x0000
96    ...                    movt r0, #0x0000
97    ...                    movw r1, #0xFFFF
98    ...                    movt r1, #0xFFFF
99    ...                    movw r2, #0x0A25
100    ...                    movt r2, #0x0A23
101    ...                    movw r3, #0x0A24
102    ...                    movt r3, #0x0A24
103    ...                    ssub16 r2, r2, r3
104    ...                    sel r4, r1, r0
105
106    Create Machine
107
108    Execute Command        sysbus.cpu AssembleBlock 0 "${prog}"
109
110    Execute Command        cpu Step 10
111
112    ${ret}=                Execute Command  sysbus.cpu GetRegister "R4"
113
114    Should Be Equal As Numbers  ${ret}  0x0000FFFF
115
116Unsigned Byte Subtraction Should Set GE Flag If And Only If The Result Is Greater Or Equal To Zero (usub8)
117    ${prog}=               Catenate  SEPARATOR=\n
118    ...                    movw r0, #0x0000
119    ...                    movt r0, #0x0000
120    ...                    movw r1, #0xFFFF
121    ...                    movt r1, #0xFFFF
122    ...                    movw r2, #0x0A0C
123    ...                    movt r2, #0x0C0A
124    ...                    movw r3, #0x0B0B
125    ...                    movt r3, #0x0B0B
126    ...                    ssub8 r2, r2, r3
127    ...                    sel r4, r1, r0
128
129    Create Machine
130
131    Execute Command        sysbus.cpu AssembleBlock 0 "${prog}"
132
133    Execute Command        cpu Step 10
134
135    ${ret}=                Execute Command  sysbus.cpu GetRegister "R4"
136
137    Should Be Equal As Numbers  ${ret}  0xFF0000FF
138
139Unsigned Word Subtraction Should Set GE Flag If And Only If The Result Is Greater Or Equal To Zero (usub16)
140    ${prog}=               Catenate  SEPARATOR=\n
141    ...                    movw r0, #0x0000
142    ...                    movt r0, #0x0000
143    ...                    movw r1, #0xFFFF
144    ...                    movt r1, #0xFFFF
145    ...                    movw r2, #0x0A25
146    ...                    movt r2, #0x0A23
147    ...                    movw r3, #0x0A24
148    ...                    movt r3, #0x0A24
149    ...                    usub16 r2, r2, r3
150    ...                    sel r4, r1, r0
151
152    Create Machine
153
154    Execute Command        sysbus.cpu AssembleBlock 0 "${prog}"
155
156    Execute Command        cpu Step 10
157
158    ${ret}=                Execute Command  sysbus.cpu GetRegister "R4"
159
160    Should Be Equal As Numbers  ${ret}  0x0000FFFF
161