FUNCTION "DBtoDB" : VOID
TITLE =
AUTHOR : BaiZH
FAMILY : IR
NAME : DBtoDB
VERSION : 0.1
VAR_INPUT
SRC_DB : INT ; //Source DB Block Number
SRC_SttAddr : INT ; //Start Address of the Sending Data in SRC_DB
SendNum : INT ; //Words Number Need Sending
DST_DB : INT ; //Destination DB Block Number
DST_SttAddr : INT ; //Start Address of the Receiving Data in DST_DB
END_VAR
VAR_IN_OUT
Enable : BOOL ; //Enable Bit
END_VAR
VAR_TEMP
DB_LOAD_TEMP : INT ;
Loop_Val : INT ; //Send Data Loop Value
DB_SAVE : INT ;
DI_SAVE : INT ;
AR1_SAVE : DWORD ;
AR2_SAVE : DWORD ;
END_VAR
BEGIN
NETWORK
TITLE =Send Data
//Move data from DB to DB
A #Enable;
JCN END;
TAR1 #AR1_SAVE; // Save AR and Opened DB
TAR2 #AR2_SAVE;
L DBNO;
T #DB_SAVE;
L DINO;
T #DI_SAVE;
L #SRC_DB; //Open DB
T #DB_LOAD_TEMP; //这里为什么要多用个“#DB_LOAD_TEMP”临时变量啊?
OPN DB [#DB_LOAD_TEMP];
L #DST_DB; //Open DB
T #DB_LOAD_TEMP;
OPN DI [#DB_LOAD_TEMP];
L #SRC_SttAddr; //Load Start Address
SLD 3; //这里为什么用这个指令?有什么用?
LAR1 ;
L #DST_SttAddr;
SLD 3;
LAR2 ;
L #SendNum;
LP1: T #Loop_Val; //Move Data
L DBW [AR1,P#0.0];
T DIW [AR2,P#0.0];
+AR1 P#2.0;
+AR2 P#2.0;
L #Loop_Val;
LOOP LP1;
LAR1 #AR1_SAVE; //Recover Original AR and DB
LAR2 #AR2_SAVE;
OPN DB [#DB_SAVE];
OPN DI [#DI_SAVE];
SET ;
R #Enable;
END: NOP 0;
END_FUNCTION
<link href="/templates/xhtml2/skins/xhtml/digg/style3/style.css" type="text/css" rel="stylesheet"/>