ENTRY &file_name PRINT "&file_name" GOSUB DATA_INIT "mio" GOSUB DATA_INIT "pll" GOSUB DATA_INIT "clock" GOSUB DATA_INIT "ddr" GOSUB DATA_INIT "peripherals" ENDDO DATA_INIT: ENTRY &function_name PRINT "&function_name" OPEN #1 &file_name /Read READ #1 %line &myline WHILE !FILE.EOF(1) ( IF STRing.SCAN("&myline","proc",0)!=-1 ( IF STRing.SCAN("&myline",&function_name,0)!=-1 ( PRINT "&myline" READ #1 %line &myline WHILE STRing.SCAN("&myline","}",0)==-1 ( PRINT "&myline" IF STRing.SCAN("&myline","mask_write",0)!=-1 ( &myline=STRING.LOWER("&myline") &index=STRING.SCAN("&myline","0x",0) &address=STRING.MID("&myline",&index,10.) &index=STRING.SCAN("&myline","0x",&index+2) &mask=STRING.MID("&myline",&index,10.) &index=STRING.SCAN("&myline","0x",&index+2) &value=STRING.MID("&myline",&index,10.) GOSUB MASK_WRITE &address &mask &value ) IF STRing.SCAN("&myline","mask_poll",0)!=-1 ( &myline=STRING.LOWER("&myline") &index=STRING.SCAN("&myline","0x",0) &address=STRING.MID("&myline",&index,10.) &index=STRING.SCAN("&myline","0x",&index+2) &value=STRING.MID("&myline",&index,10.) GOSUB MASK_POLL &address &value ) READ #1 %line &myline ) ) ) READ #1 %line &myline ) CLOSE #1 RETURN MASK_WRITE: LOCAL &read &write ENTRY &address &mask &value &read=DATA.LONG(ZSD:&address) &write=(&read&~&mask)|(&value&&mask) DATA.SET ZSD:&address %LONG &write PRINT "&address" PRINT "&write" RETURN MASK_POLL: LOCAL &read &match ENTRY &address &value &read=DATA.LONG(ZSD:&address) &match=&read&&value PRINT "&read" PRINT "&value" PRINT "&match" WHILE &match==0 ( &read=DATA.LONG(ZSD:&address) &match=&read&&value ) RETURN