//MACRO Buffer.copy ToBuffer, FromBuffer, Length, WReg //-------------------------------------------------------------------------------------------------- // // @ CopyRight Roberti & Parau Enterprises, Inc. 2021-2023 // // This work is licensed under the Creative Commons Attribution-NoDerivatives 4.0 International License. // To view a copy of this license, visit http://creativecommons.org/licenses/by-nd/4.0/ // or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. // //-------------------------------------------------------------------------------------------------- // // // Set up variables // eval(DVASM.getEnv()[4]); var ld= "L" + abiWID; var st= "S" + abiWID; var wl= abiWLen; var wn= abiWID == "D" ? "double word" : "word"; // // Generate code // \#Label ADD #Length, #ToBuffer // Compute and of buffer addr \ ADDI #Length, -#wl // Subtract #wn to it \ WHILE Condition= ( #ToBuffer <= #Length ) // Start loop to copy all #wn.s \ #ld #WReg, 0[#FromBuffer] // Load next #wn in 'from buffer' \ #st #WReg, 0[#ToBuffer] // Store it in 'to buffer' \ ADDI #ToBuffer, #wl // Load next 'to buffer' #wn address \ ADDI #FromBuffer, #wl // Load next 'from buffer' #wn address \ ENDWHILE \ ADDI #Length, #wl // Restore end of buffer addr \ WHILE Condition= ( #ToBuffer < #Length ) // Start residual length loop \ LBU #WReg, 0[#FromBuffer] // Load first byte in 'from buffer' \ SB #WReg, 0[#ToBuffer] // Store it in 'to buffer' \ ADDI #ToBuffer, 1 // Add 1 to 'to buffer' addr \ ADDI #FromBuffer, 1 // Add 1 to 'from buffer' addr \ ENDWHILE