简体   繁体   中英

Assembly PUSH instruction with an OFFSET tag

I've written a simple 'Hello World' program in assembly:

global  _main
extern  _printf

section .text
_main:
    push  offset  message
    call  _printf
    add   esp, 4
    ret
section .data
    message db  'Hello, World2', 10, 0

I've opened the compiled.EXE in Ghidra tool (freeware IDA alternative) and when I look at the generated assembly code listing, there is something like this:

 push  message
 call  _printf
 add   esp,0x4

My question is: why is there no offset keyword there (like in the source)? Is it optional or so? Moreover when I'd like to patch the instruction, the tool doesn't allow me to type the offset keyword...

Assemblers belong to one of two believes.

Assemblers that require square brackets to read/write memory will not need the offset tag to reference the offset of the label. This is the N ASM style.
These assemblers can allow or prohibit the use of offset .

Assemblers that don't require square brackets to read/write memory will need the offset tag to reference the offset of the label. This is the M ASM style.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM