flat assembler
Message board for the users of flat assembler.

 Index > Main > i dont understand this..(the \$ symbol)
Author
Moodyk9

Joined: 01 May 2014
Posts: 1
Moodyk9 01 May 2014, 19:04
Quote:

There are also some special symbols that can be used inside the numerical expression. First is \$, which is always equal to the value of current offset,

i dont understand this, i tried too look at it in ollydb but when i try to pin point it using message box it give me address of something dont exist can somebody explain please?
01 May 2014, 19:04

Joined: 25 Nov 2013
Posts: 215
Location: %x
\$=current offset

jmp \$
is the same as (loop forever)
x: jmp x
01 May 2014, 19:46
revolution
When all else fails, read the source

Joined: 24 Aug 2004
Posts: 20143
revolution 02 May 2014, 02:25
You can think of \$ as always equalling {E|R}IP.
02 May 2014, 02:25
Bargest

Joined: 09 Feb 2012
Posts: 79
Location: Russia
Bargest 02 May 2014, 14:58
revolution wrote:
You can think of \$ as always equalling {E|R}IP.

Not EIP, but EIP minus size of current command. Because
Code:
`jmp \$    `

is equal to
Code:
`label: jmp label    `

But at this point EIP is equal to address of the next command. And this code will compile as 0xEB 0xFE, which means "jump -2".

_________________
jmp \$ ; Happy end!
02 May 2014, 14:58
revolution
When all else fails, read the source

Joined: 24 Aug 2004
Posts: 20143
revolution 02 May 2014, 15:35
Sure. But that is merely an implementation issue of the x86. Other CPUs can do different things. At the assembly level \$ is the same as IP in the logical sense of being the address of the current instruction.
02 May 2014, 15:35
shutdownall

Joined: 02 Apr 2010
Posts: 517
Location: Munich
shutdownall 03 May 2014, 17:00
revolution wrote:
You can think of \$ as always equalling {E|R}IP.

Well - depends on type of segment.
If you create a data segment (no execute) it wouldn't be suitable to compare it with the actual position of IP. Or when using segmented addresses in real mode.
03 May 2014, 17:00

Joined: 25 Nov 2013
Posts: 215
Location: %x
\$=current offset
\$\$=offset from the begin of you code

Code:
```org 0x7c00
boot: jmp boot ; loop
times 512-(\$-\$\$) db 0 ; times 512-((0x7c00+2)-0x7c00)
```
04 May 2014, 08:24
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

 Jump to: Select a forum Official----------------AssemblyPeripheria General----------------MainTutorials and ExamplesDOSWindowsLinuxUnixMenuetOS Specific----------------MacroinstructionsOS ConstructionIDE DevelopmentProjects and IdeasNon-x86 architecturesHigh Level LanguagesProgramming Language DesignCompiler Internals Other----------------FeedbackHeapTest Area

Forum Rules:
 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot vote in polls in this forumYou cannot attach files in this forumYou can download files in this forum