Jump to content

Difference Between ADDRESS and OFFSET


3 posts in this topic

Recommended Posts

Updated (edited)

Difference Between ADDRESS and OFFSET

 

In the initial days when I started writing assembly programs on my own I used to get confused as to when to use ADDRESS and when to use OFFSET in the program. This article is an attempt to clear the doubts of assembly programmers regarding the meaning and usage of ADDRESS and OFFSET.

First and foremost, the purpose of using either ADDRESS or OFFSET is to get the memory address of variables during program execution.

Now, we know that variables in any assembly program are of two types, i.e. local and global variables.

While global variables remain in the memory throughout the execution of the program, local variables exist only during the execution of the functions in which they are declared and will be removed from the stack memory once the function in which they are declared completes is execution.

Since the global variables  exist in memory throughout the lifetime of a program's execution, their memory address is allocated during assembly time by the assembler. The assembler knows the exact location of the global variable's memory address during assembly time.

In case of local variables, the assembler has no idea about the address of the variable as it's address is allocated during runtime in the stack as and when the function in which it is declared is executed.

now coming back to our assembler instructions, OFFSET will get the address of a variable which already has it's address allocated. This in turn means, OFFSET could be used to get the address of global variables only. We cannot receive the address of a local variable by using OFFSET as the address of a local variable is not decided during assembly time.

To overcome this difficulty we have ADDRESS instruction. This instruction should be used if we want to retrieve the address of a local variable. 

Now naturally a question arises as to how does ADDRESS know the address of a local variable while OFFSET cannot. Well, even ADDRESS will not know the actual address of a local variable as it is referred during assembly time. What ADDRESS actually does is a simple substitution in the code as follows, just before the function is executed.

lea eax, localvar 
push eax

What really this means is that ADDRESS causes the address of the local variable which is generated during runtime to be returned. lea is used to refer to the stack memory. LEA means Load Effective Address! It is used to load variables from the stack.

If you still did not get it, then imagine a situation as follows.

