/********************************************************** msecwait関数で1秒ごとのLEDのON-OFFを行う **********************************************************/ /*****************************************************************         スタートアップ部 変更の必要は無い *****************************************************************/ #pragma asm STACKEND .EQU H'FFF10 .SECTION VEC, DATA, LOCATE=H'000000 .ORG H'000000 ;RESET VECTOR .DATA.L BEGIN .SECTION P,CODE,ALIGN=2 BEGIN: MOV.L #STACKEND,ER7 ;set stack pointer ;***** move Section D(ROM) to Section X(RAM) ***** MOV.L @_D_Head,ER0 ;source address to ER0 MOV.L @_X_Head,ER1 ;destination address to ER1 MOV.L @_D_Size,ER2 ;size to be copied to ER2 OR.L ER2,ER2 ;(ER2 or ER2) to ER2 JMP @LOOP_11 LOOP_1: MOV.B @ER0+,R3H ;source byte to E3H with ER0++ MOV.B R3H,@ER1 ;E3H to destination INC.L #1,ER1 ;increment destination address DEC.L #1,ER2 ;ER2-- LOOP_11: BNE LOOP_1 ;***** clear Section B ***** MOV.L @_B_Head,ER1 ;destination address to ER1 MOV.L @_B_Size,ER2 ;size to be copied to ER2 MOV.B #0,R3H ;0 to R3H OR.L ER2,ER2 ;(ER2 or ER2) to ER2 JMP @LOOP_21 LOOP_2: MOV.B R3H,@ER1 ;R3H to destination INC.L #1,ER1 ;increment destination address DEC.L #1,ER2 ;ER2-- LOOP_21: BNE LOOP_2 JSR @_main ; Call main() EternalLoop: BRA EternalLoop .SECTION D, DATA, ALIGN = 2 .SECTION X, DATA, ALIGN = 2 .SECTION B, DATA, ALIGN = 2 .SECTION C, DATA, ALIGN = 2 _D_Head: .DATA.L (STARTOF D) ; Section D Head Address _X_Head: .DATA.L (STARTOF X) ; Section X Head Address _D_Size: .DATA.L (SIZEOF D) ; Section D Size _B_Head: .DATA.L (STARTOF B) ; Section B Head Address _B_Size: .DATA.L (SIZEOF B) ; Section B Size .SECTION P,CODE,ALIGN=2 ;これを忘れてはいけない #pragma endasm /* メモ CPU割り込みマスククリアE_INT()と割り込みマスクセットD_INT()の表現 #pragma asm ANDC.B #B'01111111,CCR ;E_ENT() #pragma endasm #pragma asm ORC.B #B'10000000,CCR ;D_ENT() #pragma endasm */ /********************ここから通常のCプログラム********************/ #include <3048f.h> #include "h8_3048.h" void msecwait(int msec) { int i,j; for (i=0;i