Author Topic: How to create .map files??  (Read 27172 times)

Offline Danish

  • Jr. Member
  • *
  • Posts: 3
How to create .map files??
« on: June 23, 2010, 06:53:36 AM »
Hi all;
I am new to this forum,I am trying to create .map file using the syntax '[map all myfiles.com] ' but couldn't create it yet.I am using the following command line for creating it,
 "nasm -f bin myfile.asm -o [map symbols myfile.map]" but the assembler is giving the following errors:
"nasm: error:more than one input file specified"
"nasm: error:more than one input file specified"
How do I create this?? :( Please help me out in this regard..............

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: How to create .map files??
« Reply #1 on: June 23, 2010, 08:34:51 AM »
Whew! An easy one! :)

Creating map files is ordinarily the job of the linker. In the case of "-f bin", Nasm acts as its own linker, so can make a map file. Since map files only apply to "-f bin", instead of a command line option (normally to the command line of the linker) Nasm puts the "map" command in the source code. This is confusing to people who are used to asking for a map file on the command line! Sorry, that's the way it is...

So, put your "[map all myfile.map]" (you probably don't want your map file named "myfile.com", as this will probably conflict with the name of the executable) in your source code. "First" is probably a good place, but anyplace will work (I think - I've always put it first). Then assemble as "nasm myfile.asm -o myfile.com", and Nasm should create your map file, as well as the executable.

If you have trouble, get back to us. ("Welcome!", BTW)

Best,
Frank


Offline Danish

  • Jr. Member
  • *
  • Posts: 3
Re: How to create .map files??
« Reply #2 on: June 23, 2010, 10:16:12 AM »
Thanks for your help,it created the required .map file :) but now the problem is that I am using AFD for debugging, here is my .asm code which I assembled in NASM:
"[org 0x0100]
[map symbols danish.map]
mov ax,[num1]
mov bx,[num2]
add ax,bx
mov bx,[num3]
add ax,bx
mov [num4],ax

mov ax,0x4c00
int 0x21

num1:   dw 5
num2:   dw 10
num3:   dw 15   
num4:   dw 0 "
Now when after loading it into debugger,it is not giving the required results as expected, and it is not identifying the map file as well,Now what can I do?? Please help me out.......

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: How to create .map files??
« Reply #3 on: June 23, 2010, 04:41:50 PM »
No idea what "AFD" is. Google seems to think it's a tool for debugging php scripts. Oh wait! "Advanced Fullscreen Debug" from AdTec GmBH... 1990? That AFD? I would guess that it's looking for a .map file as created by a linker - probably the oldest MS linker you can find... or maybe Tlink (Borland was alive in 1990, I think). I thought *I* was using obsolete tools! :)

If you can get this... "senior citizen"... to work with *any* map file you've got, post it. Perhaps we can devise a utility to convert Nasm's map file into whatever it's looking for.

My mistake - wasn't an "easy one" after all... I shoulda known...

Your code looks fine, so I don't know why it isn't producing the "required results"...

Best,
Frank


Offline Danish

  • Jr. Member
  • *
  • Posts: 3
Re: How to create .map files??
« Reply #4 on: June 24, 2010, 09:22:31 AM »
Yes, the same "Advanced Full Screen Debugger" it was working fine when I was loaded the code using the "immediate operand" as below...
"[org 0x0100]
 mov ax, 5
 mov bx, 10
 add ax, bx
 mov bx, 15
 add ax, bx

 mov ax, 0x4c00
 int 0x21"
But when I used the code using the "Direct Addressing" as below...
"[org 0x0100]
[map symbols danish.map]
mov ax,[num1]
mov bx,[num2]
add ax,bx
mov bx,[num3]
add ax,bx
mov [num4],ax

mov ax,0x4c00
int 0x21

num1:   dw 5
num2:   dw 10
num3:   dw 15   
num4:   dw 0"

but it is not producing the required result :(......
When I reffered to the HELP in AFD it seemed to ask for some ".MAP" file for the symbols used,but when I created the ".MAP" file as below,the debugger respond as an invalid .MAP file.......

"- NASM Map file ---------------------------------------------------------------

Source file:  danish.asm
Output file:  danish.com

-- Symbols --------------------------------------------------------------------

---- Section .text ------------------------------------------------------------

Real              Virtual           Name
             117               117  num1
             119               119  num2
             11B               11B  num3
             11D               11D  num4"
Now,what I can do?????? Plz help.........

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: How to create .map files??
« Reply #5 on: June 24, 2010, 08:12:45 PM »
Forget about AFD? :)

Seriously, you *could* find yourself a debugger written this century. AFD is pretty old. Well... I'm pretty old, too, but I ain't dead yet! If you want to use AFD, you should be able to.

We know that AFD doesn't like Nasm's .map files. That isn't too much of a surprise, they weren't intended to be "standard" (AFAIK). We don't know (*I* don't) what AFD *does* like.

In my old /dos directory, I've got a few .map files. Mostly Nasm's .map files, which we know aren't suitable. The remainder, made with "who knows" what linker, mostly just list "segments". Some have error messages about "undefined symbol" in 'em. Some are from Windows files, and speak of "IMPORTS", which I don't think will help us. The few that might help seem to be of the form:

Code: [Select]
SEGMENT code PUBLIC USE16 BYTE ''
  at 00000000, length 0000000A

publics:
_K_main at code:00000000

(made by Alink, which isn't that old) As a flying wild-asmed experiment, you might try creating, by hand, a "danish.map" file like:

Code: [Select]
SEGMENT .text PUBLIC USE16 BYTE ''
  at 00000000, length 0000001F

publics:
num1 at .text:00000117
num2 at .text:00000119
num3 at .text:0000011B
num1 at .text:0000011D

Feed that to AFD and see what it says. Probably won't work, but if it does, we can think about writing a utility to convert Nasm's idea of a .map file into "something like that". Won't be pretty, but we can probably do something that works. Could modify the Nasm code, too, but I'd rather not go that route! (to please a twenty-year-old debugger? naw...)

Disassembling ("reverse engineering") AFD to see what it's looking for is a possibility, too. That would be tedious, and probably illegal. I don't care about "legal"* - they'll never take me alive! - but "tedious" doesn't appeal to me. "Trial and error" is probably easier...

When I was running dos, I liked David Lindauer's GRDB - like DEBUG, only with a brain. That will accept a ".sym" file. The feature was added after I stopped using dos, so I don't know what the format of the ".sym" file is, either, but we have source code for that, so a "converter" would probably be easier - and probably more useful, too. If you're forced to give up on AFD, we can look into that...

But if you're stubborn enough, we can probably get this to work. Whether it's "worthwhile" or not is another question. If I have occasion to reboot to dos, I'll have a look at it, but meanwhile, see what you can figure out on your own. Doing it as an .exe file rather than a .com file might be the simplest thing...

Best,
Frank

* Don't post anything illegal *here* though!