STM8S103 >> Assembly

Button


表格


main.s

  .equ PA_ODR, 0x5000
  .equ PA_IDR, 0x5001
  .equ PA_DDR, 0x5002
  .equ PA_CR1, 0x5003
  .equ PA_CR2, 0x5004
  .equ PB_ODR, 0x5005
  .equ PB_IDR, 0x5006
  .equ PB_DDR, 0x5007
  .equ PB_CR1, 0x5008
  .equ PB_CR2, 0x5009
     
  .area data
  .area sseg
  .area home
  int main
   
  .area cseg
main:
  mov PA_DDR, #0x00
  mov PA_CR1, #0x02
  mov PB_DDR, #0x20
  mov PB_CR1, #0x20

loop:
  btjf PA_IDR, #1, press
  bset PB_ODR, #5
  jp loop
press:
  bres PB_ODR, #5
  jp loop

編譯、燒錄

$ sdasstm8 -o main.s
$ sdldstm8 -ni -b home=0x8000 -b cseg=0x8080 -b data=0x0001 -b sseg=0xffff main.rel
$ sudo stm8flash -c stlinkv2 -p stm8s103f3 -u
$ sudo stm8flash -c stlinkv2 -p stm8s103f3 -s flash -w main.ihx

完成


返回上一頁