; Listing2-5.asm
;
; A sample program that demonstrates calling various
; C/C++ wide string functions.

            option  casemap:none
            include    aoaulib.inc
            includelib aoaulib.lib

            
            .const

; Program title (In Unicode):

            align   word
ttlStr      word    utf16("Listing 2-5"), 0

str1        word    utf16("String1\0" )
blank       word    utf16(" \0" )
str2        word    utf16("String2\0" )
str3        word    utf16("String1 String2\0")
str4        word    utf16("String2 String1\0")
str5        word    utf16("String String\0")


            .data
            align   word
dest        word    256 dup (0)


; External definitions for the wide string functions:

            externdef       wcscpy:proc
            externdef       wcscat:proc
            externdef       wcscmp:proc
            externdef       wcslen:proc
            .code

        
; Here is the main assembly language function.

            
            public  asmMain
asmMain     proc
            sub     rsp, 56

; Demonstrate string copy:
            
            lea     rcx, dest
            lea     rdx, str1
            call    wcscpy

; Demonstrate concatenation:
            
            lea     rcx, dest
            lea     rdx, blank
            call    wcscat
            
            lea     rcx, dest
            lea     rdx, str2
            call    wcscat
            
            lea     rdx, dest
            call    wprint
            word    utf16("str1+blank+str2='%s'\n\0")

; Demonstrate comparison:
            
            lea     rcx, dest
            lea     rdx, str3
            call    wcscmp
            mov     rdx, rax
            call    wprint
            word    utf16( "cmp(dest,str3)=%d\n\0" );
            
            lea     rcx, dest
            lea     rdx, str4
            call    wcscmp
            mov     rdx, rax
            call    wprint
            word    utf16( "cmp(dest,str4)=%d\n\0" );
            
            lea     rcx, dest
            lea     rdx, str5
            call    wcscmp
            mov     rdx, rax
            call    wprint
            word    utf16( "cmp(dest,str5)=%d\n\0" );

; Demonstrate length:
            
            lea     rcx, dest
            call    wcslen
            mov     rdx, rax
            call    wprint
            word    utf16( "len(dest)=%d\n\0" );
 
            add     rsp, 56
            ret     ;Returns to caller
        
asmMain     endp
            end