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

Subversion Repositories ssbcc

[/] [ssbcc/] [trunk/] [core/] [9x8/] [tb/] [core/] [core.s] - Blame information for rev 7

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

Line No. Rev Author Line
1 2 sinclairrf
; Copyright 2012, Sinclair R.F., Inc.
2
;
3
; Test the core instructions.
4
 
5
.memory RAM ram
6
.variable fred 3 -3
7
.variable joe  0*6
8
 
9
.main
10
 
11
  ; Test the left rotation instructions.
12
  -1 <<0 <<1 <<msb <<msb <<msb <<msb <<msb <<msb <<msb <<msb drop
13
 
14
  ; Test the right rotation instructions.
15
  -1 0>> 1>> msb>> msb>> msb>> msb>> msb>> msb>> lsb>> lsb>> drop
16
 
17
  ; Test the "dup" instruction.
18
  3 4 dup 0<> dup nip nip nip drop
19
 
20
  ; Test the "over" instruction.
21
  3 4 over 0<> nip nip drop
22
 
23
  ; Test the >r, r@, and r> instructions.
24
  3 >r -1 >r r@ r> r@ r> nip nip nip drop
25
 
26
  ; Test the "swap" instruction.
27
  3 4 swap nip drop
28
 
29
  ; Test the addition and subtraction instructions.
30
  8 5 - 7 + drop
31
 
32
  ; Test the comparison operations
33
 
34
 
35
 
36
 
37
 
38
  ; Test the bitwise logical operators
39
  0x11 0x12 &  drop
40
  0x11 0x12 or drop
41
  0x11 0x12 ^  drop
42
 
43
  ; Test the increment and decrement operators
44
  0xFE 1+ 1+ 1+ 1- 1- 1- drop
45
 
46
  ;
47
  ; Test the memory access operators.
48
  ;
49
 
50
  ; get the two pre-loaded values for "fred"
51
  .fetchvector(fred,2) drop drop
52
 
53
  ; Set the entire RAM "ram" to 0xFF.
54
  ${size['ram']-1} :set_mem 0xFF swap .jumpc(set_mem,.store-(ram)) drop
55
 
56
  ; Ensure "fred" was changed.
57
  .fetchvector(fred,2) drop drop
58
 
59
  ; Fetch, alter, and store the first value in "joe" using raw ".fetch(ram)" and ".store(ram)" macros.
60
  joe .fetch(ram) 1- joe .store(ram) drop
61
 
62
  ; Do the same using ".fetchvalue" and ".storevalue" macros.
63
  .fetchvalue(joe) 1- .storevalue(joe) .fetchvalue(joe) drop
64
 
65
  ; Do the same to the third element of "joe".
66
  2 .fetchindexed(joe) 1- 2 .storeindexed(joe) ${joe+2} .fetch(ram) drop
67
 
68
  ; Check the ".storevector" and ".fetch+" macros.
69
  6 7 .storevector(fred,2) fred .fetch+(ram) .fetch(ram) drop drop
70
 
71
  ; Test "call" and "callc" opcodes.
72
  .call(test_callc,3) drop
73
 
74 7 sinclairrf
  ; Test the carry bit operations
75
  0xBF 0x41 +c - +c - +c drop drop drop
76
  0x00 0x02 -c - -c - -c drop drop drop
77
 
78 2 sinclairrf
  ; Hang in an infinite loop.
79
  :infinite .jump(infinite)
80
 
81
; Function to test "callc" opcode
82
; ( u - \sum_n=1^u{n} )
83
.function test_callc
84
  dup 1- .callc(test_callc,nop) .return(+)

powered by: WebSVN 2.1.0

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