•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Assembly section within the Software Development category of DaniWeb, a massive community of 429,998 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,522 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Assembly advertiser: Programming Forums
Views: 525 | Replies: 3
![]() |
•
•
Join Date: Jun 2008
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
Hello,
I'm working on a C++ application that executes binary files, so I'm using NASM to create them.
Example:
Since I will execute that code later, I don't know the start address (ORG) at this time.
Is there any program that allows me to change the start address by patching the whole file afterwards?
Thanks in advance,
Phoenix10010
I'm working on a C++ application that executes binary files, so I'm using NASM to create them.
Example:
org 0 ; I don't know this value yet start: jmp start
Since I will execute that code later, I don't know the start address (ORG) at this time.
Is there any program that allows me to change the start address by patching the whole file afterwards?
Thanks in advance,
Phoenix10010
•
•
Join Date: Aug 2005
Location: Cologne, Germany
Posts: 114
Reputation:
Rep Power: 4
Solved Threads: 9
ORG just leaves empty space before the assembled hex. So if you just code your stuff in NASM and then later want to place your C-code before, your can use the DOS-Funktion copy (cp in UNIX?). This function merges two files (your c-bin and your asm-bin). You don't have to bother about the length of one of the files.
•
•
Join Date: Jun 2008
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
Hello,
thanks for your answer.
I'm loading the binary file into dynamically allocated memory at run time and execute it, but when I want to use variables (e.g. db str "Text", 0), the program doesn't know where they are stored (org 0).
Since I'm using dynamic memory, the addresses may change any time. Jump instructions work fine, though.
Phoenix10010
thanks for your answer.
I'm loading the binary file into dynamically allocated memory at run time and execute it, but when I want to use variables (e.g. db str "Text", 0), the program doesn't know where they are stored (org 0).
Since I'm using dynamic memory, the addresses may change any time. Jump instructions work fine, though.
Phoenix10010
•
•
Join Date: Aug 2005
Location: Cologne, Germany
Posts: 114
Reputation:
Rep Power: 4
Solved Threads: 9
okay.
you have to export the offsets of each var. You can do it with a macro (does NASM hav a direct way to do so?) that does basically:
-> get called at the top of the file with the pointer to the var parsed
-> just saves 4Bytes for the Pointer
You can then write a function in C that reads the vector-table and accesses the data.
you have to export the offsets of each var. You can do it with a macro (does NASM hav a direct way to do so?) that does basically:
-> get called at the top of the file with the pointer to the var parsed
-> just saves 4Bytes for the Pointer
You can then write a function in C that reads the vector-table and accesses the data.
![]() |
•
•
•
•
•
•
•
•
DaniWeb Assembly Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Previous Thread: Boot Loader using Assembly Language
- Next Thread: maze solving and bicycle speed


Linear Mode