Powerbasic Museum 2020-B

IT-Consultant: Charles Pegge => Assembler => Best place to post any assembler code => Topic started by: Theo Gottwald on January 14, 2011, 09:39:47 AM

Title: How to get the string-len in ASM
Post by: Theo Gottwald on January 14, 2011, 09:39:47 AM
Of course this should not be a replacement for the original LEN().
It's to show you how to get the string-len of a dynamic string inside your own ASM-Block.

'---------------------------------------------------------------------------
' PBLEN Ermittelt Länge eines dynamischen Strings in PB (wie LEN())

FUNCTION String_Len(sNum AS STRING) AS DWORD
!mov edi,sNum                   ;get the pointer to the string information
!mov edi,[edi]                  ;get the pointer to the string contents
!mov edx,[edi-4]                ;edx now has len of sNum
!mov function,edx               ;write answer to function
END FUNCTION
'---------------------------------------------------------------------------