;黒沢尻工業高校専攻科メカトロニクス工学 ;ブレッドボード回路の確認 カウントアップ動作 ; include 16f84.h .osc hs .pwrt on .wdt off .protect off ; org 0ch time ds 1 tm1 ds 1 tm2 ds 1 tm3 ds 1 ; org 0 goto start ;初期設定 RAは全部入力、RBは全部出力ポート start mov !ra,#1fh mov !rb,#0 clr time ;カウント値(時間値)を0にする clr rb ;RBポートを0クリア(LED全部消灯) ; main mov w,time ;現在までのカウント値をWレジスタにロード mov rb,w ;カウント値をLED出力 call wait ;ムダ時間発生 inc time ;カウント値を+1増加 ; btfsc ra,0 ;スイッチSW0オン? goto main ;オフならそのままカウントアップ表示 clr time ;オンならこれまでのカウント値をゼロにする goto main ;ムダ時間発生 wait mov tm3,#2 wait2 clr tm1 wait0 clr tm2 wait1 nop djnz tm2,wait1 djnz tm1,wait0 djnz tm3,wait2 ret