NO

Author Topic: Title case convertion  (Read 1880 times)

Offline Vortex

  • Member
  • *
  • Posts: 902
    • http://www.vortex.masmcode.com
Title case convertion
« on: December 14, 2023, 08:16:10 PM »
Hello,

Here is a title case convertion example :

Code: [Select]
include TitleCase.inc

.data

LookupTable1    db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
                db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1
                db 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1
                db 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0
                db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
                db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
                db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
                db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0


LookupTable2    db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
                db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
                db 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0
                db 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0
                db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
                db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
                db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
                db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0


sample db 'WHAT/A[CRAZY]{NIGHT}(OF)<PROGRAMMING>?IT~WAS!',0
     
.code

TitleCase PROC uses esi edi ebx string:DWORD

    mov     ecx,1
    mov     esi,OFFSET LookupTable1
    mov     edx,OFFSET LookupTable2
    mov     ebx,ecx
    mov     edi,string
    sub     edi,ebx

@@:
    add     edi,ecx
    movzx   eax,BYTE PTR [edi]
    test    eax,eax
    jz      finish
   
    cmp     BYTE PTR [esi+eax],cl
    jne     CheckTable2
    mov     ebx,1
    jmp     @b

CheckTable2:

    cmp     BYTE PTR [edx+eax],cl
    jne     @b

    or      eax,32
    mov     BYTE PTR [edi],al

    cmp     ebx,ecx
    jne     @b

    sub     eax,32
    mov     BYTE PTR [edi],al
    xor     ebx,ebx

    jmp     @b   
   
finish:

    ret

TitleCase ENDP   

start:

    invoke  TitleCase,ADDR sample
    invoke  printf,ADDR sample

    invoke  ExitProcess,0

END start
Code it... That's all...

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2152
Re: Title case convertion
« Reply #1 on: December 14, 2023, 08:57:57 PM »
Nice variation of Proper function  ;)
May the source be with you

Offline Vortex

  • Member
  • *
  • Posts: 902
    • http://www.vortex.masmcode.com
Re: Title case convertion
« Reply #2 on: December 17, 2023, 06:20:10 PM »
Hi Timo,

Thanks. Attached is the quick convertion to 64-bit.
Code it... That's all...