-
Notifications
You must be signed in to change notification settings - Fork 0
/
cputest.carbrain_asm
90 lines (82 loc) · 1.2 KB
/
cputest.carbrain_asm
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
78
79
80
81
82
83
84
85
86
87
88
89
90
//cputest: Beweeg vooruit als CPU test ok, draai rond bij falen test.
//let op: dit test slechts een minieme fractie van de functionaliteit.
JMP $test
fail:
MOV $IO_DECISION_START, %a
MOVB $DECISION_TURN_LEFT, 1(%a)
MOVB $DECISION_TURN_LEFT, 2(%a)
MOVB $DECISION_TURN_RIGHT, 3(%a)
MOVB $DECISION_TURN_RIGHT, 4(%a)
MOVB $4, (%a)
JMP $fail
test:
MOV %sp, %e
PUSH $7
PUSH $8
CMP $7, $7
JNE $fail
CMP $7, 2(%sp)
JNE $fail
CMP $1, $2
XOR $7, 2(%sp)
JNZ $fail
CMP $0x8, (%sp)
JNE $fail
CMP $1, $2
XOR $0x8, (%sp)
JNZ $fail
MOV %e, %d
SUB %sp, %d
CMP %d, $4
JNE $fail
MOV $2, %c
CMP $2, %c
JNE $fail
CMP %c, $2
JNE $fail
INC %c
JZ $fail
CMP %c, $3
JNE $fail
DEC %c
JZ $fail
CMP %c, $2
JNE $fail
DEC %c
JZ $fail
DEC %c
JNZ $fail
MOV $0x1234, 6(%sp)
CMP 6(%sp), $0x1234
JNE $fail
MOVB 6(%sp), %a
MOVB 7(%sp), %b
CMP %a, $0x12
JNE $fail
CMP %a, $0x34
JNE $fail
MOVB $0x98, 6(%sp)
MOVB $0x76, 7(%sp)
CMP 6(%sp), $0x9876
JNE $fail
POP %a //should be 8
POP %b //should be 7
CMP %e, %sp
JNE $fail
CMP %a, $8
JNE $fail
CMP %b, $7
JNE $fail
CMP $1, $2
TEST %b, $0xFFF8
JNZ $fail
CMP $1, $2
TEST %a, $0xFFF7
JNZ $fail
JE $success
JMP $fail
success:
MOV $IO_DECISION_START, %a
MOVB $DECISION_FORWARD, 1(%a)
MOVB $1, (%a)
JMP $success