;************************************************************************** ;* Although considerable effort has been expended to make this software * ;* correct and reliable, no warranty is implied; the author disclaims any * ;* obligation or liability for damages, including but not limited to * ;* special, indirect, or consequential damages arising out of or in * ;* connection with the use or performance of this software. * ;************************************************************************** .title optim .ident /01/ ; ; This module contains modules implemented in assembly language ; for performance reasons. All of the routines contained here ; can easily be written in C. ; ; Routine Compare_Memory compares two chunks of memory and returns ; zero if they are equal, -1 if the first chuck is logically less ; than the second chunk, and +1 if vice-versa. ; ; The calling sequence is: ; ; Indicator = Compare_Memory (A, B, Len) ; ; A and B are the addresses of the two memory chunks, and Len is ; the length in bytes. ; .psect $code pic,shr,exe,rd,nowrt A = 4 B = 8 Len = 12 .entry Compare_Memory,^m CmpC3 Len(ap), @A(ap), @B(ap) ; Compare the strings BNeq 10$ ; If not equal, do further tests ClrL r0 ; Return 0 Ret ; Return to caller 10$: BLssU 20$ ; If less than, branch MovL #1, r0 ; Return +1 Ret ; Return to caller 20$: MNegL #1, r0 ; Return -1 Ret ; Return to caller ; ; Routine Move_Memory copies data from one location to another. ; ; The calling sequence is: ; ; Length = Move_Memory (In, Out, Len) ; ; In and Out are the addresses of the two memory chunks, and Len is ; the length in bytes. The total length of the block is returned as ; the function value. ; In = 4 Out = 8 Len = 12 .entry Move_Memory,^m MovC3 Len(ap), @In(ap), @Out(ap); Copy the data MovL Len(ap), r0 ; Return input length as output Ret ; Return to caller ; ; Routine Clear_Memory clears (zeroes) a block of memory. ; ; The calling sequence is: ; ; Length = Clear_Memory (Out, Len) ; ; Out is the address of the memory block, and Len is the length ; in bytes. The length of the block is returned as the function ; value. ; Out = 4 Len = 8 .entry Clear_Memory,^m MovC5 #0, (sp), #0, Len(ap), @Out(ap); Zero by copying nulls MovL Len(ap), r0 ; Return input length as output Ret ; Return to caller .end