NASM - The Netwide Assembler
NASM Forum => Programming with NASM => Topic started by: william427 on July 27, 2014, 07:33:41 PM
-
hi im using 32 bit when I include my inc.asm file ,as long as I have only section .text or code it works
but what if I need to send that and a string, like section .data too?
is there any other way, because have to send stuff threw inc.asm file I guess.
thanks
billy
-
Could you post your code so we can see how you implemented it???
Usually the way I include files is like this
section .data
section .bss
section .text
%include "include.asm"
global _start:
_start:
-
Hi billy,
It isn't clear exactly what the problem is. "%include" is essentially a "cut and paste" operation, and it's pasted in where the "%include" occurs. For example, in the code Anonymous offers...
section .data
section .bss
section .text
; %include "include.asm"
; suppose our hypothetical include file,
; pasted in here, said:
section .data
foo db "this is my string", 10, 0
; and that's all
; whoops! we're no longer in "section .text"!
global _start:
_start:
; ...
There's a "__SECT__" macro known to Nasm that can be used to work around this. RTFM. In my opinion, this isn't worth bothering about. Just put your "section" directives where you need 'em - outside the "%include" - and you won't need to worry about "section" changes inside the "%include".
If that isn't your actual problem, show us some example code that illustrates it.
Best,
Frank
-
hi yall
everything will work ,but the data section.
what do I look under to find more about this "__SECT__" ?
i equ 0
x equ 100
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
mov eax, i
L1:
add eax, 1
mov ebx, eax
cmp ebx, x ;; Compares whether the counter has reached x
JL L1 ; If it is less than x, then jump to L1
sendmsg db "the answer = ", 0
-
I looked up _SECT_ will that work from a %include file?
thanks
-
Assuming this is the include file this is what it should look like at least this is how I would do it
section .data
i equ 0
x equ 100
sendmsg db "the answer = ", 0
section .text
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ExFunc:
mov eax, i
L1:
add eax, 1
mov ebx, eax
cmp ebx, x ;; Compares whether the counter has reached x
JL L1 ; If it is less than x, then jump to L1
ret
Then when you include this in your main file implement it like so:
section .data
section .bss
section .text
%include "Exfunc.asm"
global _start:
_start:
;some code goes here
-
http://www.nasm.us/xdoc/2.11.05/html/nasmdoc6.html#section-6.3.1
Not at all clear how this is going to help you. Sure it'll work in an "%include" file. An "%include" file is essentially a "cut and paste" operation. It'll work exactly as if everything was in one file.
Perhaps what you want to do is...
i equ 0
x equ 100
; this appears to be "section .text" although you don't say
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
mov eax, i
L1:
add eax, 1
mov ebx, eax
cmp ebx, x ;; Compares whether the counter has reached x
JL L1 ; If it is less than x, then jump to L1
[section .data] ; note square brackets!
sendmsg db "the answer = ", 0
__SECT__ ; changes back to whatever the previous section was
Best,
Frank
-
thanks yall
anonymous that worked
thanks
-
thanks frank thatll give me two ways to solve it
im not getting errors now and its working
thanks