tripodwang 发表于 2020-3-5 09:11:56

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 *****

xiong 发表于 2020-3-5 17:39:07

hhhhhhhhhhhhhhhh

卖萌的萨满 发表于 2020-3-8 00:06:51

楼主是个好人

吴紹军OHBUT_CC 发表于 2020-3-18 09:53:27

kankan是什么

xuedong.liu 发表于 2020-3-18 13:23:14

感谢分享!

相信自己 发表于 2020-3-20 14:41:22

好好好好好好好好

daben306 发表于 2020-3-21 08:18:47

我们与楼主共同进步

xxxx 发表于 2020-3-23 21:38:06

正好需要这个库,学习了

浮屿 发表于 2020-3-27 10:25:12

xuexiyixia

diguananhai 发表于 2020-3-29 20:00:43

谢谢分享’
页: [1] 2 3 4 5 6 7 8
查看完整版本: OSCAT库文件源代码_ST语言