I am standing somewhere on the street there and you come to meet me there in search of the address of a beautiful girl which you feel I know. So, now your asking me of the address could be considered as the assembly time of the program, you are the assembly program in search of the (girl's) address and I am the assembler.

Now if I know her exact address I'll give it to you: with perfect street address, door number, etc. This is what OFFSET does.

Now if I don't know where she lives, but I know somebody who I know knows the address of that girl, then I'll give you the address of that somebody and ask you to checkout there for the address of the girl you are searching for. That's what ADDRESS does. So it's clear that even ADDRESS doesn't have the exact address of the variable.

Now that we clearly know when to use ADDRESS and OFFSET, another question arises. Can we use ADDRESS to load global variables????

Yes, of course! If you are referring to global variables using ADDRESS, then ADDRESS simply substitutes is as following.

mov eax, 3000h

where 3000h is the actual address of the global variable. Remember, the actual address of a global variable is known during assemble and link time.

But then, why does ADDRESS use LEA instead of MOV in case of local variables. Well, for the simple reason that 

mov eax,ebp+2

is an invalid CPU instruction. Note that EBP also known as base address is the register used to access stack, and it is in stack where the local variables are stored.

Hence, LEA is used by ADDRESS in case of local variables.

So it is clear that OFFSET is to be used to global variables and ADDRESS for local variables. ADDRESS could ALSO be used while referring to global variables, BUT OFFSET cannot be used while referring to local variables.

 

Credits to author: http://www.hitxp.com/comp/pro/asm/120403.htm

Updated by Goran

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Our picks

    • Super Heavy Iron Tank v1.0.10 [ +7 Jailed ] Auto Win
      Modded/Hacked App: Super Heavy Iron Tank By Game Duo Co.,Ltd.
      Bundle ID: net.gameduo.vg
      App Store Link: https://apps.apple.com/ph/app/super-heavy-iron-tank/id6757405833?uo=4

      🤩 Hack Features

      - ADS NO / Rewards Free
      - DMG
      - ATK Speed
      ::::: ViP :::::
      - Auto Win
      - Energy Unlimited
      - Auto Skip Wave
      - Quick Supply
        • Thanks
        • Winner
        • Like
      • 5 replies
    • Super Heavy Iron Tank v1.0.10 [ +7 Cheats ] Auto Win
      Modded/Hacked App: Super Heavy Iron Tank By Game Duo Co.,Ltd.
      Bundle ID: net.gameduo.vg
      App Store Link: https://apps.apple.com/ph/app/super-heavy-iron-tank/id6757405833?uo=4

      🤩 Hack Features

      - ADS NO / Rewards Free
      - DMG
      - ATK Speed
      ::::: ViP :::::
      - Energy Unlimited
      - Auto Skip Wave
      - Auto Win
      - Quick Supply
        • Winner
        • Like
      • 4 replies
    • Super Heavy Iron Tank +3 Jailed Cheats [ Damage + More ]
      Modded/Hacked App: Super Heavy Iron Tank By Game Duo Co.,Ltd.
      Bundle ID: net.gameduo.vg
      App Store Link: https://apps.apple.com/ph/app/super-heavy-iron-tank/id6757405833?uo=4

       


      🤩 Hack Features

      - Damage Multiplier
      - God Mode -> You will take damage but you won't die.
      - XP Multiplier
      • 0 replies
    • Match Squad v1.91 [ +3 Cheats ] Currency Max
      Modded/Hacked App: Match Squad By CYPHER GAMES YAZILIM PAZARLAMA ANONIM SIRKETI
      Bundle ID: com.cyphergames.cityclash
      App Store Link: https://apps.apple.com/us/app/match-squad/id6473704944?uo=4

      🤩 Hack Features

      - Unlimited Coins
      - Unlimited Dice
      - Unlimited Cash
      • 1 reply
    • Match Squad v1.91 [ +3 Jailed ] Currency Max
      Modded/Hacked App: Match Squad By CYPHER GAMES YAZILIM PAZARLAMA ANONIM SIRKETI
      Bundle ID: com.cyphergames.cityclash
      App Store Link: https://apps.apple.com/us/app/match-squad/id6473704944?uo=4

      🤩 Hack Features

      - Unlimited Coins
      - Unlimited Dice
      - Unlimited Cash
      • 0 replies
    • Dungeons and Bags v1.1.0 [ +4 Cheats ] Currency Max
      Modded/Hacked App: Dungeons and Bags By Roshka S.A.
      Bundle ID: play.roshka.minibackpack
      App Store Link: https://apps.apple.com/us/app/dungeons-and-bags/id6752716609?uo=4

      🤩 Hack Features

      - Unlimited Gems
      - Unlimited Battle Stars
      - HP MAX
      - ATK MAX
      • 1 reply
    • Dungeons and Bags v1.1.0 [ +4 Jailed ] Currency Max
      Modded/Hacked App: Dungeons and Bags By Roshka S.A.
      Bundle ID: play.roshka.minibackpack
      App Store Link: https://apps.apple.com/us/app/dungeons-and-bags/id6752716609?uo=4

      🤩 Hack Features

      - Unlimited Gems
      - Unlimited Battle Stars
      - HP MAX
      - ATK MAX
      • 0 replies
    • Domino Stories v1.0.04 [ +8 APK MOD ] Currency Max
      Mod APK Game Name: Domino Stories
      Rooted Device: Not Required.
      Google Play Store Link: https://play.google.com/store/apps/details?id=com.domino.stories.casual.game&hl=en

       

      🤩 Hack Features

      - Unlimited Coins
      - Unlimited Stars
      - Unlimited Ticket
      - Unlimited Undo
      - Unlimited Gold Bar
      - Unlimited Free Tiles
      - Unlimited Event Currency
      - Unlimited Tokens / Event & Quest

      ⬇️ Android Mod APK Download Link


      Hidden Content

      iOSGods App for Android







       

      📖 Android Installation Instructions

      STEP 1: Download the modded APK file from the link above using your preferred Android browser or download manager.
      STEP 2: Once the download is complete, open your file manager and locate the downloaded .apk file (usually in the Downloads folder).
      STEP 3: Tap the APK file, then select Install. If prompted, enable Install from Unknown Sources in your device settings.
      STEP 3A: If the mod includes an OBB file, extract it if it’s inside an archive. Then move the folder to: /Android/obb/
      STEP 3B: If the mod includes a DATA file, extract it if it’s archived. Then move the folder to: /Android/data/
      STEP 4: Once installed, open the game and toggle your desired cheats & features through the APK mod menu. Enjoy!

       

      NOTE: If you have any questions or issues, read our Frequently Asked Questions topic. If you still need help, post your issue below and we’ll assist you as soon as possible. If the mod works for you, please share your feedback to help other members!

       

      🙌 Credits

      - IK_IK

       

      📷 Cheat Video/Screenshots

      N/A

       

       iOS & iPadOS App Hacks
      If you’re looking for Non-Jailbroken & No Jailbreak required iOS IPA hacks, visit the iOS Game Cheats & Hacks or the iOSGods App for a variety of modded games and apps for non-jailbroken iOS devices.
      • 0 replies
    • Dead Watcher +3 Mods [ Damage & Defence ]
      Mod APK Game Name: Dead Watcher By Entiz Game Studio
      Rooted Device: Not Required.
      Google Play Store Link: https://play.google.com/store/apps/details?id=com.entizgames.deadwatch

       

      🤩 Hack Features

      - Damage Multiplier
      - Defence Multiplier
      - God Mode
        • Winner
      • 1 reply
    • Domino Stories v1.0.04 [ +8 Jailed ] Currency Max
      Modded/Hacked App: Domino Stories By PERLTEC LTD
      Bundle ID: com.domino.stories.casual.game
      App Store Link: https://apps.apple.com/ph/app/domino-stories/id6754849199?uo=4

      🤩 Hack Features

      - Unlimited Coins
      - Unlimited Stars
      - Unlimited Ticket
      - Unlimited Undo
      - Unlimited Gold Bar
      - Unlimited Free Tiles
      - Unlimited Event Currency
      - Unlimited Tokens / Event & Quest
      • 0 replies
    • Domino Stories v1.0.04 [ +8 Cheats ] Currency Max
      Modded/Hacked App: Domino Stories By PERLTEC LTD
      Bundle ID: com.domino.stories.casual.game
      App Store Link: https://apps.apple.com/ph/app/domino-stories/id6754849199?uo=4

      🤩 Hack Features

      - Unlimited Coins
      - Unlimited Stars
      - Unlimited Ticket
      - Unlimited Undo
      - Unlimited Gold Bar
      - Unlimited Free Tiles
      - Unlimited Event Currency
      - Unlimited Tokens / Event & Quest
      • 1 reply
    • Food Gang v2.0.4 +6 OFFSET
      Modded/Hacked App: Food Gang By Bloop
      Bundle ID: com.bloop.food
      App Store Link: https://apps.apple.com/us/app/food-gang/id1497116240?uo=4


      Hack Feature

      - AI ATK NO
      - VIP Active
      - ADS NO / Rewards Free
      - Unlimited Gems
      - Unlimited Coins
      - Unlimited Tokens Upgrade
      - HP / Just Upgrade Hero
      - ATK / Just Upgrade Hero
        • Agree
      • 1 reply
×
  • Create New...

Important Information

We would like to place cookies on your device to help make this website better. The website cannot give you the best user experience without cookies. You can accept or decline our cookies. You may also adjust your cookie settings. Privacy Policy - Guidelines