News:

Download Pelles C here: http://www.smorgasbordet.com/pellesc/

Main Menu

PARMAREA

Started by Grincheux, April 27, 2021, 09:16:02 PM

Previous topic - Next topic

Grincheux

Can someone explain me how to use this?
I have read the help file and make what it says, I get false result


;   __________________________________________________________________________________
;   _______________________ CompareFunc ______________________________________________
;   __________________________________________________________________________________

                     ALIGN   16

CompareFunc               PROC   USES RDI,__lParam_1:LPARAM,__lParam_2:LPARAM,__lParamSort:LPARAM PARMAREA=4*QWORD
                     LOCAL   _Lv1:LVITEM
                     LOCAL   _Lv2:LVITEM
                     LOCAL   _szStr_1[256]:BYTE
                     LOCAL   _szStr_2[256]:BYTE
                     LOCAL   _dwNumber_1:DWORD
                     LOCAL   _dwNumber_2:DWORD
                     LOCAL   _lParamSort:QWORD

                     mov      [_lParamSort],r8                     ; _lParamSort = 928 SHOULD BE 8

                     mov      _Lv1.iItem,ecx                        ; RCX = 2
                     mov      _Lv1.iSubItem,r8d                  ; R8 = 8
                     mov      _Lv1.cchTextMax,256
                     mov      _Lv1._mask,LVIF_TEXT

                     mov      _Lv2.iItem,edx                       ; RDX = 3
                     mov      _Lv2.iSubItem,r8d                 ; R8 = 8
                     mov      _Lv2.cchTextMax,256
                     mov      _Lv2._mask,LVIF_TEXT

                     lea      rax,_szStr_1
                     lea      rcx,_szStr_2

                     mov      _Lv1.pszText,rax
                     mov      _Lv2.pszText,rcx

                     mov      rcx,[hWndMain + rip]
                     mov      edx,IDC_LISTVIEW_01
                     call   GetDlgItem

                     mov      rdi,rax

                     mov      rcx,rax
                     mov      edx,LVM_GETITEMTEXT
                     mov      r8d,_Lv1.iItem
                     lea      r9,_Lv1
                     call   SendMessageA

                     mov      rcx,rdi
                     mov      edx,LVM_GETITEMTEXT
                     mov      r8d,_Lv2.iItem
                     lea      r9,_Lv2
                     call   SendMessageA

                     cmp      _lParamSort,8
                     jge      @Compare

                     lea      rcx,_szStr_1
                     call   Ascii2QWord
                     mov      _dwNumber_1,eax

                     mov      rcx,SIZEOF _szStr_1
                     lea      rdx,_szStr_1
                     mov      r8,OFFSET szFmt_03
                     mov      r9d,eax
                     call   sqlite3_snprintf

                     lea      rcx,_szStr_2
                     call   Ascii2QWord
                     mov      _dwNumber_2,eax

                     mov      rcx,SIZEOF _szStr_2
                     lea      rdx,_szStr_2
                     mov      r8,OFFSET szFmt_03
                     mov      r9d,eax
                     mov      rax,OFFSET @Compare
                     push   rax
                     jmp      sqlite3_snprintf

                     ALIGN   16
@Compare :
                     lea      rcx,_szStr_1
                     lea      rdx,_szStr_2
                     call   lstrcmpA

                     ret
CompareFunc               ENDP

Thanks

John Z

Might help others to help you if you also include the parameter values you are passing to the code.  Might clarify "false result" - do you mean the sort is not performed correctly?

Wish I could be more help but it has been many years since I did assembly.  Think 286/386 timeframe....


John Z

Grincheux

I have found. PARMAREA was not the problem and it runs like the doc says.
The problem was ME:Use RDI without saving, passing the wrong paramter size...
Trying to sort hex numbers in conerting them to decimal rather than hexa...
I am very tired!