openbcm

Git mirror of https://github.com/Broadcom-Network-Switching-Software/OpenBCM
git clone git://git.finwo.net/mirror/broadcom/openbcm
Log | Files | Refs | README

pong-wk.asm (2393B)


      1 ;
      2 ;
      3 ;
      4 ; This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
      5 ; 
      6 ; Copyright 2007-2019 Broadcom Inc. All rights reserved.
      7 ; 
      8 ;
      9 ; This is the silly Pong program for the White Knight 5690.
     10 ; To start it, use the following commands from BCM:
     11 ;
     12 ;	led load pong-wk.hex
     13 ;	led auto on
     14 ;	led start
     15 ;
     16 
     17 TICKS		EQU	1
     18 SECOND_TICKS	EQU	(30*TICKS)
     19 UPDATE_TICKS	EQU	(SECOND_TICKS/10)
     20 
     21 POS_X		EQU	0xa0
     22 POS_Y		EQU	0xa1
     23 DIR_X		EQU	0xa2
     24 DIR_Y		EQU	0xa3
     25 TIMER		EQU	0xa4
     26 
     27 update:
     28 	ld	a,(DIR_X)
     29 	cmp	a,0
     30 	jnz	up1
     31 	; If DIR variable is 0, it tells us to do first time init
     32 	ld	a,1
     33 	ld	(DIR_X),a
     34 	ld	(DIR_Y),a
     35 up1:	
     36 	; Display ball at position (POS_X, POS_Y)
     37 
     38 	ld	a,0		; column
     39 
     40 update_col:
     41 	cmp	a,(POS_X)
     42 	jz	up3
     43 	call	led_black
     44 	call	led_black
     45 	call	led_black
     46 	call	led_black
     47 	jmp	next_col
     48 up3:
     49 	ld	b,(POS_Y)	; 1st row
     50 	cmp	b,0
     51 	jnz	up4
     52 	call	led_green
     53 	jmp	up5	
     54 up4:
     55 	call	led_black
     56 up5:
     57 
     58 	dec	b		; 2nd row
     59 	jnz	up6
     60 	call	led_green
     61 	jmp	up7
     62 up6:
     63 	call	led_black
     64 up7:
     65 
     66 	dec	b		; 3rd row
     67 	jnz	up8
     68 	call	led_green
     69 	jmp	up9
     70 up8:
     71 	call	led_black
     72 up9:
     73 	dec	b		; 4th row
     74 	jnz	up10
     75 	call	led_green
     76 	jmp	up11
     77 up10:
     78 	call	led_black
     79 up11:
     80 
     81 next_col:
     82 	inc	a
     83 	cmp	a,12
     84 	jc	update_col
     85 
     86 	; Update position if timer expires
     87 
     88 	inc	(TIMER)
     89 	ld	a,(TIMER)
     90 	cmp	a,UPDATE_TICKS
     91 	jnz	skip_update
     92 	sub	a,a
     93 	ld	(TIMER),a
     94 
     95 	ld	a,(POS_X)
     96 	add	a,(DIR_X)
     97 	ld	(POS_X),a
     98 	cmp	a,0
     99 	jnz	up20
    100 	ld	a,1
    101 	ld	(DIR_X),a
    102 	jmp	up21
    103 up20:
    104 	cmp	a,5
    105 	jnz	up21
    106 	ld	a,-1
    107 	ld	(DIR_X),a
    108 up21:
    109 
    110 	ld	a,(POS_Y)
    111 	add	a,(DIR_Y)
    112 	ld	(POS_Y),a
    113 	cmp	a,0
    114 	jnz	up22
    115 	ld	a,1
    116 	ld	(DIR_Y),a
    117 	jmp	up23
    118 up22:
    119 	cmp	a,3
    120 	jnz	up23
    121 	ld	a,-1
    122 	ld	(DIR_Y),a
    123 up23:
    124 
    125 skip_update:
    126 
    127 	send	48
    128 
    129 ;
    130 ; led_black, led_amber, led_green
    131 ;
    132 ;  Inputs: None
    133 ;  Outputs: Two bits to the LED stream indicating color
    134 ;  Destroys: None
    135 ;
    136 
    137 led_black:
    138 	pushst	ZERO
    139 	pack
    140 	pushst	ZERO
    141 	pack
    142 	ret
    143 
    144 led_green:
    145 	pushst	ZERO
    146 	pack
    147 	pushst	ONE
    148 	pack
    149 	ret
    150 
    151 led_amber:
    152 	pushst	ONE
    153 	pack
    154 	pushst	ZERO
    155 	pack
    156 	ret
    157 
    158 ;
    159 ; Symbolic names for the bits of the port status fields
    160 ;
    161 
    162 RX		equ	0x0	; received packet
    163 TX		equ	0x1	; transmitted packet
    164 COLL		equ	0x2	; collision indicator
    165 SPEED_C		equ	0x3	; 100 Mbps
    166 SPEED_M		equ	0x4	; 1000 Mbps
    167 DUPLEX		equ	0x5	; half/full duplex
    168 FLOW		equ	0x6	; flow control capable
    169 LINKUP		equ	0x7	; link down/up status
    170 LINKEN		equ	0x8	; link disabled/enabled status
    171 ZERO		equ	0xE	; always 0
    172 ONE		equ	0xF	; always 1