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

Subversion Repositories ssbcc

[/] [ssbcc/] [trunk/] [example/] [GameOfLife/] [hdl/] [uc/] [uc.s] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 sinclairrf
; Conway's Game of Life, SSBCC.9x8 implementation
2
; Copyright 2012-2013, Sinclair R.F., Inc.
3
 
4
.include memory.s
5
.include propagate.s
6
 
7
.main
8
 
9
  ; On initial program start-up or on a reset, do the following:
10
  .call(clear_ping_pong_buffers)
11
 
12
  ; Run the program.
13
  :infinite
14
 
15
    .call(process_user_commands)
16
 
17
    ; Don't propagate the state if the the machine is stopped.
18
    .fetch(cmd_stop) .jumpc(infinite)
19
 
20
    ; See if enough frames have elapsed to start updating the next frame.
21
    .fetch(cnt_frame_waits) .jumpc(wait,1-)
22
 
23
      ; Restart the count for the number of frames between updates.
24
      .fetch(cmd_frame_waits) .store(cnt_frame_waits)
25
 
26
      ; Compute the new machine state
27
      .call(propagate)
28
 
29
      ; Swap the read and write ping pong buffer selection.
30
      .fetch(sel_rd) O_PING_PONG_SEL_WR .outport 1 ^ O_PING_PONG_SEL_RD .outport .store(sel_rd)
31
 
32
      .jump(no_wait)
33
 
34
    ; Otherwise, store the decremented wait count.
35
    :wait
36
 
37
      .store(cnt_frame_waits)
38
 
39
    :no_wait
40
 
41
    ; Wait until the current video frame ends.
42
    :wait_until_frame_ended .inport(I_FRAME_ENDED) 0= .jumpc(wait_until_frame_ended)
43
 
44
  .jump(infinite)
45
 
46
; Clear the two ping pong buffers.
47
; ( - )
48
.function clear_ping_pong_buffers
49
  ; Loop through the memory banks.
50
  ${C_N_MEM_BANKS-1} :loop_sel
51
    ; Output the bank index, but don't remove it from the data stack.
52
    O_PING_PONG_SEL_WR .outport
53
    ; Loop through the high memory addresses.
54
    ${C_N_MEM_LINES-1} :loop_high
55
      ; Output the line index, but don't remove it from the data stack.
56
      O_ADDR_HIGH .outport
57
      ; Loop through the low memory addresses and write a 0 to the associated address.
58
      ${C_N_MEM_WORDS-1} :loop_low
59
        ; Output the word index, but don't remove it from the data stack.
60
        O_ADDR_LOW .outport
61
        ; Clear all bits at the commanded word.
62
 
63
        .jumpc(loop_low,1-) drop
64
      .jumpc(loop_high,1-) drop
65
    .jumpc(loop_sel,1-)
66
  .return(drop)

powered by: WebSVN 2.1.0

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