NASM - The Netwide Assembler
NASM Forum => Programming with NASM => Topic started by: MIchael on May 27, 2018, 08:32:01 AM
-
Is it possible to change the names of instructions or directives with the help of directives or other means of the NASM compiler? For example:
%iredefine mov NASM@move
%iredefine %iredefine PRE@redefine
PRE@redefine push NASM@push
PRE@redefine syscall NASM@syscall
section .text
global _start
_start:
NASM@move rax, 0x4142434445464748
NASM@push rax
NASM@move rdx, 0x8
NASM@move rsi, rsp
NASM@move rax, 0x1
NASM@move rdi, 0x1
NASM@syscall
-
bits 64
%define NASM@move mov
%define NASM@push push
%define NASM@syscall syscall
section .text
global _start
_start:
NASM@move rax, 0x4142434445464748
NASM@push rax
NASM@move rdx, 0x8
NASM@move rsi, rsp
NASM@move rax, 0x1
NASM@move rdi, 0x1
NASM@syscall
All these people that you mention
Yes, I know them, they're quite lame
I had to rearrange their faces
And give them all another name
- Bob Dylan
Why you would want to do such an insane thing is none of my business.
Best,
Frank
-
Nice try! But according to my logic I have to get a compilation error "Label or instruction expected" if I write this after last line of my code:
mov ax, 0
Because MOV instruction will no longer exist.
-
Heey! Can anybody answer my question?
Please...
-
Ummm, no?
Seriously, and without meaning any insult, I question if you don't want "mov" to exist, whether Nasm is what you're looking for.
If you got into the sourcecode - x86/insns.dat - and made changes there - you might be able to create a tool that does what you want... instead of what Nasm does...
Best,
Frank
-
As I understand, it is impossible. I would not want to change the core of NASM to implement my plan. I want the code that I write could be compiled using the official release without any problems. So, so far, I refuse my idea
-
Ummm, no?
Seriously, and without meaning any insult, I question if you don't want "mov" to exist, whether Nasm is what you're looking for.
A year ago I wanted something similar. I don't know about the OP's reasons (and this is an old thread) but when you machine-generate ASM code from another language, then it happens that some identifiers used in the original language can clash with reserved words in Nasm.
Sometimes you can 'decorate' such names to avoid a clash, but sometimes also the names have to be just as they are in order to link with those names exported from elsewhere. (One I had problems with as 'abs' IIRC.)
If you got into the sourcecode - x86/insns.dat - and made changes there - you might be able to create a tool that does what you want... instead of what Nasm does...
That won't help unless you rename all opcodes and register names to have unlikely prefixes or suffixes, otherwise there is still a risk of a clash. And then the same assembler build won't work for conventional code.
Some assemblers are aware of such problems and will provide workarounds (I'm using such an alternative now). But I'm just pointing out the OP's requirement isn't that crazy.