views:

249

answers:

5

Hello, I need to create an executable from the next assembly code:

.MODEL SMALL
.DATA
TEXT DB 'Hello world!$'

.CODE
.STACK 20
.STARTUP
MOV AX, @DATA
MOV DS, AX
MOV AH, 9
MOV BL, 02H
INT 10H
MOV Dx, OFFSET TEXT
INT 21H
MOV AH, 4CH
INT 21H
END

It works with Turbo Assembler (tasm.exe), but I don't want to continue working with it, because it doesn't run in Windows 7.

Thanks.

+2  A: 

use Microsoft macro assembler (MASM)

Alon
Hey, I tried it, but I don't understand how it works with 16-bit code.
Kiewic
A: 

GNU Assembler

John Paulett
Someone had a bright idea naming it Gas instead of the normal acronyms... I shudder to think about some of the conversations that could have caused.
Matthew Scharley
Not giving -1, but recommending Gas to someone who wants to really write some assembler (especially on DOS or Windows) could be considered evil.
drhirsch
@Matthew Scharley: I thought it was called GASM
mwc
@mwc: Not according to Wikipedia atleast. I admit to not knowing beyond that.
Matthew Scharley
+1  A: 

You could try NASM or MASM, but your source will likely need minor changes to work with those.

Lucero
It needs changes anyway, the program, as is, compiles but does not work. (First call, Int 10h function 9 requires CX to be the number of times to print the char in AL in BL color, none of the three registers needed are initialized, so the result is undefined)
PA
+2  A: 

Your code as given is suitable for 16-bit DOS systems. To use a modern assembler, you will have to modify your code to work in a 32-bit environment, which may be a nontrivial process. All the code you've given so far will need to be rewritten.

I recommend NASM as it is an active, well supported project.

Greg Hewgill
Hi, thanks for your help, I'm using Windows XP and Windows 7, which one should I install, NASM win32 version or NASM dos version? Does my code need to be modified?
Kiewic
If TASM doesn't work in Windows 7 (probably because it is a 16-bit program), then the NASM DOS version probably won't work either. But it might, and in that case you can continue to write 16-bit DOS code compiled into `.COM` files with the source you posted. However, if you use the Win32 NASM version then your code will need to be completely different, as 32-bit land has different rules.
Greg Hewgill
+4  A: 

If there is an ongoing need to develop MSDOS programs, run a 16-bit environment like DOSBOX. That way tasm.exe—one of the finest assemblers of its day—can also run, along with your program, and the tools that go with tasm—Turbo Debugger, Turbo Linker, and Turbo C.

You could also install Windows XP or Windows 98 over Windows 7, as a multi-boot alongside it, or in a virtual machine hosted by Windows 7. Either way, you'd then have the ability to run MSDOS programs without hassle.

As Greg Hewgill mentioned, major rearchitecting of the program is needed for it to run in a 32-bit (or greater) environment.

wallyk
Hey, the DOSBOX seems to be working.
Kiewic
And your program will be able to run as well.
PA
I'm dumb with that of assembly language, and this got me out of trouble, thanks.
Kiewic
One can perfectly create 32-bit dos programs with NASM or several other 32-bit assemblers :-) It's even possible with (G)AS, but only for masochists.
Marco van de Voort