Giter Club home page Giter Club logo

Comments (4)

Menshin avatar Menshin commented on June 27, 2024 1

Hey @xmpf,

you've correctly located the instruction that gives that output :

image

While the 8-bits registry CL is (always) used for SAR second variable operand, reading the Intel x64 specs for SAR gives :

image
(Intel Software Developer’s Manual, Volume 2B, page 4-584)

and the corresponding bits for AMD64 :
image
(AMD64 Architecture Programmer's Manual volume 3, page 318)

So when the compiler is translating the >> operator to a SAR instruction, it's implicit that the right operand will be used modulo 64 (or modulo 32 if using a 32-bits wide register).
Ghidra, being a friendly program, slaps an artificial & 0x3F in its decompilation to reminds the reverser that fact.

from hackaday-u.

Menshin avatar Menshin commented on June 27, 2024 1

You're welcome.
If you're refering to :

image

then this logical AND applies to the whole expression, not only index*8 and truncate the number to fit inside an unsigned char.

This is visible in the decompiled code as a (char) cast :

image

or in the disassembly when the 8-bits register AL is used to store the result :

image

from hackaday-u.

xmpf avatar xmpf commented on June 27, 2024 1

Thanks :)

from hackaday-u.

xmpf avatar xmpf commented on June 27, 2024

Hi, thank you for your answer.
In the original source code however, the modulo is 0xff.

from hackaday-u.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.