; ======================= source-file: _length_1.asm ============================
;
; Purpose: fast string, binary and list length, combined into _one_ predicate.
; This particular file implements the 2nd variant (to get the size of binaries)
; GLOBAL PREDICATES
; UNSIGNED length(STRING) -(i) language c
; UNSIGNED length(BINARY) -(i) language c
; % ...(etc)...
; ----------------------------------------------------------------------------
IDEAL
P586
MODEL FLAT
CODESEG
align 4
public _length_1
PROC _length_1 near ; UNSIGNED length(BINARY) -(i) language c
mov ecx,[esp+4] ; binary, ARG-1
mov eax,[dword ptr ecx-4] ; length of binary is stored in prev. 4 bytes
sub eax,4 ; subtract 4 from this length
ret
ENDP _length_1
END
/************************ VISUAL PROLOG TEST-PROGRAM: *************************/
GLOBAL PREDICATES
UNSIGNED length(STRING) -(i) language c % "_length_0" variant
UNSIGNED length(BINARY) -(i) language c % "_length_1" variant
% UNSIGNED length(ILIST) -(i) language c % "_length_2" variant
% ...(etc)...
GOAL
repeat, write("\nGive a Binary-size: "), readint(SZ), Bx = makebinary(SZ),
N5 = length(Bx), write("Binarylength = ",N5,", BinarySize = ",SZ),
write("\nPress ESC for the next test; any other key to continue:\n"),
readchar(C5x), C5x='\27', !.
; ************** "32-bit Assembly Language Extensions for Visual Prolog" ****************
; Written by George A. Stathis (c) 2005, E-mail: omadeon@yahoo.com, gstathis@enm.gr
; URL: http://www.omadeon.com/asm Company: ENB Ltd. Company site: http://www.enb.gr
; All use of this source-code is unrestricted, provided that the author is mentioned.