NASM - The Netwide Assembler
NASM Forum => Using NASM => Topic started by: mik3ca on January 10, 2021, 04:08:44 PM
-
What I'm trying to do is reserve a large block of code memory so that I can fill it with data later as the program executes.
Currently I can reserve 1, 2, and 4 bytes of data using db 0h, dw 0h, and dd 0h respectively.
I could do something like db '<insert spaces here>' if I want to manually reserve a block of memory, but that would be a very tedious task if say for example, I want to reserve 16KB of memory because then that would mean I'd have to do db then 16,384 spaces between the quotes and I have no time to be counting that many spaces every hour.
Is there a simpler way to do this in nasm? I'm using version nasm 2.10.04 for linux.
-
to save x spaces, you can use
label: times x db 0
Of course, "label" can be whatever you want, and possible be left out (although that is generally not practical).
You can also use resb, resw, resd to reserve uninitialised space. They would normally be in section .bss, but I imagine they will be OK in your code section.
-
In Linux, the code section (section .text) is usually read-only, so this won't work well. It would work in .data, but Nasm would complain. The advantage to secrion .bss is that this empty space does not take up space on the disk file.
Best,
Frank
-
Debs answer seems to work for me. it was the "times" keyword that I needed.