Member Avatar for Rahul47

I have already done some Assembly programming using Turbo Assembler.
So recently i downloaded MASM32 but i was unable to link and execute my programs.

Is there anyone out there who can suggest a way to link and execute using a simple Hello World! Program ?

Thanx

Which errors are you getting?

MASM is just an assembler, IIRC. Are you also running a linker after assembling source into object code?

This tutorial explains the steps needed to link a simple MessageBox program.

Member Avatar for Rahul47

I just simply wanna write ALP and execute in MASM32.

I don't use MASM, but from what deceptikon said, you'll need a linker as well as MASM.

I compiled and linked, but couldn't execute.
(MASM32 editor: File/Cmd prompt)

C:\masm32>bin\ml /c test.asm
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997. All rights reserved.

Assembling: test.asm

C:\masm32>bin\link16 test.obj

Microsoft (R) Segmented Executable Linker Version 5.60.339 Dec 5 1994
Copyright (C) Microsoft Corp 1984-1993. All rights reserved.

Run File [test.exe]:
List File [nul.map]:
Libraries [.lib]:
Definitions File [nul.def]:

Running test.exe opens a popup "Unsupported 16-Bit Application":

The program or feature "\??\C:\masm32\test.exe" cannot start or run due
to incompatibility with 64-bit versions of Windows. Please contact the
software vendor to ask if a 64-bit Windows compatible version is available.

But in dosbox it works:
[http://www.dosbox.com/download.php?main=1]

My code:

.model small
.stack 100
data segment
    msg db "Enter a character: $"
data ends
code segment
assume cs:code , ds:data
_Start:
    mov dx, data
    mov ds, dx
    mov dx, offset msg
    mov ah,09h
    int 21h
    mov bx,ax
    mov ah,4ch
    int 21h
code ends
end _Start

Hi,
I do not know your level of assembly in 32 bits on windows.
I have written a Hello world program and can be compiled using the file build.bat of the masm32 package. May be it surprise you.

This is the code:

.486
.model flat,stdcall
option casemap:none

include c:\masm32\include\windows.inc
include c:\masm32\include\user32.inc
include c:\masm32\include\kernel32.inc
includelib c:\masm32\lib\user32.lib
includelib c:\masm32\lib\kernel32.lib


.data
    bbbb db "is wonderful", 0
        aaaa db "Assembly",0
.code


inicio:
    invoke MessageBox, NULL, addr bbbb, addr aaaa, MB_OK
    invoke ExitProcess, 0
end inicio

You need to understand that interrupts are forbiden and you must call windows api functions.

Registers are named preceding an "E" to the msdos part: EAX, EBX, ECX, etc.
The low word can be accessed with the msdos name. AX is the low word of EAX. And AH is the high byte of AX and AL is the low byte of AX (and of EAX).

The good news are that in the model flat all segment registers point to the same segment of 4GB. You do not need to refer to them in the most cases.

Cheers.

As you noted, it wasn't 32-bit assembly, but old 16-bit assembly.
It was just assembled with masm32 - even if linked with link16.

What I said was that to run the program, 16-bit dos emulator is needed.

I don't know why, but there has been some kind of 16-bit assembly mania around lately.

Hi,
In 32 bits systems, there was emulation to 16 bits code.
In 64 bits systems, there is emulation to 32 bits code, but they do not support 16 bits programs.
If you want to know more about this emulation search in google "wow" (windows on windows).
There are three solutions:
1. You can install an emulator like VirtualBox and create a 32 bits virtual machine. To do this you need a 32 bits instalation disk. The virtual 32 bits system will emulate 16 bits machine when needed.
2. You can use an emulator to emulate a 16 bits machine. You need the instalation disks and a way to install them.
3. You use DosBox. It is the easier solution, I think.

Cheers.

Member Avatar for Rahul47

Well using TASM on Windows 7 solved my problem.
Thanx Y'all for helping out :-)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.