NASM - The Netwide Assembler
NASM Forum => Programming with NASM => Topic started by: S Mahen on January 21, 2014, 07:29:22 AM
-
Hi, I am trying to implement a code for the statement in which I am suppose write 8086 code in two different segments(Module_A & Module_B), far procedures defined in Module_B are to be called from Module_A and values defined in section .data of Module_A are used in Module_B to perform different operations.
I tried this with MASM/TASM, Windows XP and it is working there.
Now I'm using Fedora 20 with nasm 2.10.7.
Please guide me how to go ahead?
Thanks in advance.
-
Hi!
I'm not an expert, but i would try something like this:
segment A
procedure
segment B
procedure
I think, at first, you have to select/switch/change a code segment, then call your procedure.
Select segment A -> Call procedure
Select segment B -> Call procedure
EDIT:
Here is more info: Complete 8086 instruction set - Gabriele Cecchetti (http://www.gabrielececchetti.it/Teaching/CalcolatoriElettronici/Docs/i8086_instruction_set.pdf)
See instruction CALL, ~ On page 6, there is a far call example.
-
You can use code and data in different modules - just declare symbols "global" if they're defined in this module and need to be used in another - and declare 'em "extern" if they're used in this module but defined in another. Then put both (all) .o files on the command line to ld (or gcc).
"FAR", however, is more of a real mode, segmented memory model thing, as it involves changing the segment registers to some other 64k segment. In Windows/Linux/BSD/OSX (probably others) we've got a "flat" memory model, in which each segment spans the whole 4G (or more on a 64-bit system). There would be no point to a "far" procedure.
Nasm will let you declare arbitrary section names and attributes. I'd have to experiment to see what it would do if you tried "segment .text" and "segment .text2 exec" and a far call between 'em... and you can do that... I doubt if it would work.
Best,
Frank
Edit: You might find this information on segment registers interesting:
http://mirror.freedoors.org/Geezer-1/johnfine/segments.htm
-
One example (http://abreojosensamblador.net/Productos/AOE/html/Codigos/Cap05/FarCN1.asm)
Regards
-
Maybe I'm confused about what we're trying to do. Here's what the old Nasm Manual instruction set reference says about "call":
http://home.myfairpoint.net/fbkotler/nasmdocc.html#section-A.4.18
For clarity:
I tried this with MASM/TASM, Windows XP and it is working there.
This was with real mode (16-bit) code, right? Not for Windows?
Now I'm using Fedora 20 with nasm 2.10.7.
And now you want to do it in Linux? Or is this for DosBox?
Best,
Frank