Jump to content
View in the app

A better way to browse. Learn more.

Tuts 4 You

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Help in Porting from ASM to Delphi

Featured Replies

Posted

Hello, i need help in porting this code from asm to delphi ( i have tried inlining it but it does not produce the right result)



@Test_00452510: movsx eax,byte ptr [esi+$050e858] // =======> $050e858 is pointing to an address in memory
lea edx,[eax+esi+1]
imul edx,ebx
add ecx,edx
mov eax,$07ccbfadf
imul ecx
sub edx,ecx
sar edx,9
mov eax,edx
shr eax,$01f
add eax,edx
imul eax,eax,$03e7
inc esi
add ecx,eax
cmp esi,edi
jl @Test_00452510

the above code was ripped with code ripper plugin in olly.


Inline asm will work fine - after you fix some of your bugs. :)


 


1) initial EBX value is unknown;


2) initial ECX value is unknown;


3) initial ESI and EDI values are unknown;


4) and don't forget to save/restore all important registers. I prefer to wrap inline asm in pushad/popad, just to be sure.


5) result of your ripped ASM code is in ECX, Delphi by default will ignore that. Make sure you store it in some variable.


 


EDIT: added #5.


Edited by kao

  • Author

thanks Kao for your suggestions but I have spent the better part of today trying to fix the bug ridden asm code but no success that is why I decided to port it in Delphi. well I will keep on trying and keep you updated on my progress. thanks once again.

To port that code to Delphi, you still need to answer my first 3 points about initial register values. :) If you'd give me few test inputs and expected results, I could try to make the appropriate Delphi code.


  • Author

After some good night rest and a Cup of Coffee this morning, I have finally ported the code to work properly (still used inline asm).
the problem was the variable i set the result from the asm code was not set to zero on initialization so that caused it to have junk values in memory.

Thanks Kao for your help and suggestions, i really appreciate it.

Create an account or sign in to comment

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.