|
4 | 4 |
|
5 | 5 | RSpec.describe(AVR::Opcode) do |
6 | 6 | describe "cpse" do |
7 | | - it_behaves_like "opcode", :cpse |
| 7 | + it_behaves_like "opcode", :cpse do |
| 8 | + it "compares r0 == r1, with 1-word instruction" do |
| 9 | + cpu.r0 = 5 |
| 10 | + cpu.r1 = 5 |
| 11 | + cpu.device.flash.set_word(0, 0b0001_0000_0000_0001) # cpse r0, r1 |
| 12 | + cpu.device.flash.set_word(1, 0b0000_0000_0000_0000) # nop |
| 13 | + cpu.step |
| 14 | + expect(cpu.next_pc).to(eq(2)) |
| 15 | + end |
8 | 16 |
|
9 | | - it "compares r0 == r1, with 1-word instruction" do |
10 | | - cpu.r0 = 5 |
11 | | - cpu.r1 = 5 |
12 | | - cpu.device.flash.set_word(0, 0b0001_0000_0000_0001) # cpse r0, r1 |
13 | | - cpu.device.flash.set_word(1, 0b0000_0000_0000_0000) # nop |
14 | | - cpu.step |
15 | | - expect(cpu.next_pc).to(eq(2)) |
16 | | - end |
17 | | - |
18 | | - it "compares r0 == r1, with 2-word instruction" do |
19 | | - cpu.r0 = 5 |
20 | | - cpu.r1 = 5 |
21 | | - cpu.device.flash.set_word(0, 0b0001_0000_0000_0001) # cpse r0, r1 |
22 | | - cpu.device.flash.set_word(1, 0b1001_0100_0000_1100) # jmp ... |
23 | | - cpu.device.flash.set_word(2, 0b1010_1010_1010_1010) # ... 0xaaaa |
24 | | - cpu.device.flash.set_word(3, 0b0000_0000_0000_0000) # nop |
25 | | - cpu.step |
26 | | - expect(cpu.next_pc).to(eq(3)) |
27 | | - end |
| 17 | + it "compares r0 == r1, with 2-word instruction" do |
| 18 | + cpu.r0 = 5 |
| 19 | + cpu.r1 = 5 |
| 20 | + cpu.device.flash.set_word(0, 0b0001_0000_0000_0001) # cpse r0, r1 |
| 21 | + cpu.device.flash.set_word(1, 0b1001_0100_0000_1100) # jmp ... |
| 22 | + cpu.device.flash.set_word(2, 0b1010_1010_1010_1010) # ... 0xaaaa |
| 23 | + cpu.device.flash.set_word(3, 0b0000_0000_0000_0000) # nop |
| 24 | + cpu.step |
| 25 | + expect(cpu.next_pc).to(eq(3)) |
| 26 | + end |
28 | 27 |
|
29 | | - it "compares r0 != r1" do |
30 | | - cpu.r0 = 3 |
31 | | - cpu.r1 = 5 |
32 | | - cpu.device.flash.set_word(0, 0b0001_0000_0000_0001) # cpse r0, r1 |
33 | | - cpu.device.flash.set_word(1, 0b0000_0000_0000_0000) # nop |
34 | | - cpu.step |
35 | | - expect(cpu.next_pc).to(eq(1)) |
| 28 | + it "compares r0 != r1" do |
| 29 | + cpu.r0 = 3 |
| 30 | + cpu.r1 = 5 |
| 31 | + cpu.device.flash.set_word(0, 0b0001_0000_0000_0001) # cpse r0, r1 |
| 32 | + cpu.device.flash.set_word(1, 0b0000_0000_0000_0000) # nop |
| 33 | + cpu.step |
| 34 | + expect(cpu.next_pc).to(eq(1)) |
| 35 | + end |
36 | 36 | end |
37 | 37 | end |
38 | 38 | end |
0 commit comments