📄 des3452_1.asm
字号:
;
;LED program for DES3428/DES3452
;
;LED sequence:
;
;Bit NO. 0 1 2 3
;Function 2G/7_SEG_LED 2F/7_SEG_LED 2E/7_SEG_LED 2D/7_SEG_LE
;Bit NO. 4 5 6 7
;Function 2C/7_SEG_LED 2B/7_SEG_LED 2A/7_SEG_LED 1A/1B/7_SEG
;LED for SFP
;Bit NO. 4 5 7 8
;Function LNK/ACT1000_5 LNK/ACT100_5 LNK/ACT1000_4 LNK/ACT100_4
;LED for XE
;Bit NO. 9 10 11 12
;Function LNK/ACT1000_2 LNK/ACT100_2 LNK/ACT1000_1 LNK/ACT100_1
;LED for FE
;Bit NO. 13 14 15 16
;Function LNK/ACT100_29 LNK/ACT10_29 LNK/ACT100_28 LNK/ACT10_2
;...
;Bit NO. 3 2 1 0
;Function LNK/ACT100_7 LNK/ACT10_7 LNK/ACT100_6 LNK/ACT10_6
;Bit NO. 0 1 2 3
;Function 2G/7_SEG_LED 2F/7_SEG_LED 2E/7_SEG_LED 2D/7_SEG_LE
;Bit NO. 4 5 6 7
;Function 2C/7_SEG_LED 2B/7_SEG_LED 2A/7_SEG_LED 1A/1B/7_SEG
; Symbolic names for the bits of the port status fields
;
RX equ 0x0 ; received packet
TX equ 0x1 ; transmitted packet
COLL equ 0x2 ; collision indicator
SPEED_C equ 0x3 ; 100 Mbps
SPEED_M equ 0x4 ; 1000 Mbps
DUPLEX equ 0x5 ; half/full duplex
FLOW equ 0x6 ; flow control capable
LINKUP equ 0x7 ; link down/up status
LINKEN equ 0x8 ; link disabled/enabled status
ZERO equ 0xE ; always 0
ONE equ 0xF ; always 1
LED_FE_END equ 48 ;12+24
LED_SFP_C_END equ 50
LED_SFP_F_END equ 52 ;8 + 2 + 2
LED_XE_END equ 54 ;8 + 2
LED_NULL_END equ 56
LED_MG_END equ 64
LED_TOTAL_NUM equ 64
LED_TOTAL_BITS equ 120
;
LED_TIMER equ 0xC0 ;led timer
counter equ 0xC1 ;led counter
phyport equ 0xC2 ;physical port number
;link_status equ 0xC3 ;current port's link status
;per port's link status
;Host update LED_LINK according link state
;bit0-bit3: timer
;bit4: 0=linkdown, 1=linkup; bit5:medium; bit6:100M/1000M; bit7: 7 segment led
;one byte per port, total 28 bytes
LED_LINK equ 0xC4 ; total 58
begin:
;initialize
ld A, 0
ld (counter), A
ledloop:
;Assign the first port
ld B, 0
ld A, (counter)
call getportmap
ld A, (phyport)
port A
add A, LED_LINK ; A = LED_LINK[phyport]
call led_link_status
inc (counter)
ld A, (counter)
cmp A, LED_TOTAL_NUM
jnz ledloop
sendto:
send LED_TOTAL_BITS
;assume the addrss of link status for phyport has been loaded into A,
led_link_status:
ld B,(counter)
fe_port:
cmp B, LED_FE_END
jnc sfp_c_port
jmp check_link
sfp_c_port:
cmp B, LED_SFP_C_END
jnc sfp_f_port
tst (A), 5
jc LINK_DOWN
jmp check_link
sfp_f_port:
cmp B, LED_SFP_F_END
jnc xe_port
tst (A), 5
jnc LINK_DOWN
jmp check_link
xe_port:
cmp B, LED_XE_END
jnc null_port
;jnc sfp_port
jmp check_link
null_port:
cmp B, LED_NULL_END
jnc seven_seg
jmp LED_OFF_TWOBIT
seven_seg:
cmp B, LED_MG_END ; if (counter >= LED_SEG_END) jmp sfp_port
jnc mg_end
tst (A), 7
jc LED_ON_ONEBIT
jmp LED_OFF_ONEBIT
check_link:
tst (A), 4
jnc LINK_DOWN
traffic:
pushst RX
pushst TX
tor
pop
jc LINK_BLINK
ld B,(A)
and B, 0xF0
ld (A), B ;reset led timer
LINK_UP:
tst (A), 6
jc LED_ON_GREEN
jmp LED_ON_AMBER
;(A): link status; B: counter
LINK_BLINK:
inc (A)
ld B,(A)
and B, 0x0F
cmp B,2
jc LINK_DOWN
cmp B,3
jc LINK_UP
ld B, (A)
and B, 0xF0
ld (A),B
jmp LINK_BLINK
LINK_DOWN:
pushst ONE
pack
LED_OFF_ONEBIT:
pushst ONE
pack
ret
LED_ON_ONEBIT:
pushst ZERO
pack
ret
LED_OFF_TWOBIT:
pushst ONE
pack
pushst ONE
pack
ret
LED_ON_AMBER:
pushst ONE
pack
pushst ZERO
pack
ret
LED_ON_GREEN:
pushst ZERO
pack
pushst ONE
pack
ret
;get portmap, assume counter has been loaded into A
getportmap:
cmp A, LED_FE_END ; if (counter >= LED_SEG_END) jump sfp_portmap
jnc sfp_c_portmap
ld B,6
add A,B
ld (phyport), A
ret
sfp_c_portmap:
cmp A, LED_SFP_C_END
jnc sfp_f_portmap
ld B, 44
sub A, B
ld (phyport), A
ret
sfp_f_portmap:
cmp A, LED_SFP_F_END
jnc xe_portmap
ld B, 46
sub A, B
ld (phyport), A
ret
xe_portmap:
cmp A, LED_XE_END ; if (counter >= LEDSFP_END) jump xe_portmap
jnc mg_portmap
ld B, 51
sub A, B
ld (phyport), A
ret
;sfp_portmap:
; cmp A,LED_SFP_END
; jnc mg_portmap
; ld B, 46
; sub A, B
; ld (phyport), A
; ret
mg_portmap:
cmp A, LED_MG_END
jnc mg_end
ld B, 55
sub A, B
ld (phyport), A
mg_end:
ret
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -