0

I'm writing code but it gives errors on visual studio.

On emu it's working but on visual studio it's not working.

I saw different tutorials of displaying hello world program but not one is working on my visual studio masm..

What's the proper way to execute this code?

. MODEL SMALL
. STACK 100H
.DATA 
MSG DB "HELLO! $"
.CODE
MAIN PROC
MOV AX, @DATA
MOV DS, AX
LEA DX, MSG
MOV AH, 9
INT 21H
MOV AH,4CH
INT 21H
MAIN ENDP
END MAIN

tell me. What is the right procedure to execute it

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847

1 Answers1

3

The code you show is 16 bit code for MSDOS. 64 bit versions of Windows can't run 16 bit code, except via an emulator or virtual pc. I'm not aware of a version of Visual Studio that can produce 16 bit code. You can try to find a downloadable version of a 16 bit tool set to assemble the code, such as Masm 6.11 (do a web search).

If interested in 16 bit C or C++, Microsoft Visual C/C++ 4.1 usually includes the 16 bit toolset, but not Masm, so you'll still need Masm 6.11 and you can combine the files into common directories. The Microsoft 16 bit toolsets can run on 32 bit versions of windows, or on an MSDOS emulator or a virtual pc running MSDOS (with emm386 setup, as a dos extender is used by the toolset). If using virtual pc, I recommend using a USB stick for transferring files to or from the virtual pc.

A complete Microsoft 16 bit toolset includes MASM (ml.exe), C/C++ compiler, Linker, CodeView (cv.exe - source level debugger), QuickHelp (qh.exe) - help utility), Programmer's Workbench (pwb.exe - IDE), H2INC (converts a C .h include file into a MASM .inc include file, NMAKE (make utility), DOSXNT (dos extender used by the toolset itself), ... . I'm not sure where you could find a complete toolset.

rcgldr
  • 27,407
  • 3
  • 36
  • 61
  • 1
    The assembler included in current versions of Visual Studio can assemble 16-bit code and produce OMF files. It doesn't include a linker capable of producing 16-bit executables though. There are Win32 versions of the Microsoft 16-bit toolchain (compiler, linker) that work on 64-bit versions of Windows, but they're even harder to find. The Windows 2003 DDK being where I got my copy from. – Ross Ridge Mar 30 '19 at 23:34