Major Member
|
LED_PORT_1 = 0x00
LED_PORT_2 = 0x00
LED_STATUS_1 = 0x00
LED_STATUS_2 = 0x00
LED_STATUS_3 = 0x00
LED_STATUS_4 = 0x00
SET X = 0 ; Index X = 0
TEST_LOOP:
Set Flag C = 1
LED_STATUS_1 = ROL LED_STATUS_1 ; 0x01 C <- |7|6|5|4|3|2|1|0| <- C
LED_STATUS_2 = ROL LED_STATUS_2 ; 0x00 C <- |7|6|5|4|3|2|1|0| <- C
LED_STATUS_3 = LED_PORT_1_TABLE,X ; Index X get Table Data
LED_STATUS_4 = LED_PORT_2_TABLE,X ; Index X get Table Data
LED_STATUS_1 = LED_STATUS_1 OR LED_STATUS_3
LED_STATUS_2 = LED_STATUS_2 OR LED_STATUS_4
LED_PORT_1 = LED_STATUS_1 ; 0x01
LED_PORT_2 = LED_STATUS_2 ; 0x00
LED_PORT_1 = LED_STATUS_1 xor LED_STATUS_3 ; 0x00
LED_PORT_2 = LED_STATUS_2 xor LED_STATUS_4 ; 0x00
LED_PORT_1 = LED_STATUS_1 ; 0x01
LED_PORT_2 = LED_STATUS_2 ; 0x00
LED_PORT_1 = LED_STATUS_1 xor LED_STATUS_3 ; 0x00
LED_PORT_2 = LED_STATUS_2 xor LED_STATUS_4 ; 0x00
LED_PORT_1 = LED_STATUS_1 ; 0x01
LED_PORT_2 = LED_STATUS_2 ; 0x00
LED_PORT_1 = LED_STATUS_1 xor LED_STATUS_3 ; 0x00
LED_PORT_2 = LED_STATUS_2 xor LED_STATUS_4 ; 0x00
INC X ; Index X + 1
CMP X,#0A
BNE TEST_LOOP
LED_PORT_1 = #0FFH
LED_PORT_2 = #0FFH
JMP $
LED_PORT_1_TABLE:
.DB $01,$02,$04,$08,$70,$80,$00,$00,$00,$00
LED_PORT_2_TABLE:
.DB $00,$00,$00,$00,$00,$00,$01,$02,$1C,$60
============================================
我沒辦法給你8051正確的寫法~
所以只能用觀念來教你~
上述的方式我已經用Code去驗證過了~
可以完整呈現你上面貼的流程~
方法好不好是其次~ 不過Size應該可以省不少喔~
因為我貼的是不屬於任何語法~ 試著寫看看吧~
加油喔~~~
.
.
|