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

    • Nonstop Knight 2 Cheats v3.3.0 +7 [ God Mode & More ]
      Modded/Hacked App: Nonstop Knight 2 - Action RPG By Flaregames GmbH
      Bundle ID: com.koplagames.kopla02
      iTunes Store Link: https://apps.apple.com/us/app/nonstop-knight-2-action-rpg/id1444887980?uo=4

       

      📌 Mod Requirements

      - Jailbroken iPhone or iPad.
      - iGameGod / Filza / iMazing.
      - Cydia Substrate, ElleKit, Substitute or libhooker depending on your jailbreak (from Sileo, Cydia or Zebra).

       

      🤩 Hack Features

      - God Mode
      - One Hit Kill
      - Custom Move Speed
      - Custom Attack Speed
      - Custom Attack Range
      - Instant Skill
      - Infinite MP

       

      Non-Jailbroken Hack: https://iosgods.com/topic/99785-nonstop-knight-2-v323-jailed-cheats-2/

       

      ⬇️ iOS Hack Download Link: https://iosgods.com/topic/99783-nonstop-knight-2-cheats-v324-7-god-mode-more/
        • Informative
        • Agree
        • Haha
        • Thanks
        • Winner
        • Like
      • 1,610 replies
    • MARVEL Contest of Champions v52.1.0 +11++ Amazing Cheats!
      Modded/Hacked App: MARVEL Contest of Champions By Kabam
      Bundle ID: com.kabam.marvelbattle
      iTunes Link: https://itunes.apple.com/us/app/marvel-contest-of-champions/id896112560?mt=8&uo=4&at=1010lce4


      Hack Features
      - Enemy/AI Doesn't Attack
      - Special Attack/Skill Always Available
      - No Knockbacks When Hit
      - No Knockdowns When Hit
      - Enemy Doesn't Block
      - Auto Win - Whoever Attacks first, loses. Disable AI Doesn't Attack for this to work.
      - One Hit Kill / High Damage - Linked. Attack first or use with Enemy Doesn't Attack.

      Non-Jailbroken version of this hack: https://iosgods.com/topic/44075-marvel-contest-of-champions-v1311-2-cheats-for-jailed-devices/
        • Informative
        • Agree
        • Haha
        • Thanks
        • Winner
        • Like
      • 3,522 replies
    • Ultimate Golf! v4.23.01 +1 Jailed Cheat [ Perfect Shot ]
      Modded/Hacked App: Ultimate Golf! By Miniclip.com
      Bundle ID: com.hypgames.ultimategolf
      iTunes Store Link: https://apps.apple.com/us/app/ultimate-golf/id1475163222
       

      Hack Features:
      - Perfect Shot -> Every ball hit will go straight.


      Jailbreak required hack(s): [Mod Menu Hack] Ultimate Golf! v4.4.3 +1 Cheat [ Perfect Shot ] - Free Jailbroken Cydia Cheats - iOSGods
      Modded Android APK(s): https://iosgods.com/forum/68-android-section/
      For more fun, check out the Club(s): https://iosgods.com/clubs/
        • Informative
        • Agree
        • Haha
        • Thanks
        • Winner
        • Like
      • 182 replies
    • Ultimate Golf! v4.23.01 +1 Cheat [ Perfect Shot ]
      Modded/Hacked App: Ultimate Golf! By Miniclip.com
      Bundle ID: com.hypgames.ultimategolf
      iTunes Store Link: https://apps.apple.com/us/app/ultimate-golf/id1475163222


      Hack Features:
      - Perfect Shot -> Every ball hit will go straight.


      Non-Jailbroken & No Jailbreak required hack(s): https://iosgods.com/forum/79-no-jailbreak-section/
      Modded Android APK(s): https://iosgods.com/forum/68-android-section/
      For more fun, check out the Club(s): https://iosgods.com/clubs/
        • Informative
        • Agree
        • Haha
        • Thanks
        • Winner
        • Like
      • 298 replies
    • Creatures of the Deep v2.93 +6 Jailed Cheats [ VIP + More ]
      Modded/Hacked App: Creatures of the Deep By Infinite Dreams
      Bundle ID: pl.idreams.cotd
      iTunes Store Link: https://apps.apple.com/us/app/creatures-of-the-deep/id1556204048?uo=4


      Hack Features:
      - VIP
      - Alpha User
      - Free Lottery Spin
      - 100 Inventory Size
      - Negative Upgrade Cost
      - 0 Upgrade Cost


      Jailbreak required hack(s): [Mod Menu Hack] Creatures of the Deep v2.33 +6 Cheats [ VIP + More ] - Free Jailbroken Cydia Cheats - iOSGods
      Modded Android APK(s): https://iosgods.com/forum/68-android-section/
      For more fun, check out the Club(s): https://iosgods.com/clubs/
        • Informative
        • Agree
        • Haha
        • Thanks
        • Winner
        • Like
      • 105 replies
    • Creatures of the Deep v2.93 +6 Cheats [ VIP + More ]
      Modded/Hacked App: Creatures of the Deep By Infinite Dreams
      Bundle ID: pl.idreams.cotd
      iTunes Store Link: https://apps.apple.com/us/app/creatures-of-the-deep/id1556204048?uo=4


      Hack Features:
      - VIP
      - Alpha User
      - Free Lottery Spin
      - 100 Inventory Size
      - Negative Upgrade Cost
      - 0 Upgrade Cost


      Non-Jailbroken & No Jailbreak required hack(s): [IPA Mod Menu] Creatures of the Deep v2.33 +6 Jailed Cheats [ VIP + More ] - Free Non-Jailbroken IPA Cheats - iOSGods
      Modded Android APK(s): https://iosgods.com/forum/68-android-section/
      For more fun, check out the Club(s): https://iosgods.com/clubs/
        • Informative
        • Agree
        • Haha
        • Thanks
        • Winner
        • Like
      • 40 replies
    • eFootball™ v10.0.1 +3 Cheats [ Dumb AI ]
      Modded/Hacked App: eFootball™ 2023 By KONAMI
      Bundle ID: jp.konami.pesactionmobile
      iTunes Store Link: https://apps.apple.com/us/app/efootball-2023/id1117270703


      Hack Features:
      - Dumb ai 50% 99% (use either one)
      - No pass (turn off when enemy kick)
      - No catch (dumb goalie)


      Non-Jailbroken & No Jailbreak required hack(s): https://iosgods.com/forum/79-no-jailbreak-section/
      Modded Android APK(s): https://iosgods.com/forum/68-android-section/
      For more fun, check out the Club(s): https://iosgods.com/clubs/
        • Informative
        • Agree
        • Haha
        • Thanks
        • Winner
        • Like
      • 617 replies
    • Barbie™ Merge Mystery v54 +3 Jailed Cheats [ Unlimited Currencies ]
      Modded/Hacked App: Barbie™ Merge Mystery By Rollic Games Oyun Yazilim ve Pazarlama Anonim Sirketi
      Bundle ID: com.rollic.barbiemerge
      iTunes Store Link: https://apps.apple.com/ph/app/barbie-merge-mystery/id6736395270?uo=4

       


      🤩 Hack Features

      - Unlimited Coins -> Earn or spend some.
      - Unlimited Gems -> Earn or spend some.
      - Unlimited Energy -> Earn or spend some.
        • Thanks
        • Like
      • 6 replies
    • Adorable Garden v1.2.3 +1++ Jailed Cheat [ Unlimited Currencies ]
      Modded/Hacked App: Adorable Garden By Skyborne Games Inc
      Bundle ID: com.skybornegames.adorablegarden
      iTunes Store Link: https://apps.apple.com/us/app/adorable-garden/id6503631437?uo=4

       


      🤩 Hack Features

      - Freeze Currencies
        • Informative
        • Haha
        • Thanks
        • Like
      • 4 replies
    • Adorable Garden v1.2.3 +1++ Cheat [ Unlimited Currencies ]
      Modded/Hacked App: Adorable Garden By Skyborne Games Inc
      Bundle ID: com.skybornegames.adorablegarden
      iTunes Store Link: https://apps.apple.com/us/app/adorable-garden/id6503631437?uo=4

       
       

      🤩 Hack Features

      - Freeze Currencies
        • Informative
        • Winner
      • 2 replies
    • Barbie™ Merge Mystery v54 +3 Cheats [ Unlimited Currencies ]
      Modded/Hacked App: Barbie™ Merge Mystery By Rollic Games Oyun Yazilim ve Pazarlama Anonim Sirketi
      Bundle ID: com.rollic.barbiemerge
      iTunes Store Link: https://apps.apple.com/ph/app/barbie-merge-mystery/id6736395270?uo=4

       
       

      🤩 Hack Features

      - Unlimited Coins -> Earn or spend some.
      - Unlimited Gems -> Earn or spend some.
      - Unlimited Energy -> Earn or spend some.
        • Like
      • 4 replies
    • Grimguard Tactics: Fantasy RPG v1.17.1 +3 Jailed Cheats [ Auto Win ]
      Modded/Hacked App: Grimguard Tactics: Fantasy RPG By Outerdawn Limited
      Bundle ID: com.outerdawn.grimguard
      iTunes Store Link: https://apps.apple.com/us/app/grimguard-tactics-fantasy-rpg/id1496893856?uo=4


      Hack Features:
      - Auto Win
      - Unlimited Daily Rewards
      - No Stamina Cost


      Jailbreak required hack(s): [Mod Menu Hack] Grimguard Tactics: Fantasy RPG v1.1.10 +3 Cheats [ Auto Win ] - ViP Cheats - iOSGods
      Modded Android APK(s): https://iosgods.com/forum/68-android-section/
      For more fun, check out the Club(s): https://iosgods.com/clubs/
        • Agree
        • Like
      • 131 replies
×
  • 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