OSCAT库文件源代码_ST语言
OSCAT库文件源代码_ST语言,编写的很精致,很优秀,共同学习一下,哈。(* @NESTEDCOMMENTS := 'Yes' *)(* @PATH := '\/Buffer Management' *)(* @OBJECTFLAGS := '0, 8' *)(* @SYMFILEFLAGS := '2048' *)FUNCTION _BUFFER_CLEAR : BOOLVAR_INPUT PT: POINTER TO BYTE; SIZE: UINT;END_VARVAR ptw: POINTER TO DWORD; temp:DWORD; end,end32 : DWORD;END_VAR (*version 1.2 31.oct. 2008programmer hugotested by oscat this function will initialize a given arrayof byte with 0.the function needs to be called: _buffer_clear(adr("array"),sizeof("array"));this function will manipulate a given array.the function manipulates the original array,it rerturnes true when finished.because this function works with pointers itsvery time efficient and it needs no extra memory. *)(* @END_DECLARATION := '0' *)(* this routine uses 32 bit access to gainspeed *)(* first access bytes till pointer is alignedfor 32 bit access *)temp := pt;end := temp + UINT_TO_DWORD(size);end32 := end - 3;WHILE (pt < end) AND ((temp AND16#00000003) > 0) DO pt^:= 0; pt:= pt + 1; temp:= temp + 1;END_WHILE;(* pointer is aligned, now copy 32 bits at atime *)ptw := pt;WHILE ptw < end32 DO (* *) ptw^:= 0; ptw:= ptw + 4;END_WHILE;(* copy the remaining bytes in byte mode *)pt := ptw;WHILE pt < end DO pt^:= 0; pt:= pt + 1;END_WHILE; _BUFFER_CLEAR := TRUE; (* revision Historyhm 5.mar. 2008 rev 1.0 originalversion hm 16.mar. 2008rev 1.1 addedtype conversion to avoid warnings under codesys 30 chagedtype of input size to uint deletedunused variable i hm 31.oct. 2008rev 1.2 correctedan error while routine would write outside of arrays *)END_FUNCTION
**** Hidden Message ***** hhhhhhhhhhhhhhhh 楼主是个好人
kankan是什么 感谢分享! 好好好好好好好好 我们与楼主共同进步
正好需要这个库,学习了 xuexiyixia 谢谢分享’