微處理器 - STCmicro STC15W104 - Assembly - LED



參考資訊:
http://plit.de/asem-51/
http://www.stcisp.com/stcisp620_off.html
https://sourceforge.net/projects/mcu8051ide/

I/O驅動方式

P.S. I/O預設是8051雙向模式

main.s

    .org 0h
    jmp _start
  
    .org 100h
_start:
    setb p3.2
    call delay_1s
    clr p3.2
    call delay_1s
    jmp _start
 
    ; 1t + ((1t + (4t * 250) + 4t) * 200t) + 4t = 201005t
    ; 11.0592MHz = 0.09042us
    ; 201005t * 0.09042us = 18175us
delay_18ms: 
    mov r7, #200
d0:
    mov r6, #250
d1: 
    djnz r6, d1
    djnz r7, d0
    ret

    ; 1t + ((4t + 201005t + 4t) * 55) + 4t = 11055720t
    ; 11055720t * 0.09042us = 999658us ~= 1s
delay_1s: 
    mov r5, #55
d2: 
    call delay_18ms
    djnz r5, d2
    ret
    .end

編譯

$ mcu8051ide --compile main.s

接著透過STC-ISP燒錄即可