Hi. I have just started using nasmw and I need to know the syntax to specify the segments within the assembler. Many thanks. ASCII silly question, get a silly ANSI
I have read and tried the syntax mentioned in the documentation and it doesn't work. Could it be something to do with the fact that I am using nasmw instead of nasm? ASCII silly question, get a silly ANSI
Refer to section 5.2 of the documentation why it doesn't work. Specifically, you are using the BIN output format and not using the OBJ file format. When you use the BIN format, you would get something lke
;- hello.asm - (Nasm BIN DOS com file) --- cut here
SECTION .text
org 0x100
start:
mov ah,9
mov dx,text
int 21h
mov ax,4c00h
int 21h
SECTION .data
text db 'Hello,World',13,10,36
;- hello.asm - (Nasm BIN DOS com file) --- cut here
Compile with:
nasmw -f bin hello.asm -o hello.com
Greetings,
Also read section 6.1 about the BIN file format.
Wouter Dijkslag
You receive the no stack warning because this is a COM program, not an EXE program. A COM program has no stack-information in itself, it is set up by the operating-system (after which you can change it, if you want off course, but that is not the purpos). You have to use EXE2BIN or EXE2COM or something to make the real program, or not link it to EXE but to COM file format.
Be careful when making a .COM program (as opposed to .EXE). The CS, DS, and SS segment registers all point to the same area of memory, so if you use too much stack space, it will eventually start to trample your code. The stack pointer is initially at the top of the code segment (64KB). For example: if you have 10K of code and data, the maximum stack space available is 54KB.
Tip: when posting a question like this, please tell us what you are doing. Are you using it for Visual C++? DJGPP? DOS COM file? Are you going to link it? With what?
The best way to make a COM file with Nasm is to use the 'bin' format, and put ORG 0x100 near the top of your source file. If you make the output file have a .COM extension, it will be directly usable without linking.
EXE2BIN hasn't been available with DOS or any OS Micro$oft has released for a long time. Fortunately its functionality is present in a program that Micro$oft still packages with Windows 98, debug. Here's an alternative .bat file.
rem exe2bin.bat
@echo off
del exe2bin.scr
echo N file.bin >>exe2bin.scr
echo W >>exe2bin.scr
echo Q >>exe2bin.scr
debug file.exe <exe2bin.scr
:end
'course you need to replace file.bin and file.exe with the proper filenames of the program... and probably you can just write the script file separately... "Information has a tendency to be free. Which means someone will always tell you something you don't want to know."
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.