I'm having some trouble getting NASM to work at the moment. I have to get it installed for a subject that I'm doing at college. I have Windows 8.1 Pro 64-bit installed. I managed to get NASM installed by downloading the latest version.
Our first task is just to copy the code to a Hello World program and get it running. Here's the code below:
bits 16
org 0x100 ; Start the program at offset 100h
jmp main ; Jump to main program
message: db 'Hello World', 0ah, 0dh, '$'
main: mov dx, message ; Start address of message
mov ah, 09 ; Prepare for screen display
int 21h ; DOS interrupt 21h
int 20h ; Terminate program
So I saved that as prog1.asm and used a batch script that our lecturers gave us to compile it. The batch script is this:
nasm -f bin %1.asm -o %1.com -l %1.lst
When I type in as prog1.asm into cmd it compiles without error, although as soon as I type in prog1 to run the program I get the following error in the cmd window:
This version of C:\Users\########\AppData\Local\nasm\prog1.com is not compatible with the version of Windows you're running. Check your computer's system information and then contact the software publisher.
I don't know what to do really and no matter what I try or Google, nothing seems to give me a straight answer or a proper solution.
The program you've built is a DOS program - it won't run directly in Windows (you might be able to run it in compability mode in Windows XP/9x, but certainly not on your 64-bit edition of Windows 8.1).
You'll need to run your program in some sort of emulator that can handle DOS programs. Probably the most popular one is DOSBox.
If you choose DOSBox you can use a 3rd party front-end to configure things. Or you can just start up DOSBox, then at DOSBox's prompt type:
mount c: <the directory where prog1.com is located>
c:
prog1
I had the same issue with the same exercise.
I have Windows 7 64bit.
My solution was this:
Downloaded and Installed DosBox
Downloaded 16bit version of NASM from:
http://prdownloads.sourceforge.net/nasm/nsm09838.zip?download
(other versions of NASM gave me weird errors)
Unzipped NASM to c:\nasm16
Using notepad, created prog1.asm file (with containing code) in c:\nasm16\
Copied the "as.bat" file into c:\nasm16\
Ran DosBox, and in Dosbox ran command:
mount c c:\nasm16
Open mounted drive with command:
c:\
ran command:
as prog1
And it worked hooraa! :)
Related
Something changed recently with the Windows Command Prompt on my Windows 10 machine, and it is now printing a large amount of "^B" characters after we run an executable from the command line. The executable is a compiled Fortran program and we have run it many times in the past without this issue. But now we have this carat-B pattern that is clogging my terminal every time I make a run. (see below)
Can anyone point me in the right direction of resolving this issue? I can't find anything on the internet.
I'm trying to create helloworld C program for windows. I need target executable to be COFF file for some security-related project. Do I use cl.exe? Do I use fasm?
Edit: not necessirily compile on windows, anything goes as long as I can run binary on windows.
Edit2: anything goes as long as I can run binary on windows or load as dynamic library.
You would use nasm.
period#D5DZ5WT2 ~/src/metasploit-framework $ nasm -f coff -o obj-intel.o dlexec.asm
period#D5DZ5WT2 ~/src/metasploit-framework $ file -s obj-intel.o
obj-intel.o: Intel 80386 COFF object file, no line number info, not stripped, 1 section, symbol offset=0x16f, 26 symbols
(That was done on WSL the windows subsystem for linux, but you should be able to do the same with cygwin or a native win binary for nasm).
https://www.nasm.us/pub/nasm/releasebuilds/2.14.02/
Hello guys I am writing an operating system in Assembly 16 bit NASM windows 10 64 bit (to be specific) and compiled it to 2 binary .bin files:
kernel.bin
boot.bin
as you may guess boot.bin loads kernel.bin and makes a filesystem, thats all ok. but the problem is that I need to test it on a real machine to test how the hardware reacts instead of only virtual! so I got floppys (3.5" 1.44MB) it is more than enough but I tried to write the bootloader (boot.bin) to sector 0 of a floppy with a floppy-usb-drive (drive and floppys are working how they should!) I use the following steps for putting the OS on a floppy in cmd:
format A:
nasm -f bin kernel.asm -o KERNEL.BIN`
copy KERNEL.BIN A:\KERNEL.BIN
debug boot.bin
w 100 0 0 1
q
it boots... but not correct: it says this:
Please remove all media... press any key to reboot...`
and it reboots to windows 10
QUESTION
how can I fix this? I now use dosbox and debug.exe in dosbox (debug.exe from windows 7 x32), like: I copy the kernel and burn the loader but it actually WORKS! and loads my OS!
It's quite likely that your system is EFI or uEFI rather than traditional BIOS, especially if it's been made in the last four or five years. You can check the system configuration at boot (Go into BIOS or EFI config) and enable legacy boot mode.
It is also possible that your antivirus software is interfering with you writing to a bootsector silently. Check those logs and make sure that your command line is being run as an administrator.
I use Windbg 64 bits to debug a program (32bits, langage C), this program contains exceptions.
In my program I recolte informations about exception occured, especialy ExceptionRecord and ContextRecord and I call batch file that call cdb.exe (64bits).
The line in batch file where I call cdb.exe is:
cdb.exe -p %PID% -pd -loga %LogFile%.txt -lines -c ".echo ;.echo *** Call stack of module causing abort ***;.effmach x86;.cxr %ContextRecord%;kp; .dump /ma %LogFile%.dmp;q" > nul
Where %PID% : my process Id
So, when I use ;.load wow64exts;!sw; instead .effmach x86, the debuger run and show me exactly what I need (The line and function caused exception), but when I use .effmach x86, the batch file stop runing, or crash, or I don't know, but there is no result and the logfile not created.
My question: Why .effmach x86 crash my batch file?
Thanks
I use Windows 7 64 bits
(sorry for my english)
I have find problem
for simple reason, must add space between x86 and next semicolon ; (x86; architecture doesn' exist)
I have compiled one clipper program using haarbour compiler and the c file produced was compiled using djgpp to produce final exe. This exe runs fine in console window of Windows 98.
However, when I exit to msdos prompt or try to run in pure dos, it does not give any error. But did not go further. however num lock and cap locks responds propery. When I press ctrl+al+del it gives me message hdpmi terminated by the user. I have tried cwsdpmi instead of Hdpmi32 but the problem remains same.
There is on exe HBRUN.exe which acts as an interpreter to .hrb files produced instead of stand alone exe. When I run HBRUn in pure do,it behaved in the same fashion. But when I runit another directory where no dbf files were there, it gave me error dbf file not found ! This also works fine in console window but compiled for pure DOS.
I think there is some problem with all the exes produced using harbour and djgpp if they are big.
one simple 5-6 line program's .hrb file was run correctly in pure dos by hbrun ( Size of hbrun is about 1700 K where as my exe file size is 950 K
Can anybody shade some light ?
Sadly, you're unlikely to find any help here. I would suggest approaching the Harbour Project itself for help. They can be found on github with their list of developers (with email addresses!)
Harbour is powerful.
http://harbour.github.io/
To run in pure DOS I would recommend you to try OPENWATCOM
Here is a copy of the message from Pritpal Bedi (one of the developers):
I could compile Harbour with OpenWatcom DOS.
Machine : WIndows 7 32 Bits
STEPS:
Downloaded: http://ftp.heanet.ie/pub/openwatcom/open-watcom-c-dos-1.9.exe
Installed in C:\WATCOM. Follow all default options when installing except making changes to AUTOEXEC.bat and CONFIG.sys.
WATCOM will save these two files with .DOS as extention.
Copy C:\Watcom\autoexec.dos C:\Watcom\m.bat
Redefine PATH statement as : SET PATH=C:\WATCOM\BINW;C:\Harbour\bin\dos\watcom;%PATH%
Keep all other SETs intact.
CD to C:\Harbour
Execute C:\Watcom\m.bat
Execute DOS-MAKE [ Do Not use "install" option, it will pollute your existing environment ]
Harbour binaries will be deposited in C:\Harbour\bin\dos\watcom
NOTE [ And it is strange ] that steps 7 and 8 will have to be repeated for few times
as console window from where you are initiating it will disappear, but do not worry,
it seems to be an issue with memory.
CD to harbour\tests
Issue : hbmk2 hello -workdir= -run
It appears long command line do not go through, so we have to shorten the path and hence command line length.
Be cheerful as you will see "Hello World" printed in current console.
Pritpal Bedi