The MASM Forum

Projects => MASM32 => Topic started by: MIH1406 on October 02, 2012, 11:44:00 AM

Title: MASM32 for Ubuntu Linux operating system?
Post by: MIH1406 on October 02, 2012, 11:44:00 AM
I have attending a course called Computer Architecture this semester and I found that I have to use MASM.

I am a linux user, I found other programs do the same job for me but in different formats, like: yasm and nasm.

I tried to run MASM32 using WINE but I failed.

Or at least, a masm-like assembler for Ubuntu Linux.
Title: Re: MASM32 for Ubuntu Linux operating system?
Post by: jj2007 on October 02, 2012, 12:19:01 PM
JWasm (http://www.japheth.de/JWasm.html#jwdownload) is a perfect clone of Masm, and runs on Linux. See here for an example (http://www.movsd.com/board/index.php?topic=12624.0).
Title: Re: MASM32 for Ubuntu Linux operating system?
Post by: Vortex on October 03, 2012, 03:30:56 AM
Another option is Solar Assembler :

http://oby.ro/sol_asm/index.html

QuoteMultiplatform, runs on:
WIn95, Win98, Windows XP, VISTA, Windows 7 32 and 64 bits
Mac OS X (10.5 leopard),
Unix / Linux and other unix like OSes that can link with an ELF libc
Solar OS
Title: Re: MASM32 for Ubuntu Linux operating system?
Post by: mineiro on October 03, 2012, 05:33:43 AM
hello Sir MIH1406;
after read your post I have tried install masm32v11 under linux and worked.
My command line was after uncompress, inside home user directory:
wineconsole install.exe
Then, it was installed under hidden folder .wine.
If you have troubles, post and I can try to help you, I will not garantee you to solve the problem, but I say to you that I will try from this side of monitor.

I'm currently working with jwasm under linux, but after see that solasm accept it too, I will try it.
Title: Re: MASM32 for Ubuntu Linux operating system?
Post by: mineiro on October 03, 2012, 05:48:56 AM
The easy way that I have found to make it work under linux was:
Ask for a friend to compress masm32 folder and send it to you, so you just need uncompress it under some folder and use wineconsole to do the job.

Remember that have some rules to be followed if you are using masm under linux, because you can only create programs to be microsoft compatible.
Title: Re: MASM32 for Ubuntu Linux operating system?
Post by: Gunther on October 03, 2012, 08:17:56 AM
Hi MIH1406,

the best way to run MASM under Linux is the WINE. Also possible is to use GAS with intel_syntax noprefix; that enables the Intel syntax for GAS. The rest is easy. Good luck.

Gunther

Title: Re: MASM32 for Ubuntu Linux operating system?
Post by: hutch-- on October 06, 2012, 01:00:48 PM
I personally don't see why more people don't use GAS with its newer Intel notation. You are no longer bound to that horrible AT&T notation and GAS performs fine. It feels a bit "agricultural" after using MASM but it does have that real assembler [tm] feel and you can use the Linux linker with it. (LD I think).
Title: Re: MASM32 for Ubuntu Linux operating system?
Post by: Gunther on October 06, 2012, 06:42:03 PM
Steve,

Quote from: hutch-- on October 06, 2012, 01:00:48 PM
I personally don't see why more people don't use GAS with its newer Intel notation. You are no longer bound to that horrible AT&T notation and GAS performs fine. It feels a bit "agricultural" after using MASM but it does have that real assembler [tm] feel and you can use the Linux linker with it. (LD I think).

yes, that's the point. And yes, the Linux linker is ld.

Gunther
Title: Re: MASM32 for Ubuntu Linux operating system?
Post by: Vortex on October 06, 2012, 08:21:20 PM
The AT&T notation is unusable, that's true. If I am not wrong, FreeBasic is using GAS too.
Title: Re: MASM32 for Ubuntu Linux operating system?
Post by: Gunther on October 06, 2012, 09:28:08 PM
Hi Vortex,

you're right: The AT&T syntax needs a large habituation. :icon_cool: The only advantage that I can see is that: the source, destination syntax did help me to master the PowerPC assembly languge, because that boxes have Motorola processors built in.

Gunther
Title: Re: Is gas compatible with masm syntax?
Post by: Lassar on March 01, 2013, 03:12:56 PM
Question ?

Is gas compatible with masm syntax.
Title: Re: MASM32 for Ubuntu Linux operating system?
Post by: hutch-- on March 01, 2013, 03:30:32 PM
Lassar, simple answer is no but GAS will do standard Intel notation if you set that option. To use direct MASM notation you can use JWASM if you have some reason not to use the original Microsoft ML.EXE.
Title: Re: MASM32 for Ubuntu Linux operating system?
Post by: MichaelW on March 01, 2013, 05:44:08 PM
Quote from: Vortex on October 06, 2012, 08:21:20 PM
If I am not wrong, FreeBasic is using GAS too.

Yes, the default backend code emitter outputs Intel-syntax GAS code, but there is also a gcc backend in development.
Title: Re: MASM32 for Ubuntu Linux operating system?
Post by: Vortex on March 02, 2013, 05:42:26 AM
Hi MichaelW,

Any chance to get a preview of the gcc backend?
Title: Re: MASM32 for Ubuntu Linux operating system?
Post by: goofprog on September 15, 2013, 07:48:28 PM
Try DosBox maybe it works with MASM under linux.
Title: Re: MASM32 for Ubuntu Linux operating system?
Post by: MichaelW on September 16, 2013, 04:05:48 AM
Quote from: Vortex on March 02, 2013, 05:42:26 AM
Hi MichaelW,

Any chance to get a preview of the gcc backend?

Sorry, I didn't reply at the time because I somehow missed your post. The gcc backend has been more or less operable and part of the distribution for several years IIRC. With the version 0.90.0 release in June, the developer who currently seems to be doing most of the compiler work stated that:
Quote
The C backend has become stable, with many bugs fixed

http://www.freebasic.net/forum/viewtopic.php?f=1&t=21321

And the 0.90.0 release was followed with 0.90.1 less than a month later to fix a few problems.

http://www.freebasic.net/forum/viewtopic.php?f=1&t=21382

Here is one of the examples included with the distribution, procedures.bas:

function AddNumbers( a as integer, b as integer ) as integer
return a + b
end function

sub hello( )
print "hello"
end sub

declare sub myprint( num as integer )

'' Code outside any procedures is the main part of the program
hello( )
print AddNumbers( 1, 1 )
myprint 5

sub myprint( num as integer )
print num
end sub


And the assembly output when compiled with 0.90.1 as a console app with the default -gen gas:

.intel_syntax noprefix

#procedures.bas' compilation started at 12:30:02 (FreeBASIC 0.90.1)

.section .text
.balign 16

.globl _ADDNUMBERS@8
_ADDNUMBERS@8:
push ebp
mov ebp, esp
sub esp, 4
mov dword ptr [ebp-4], 0
.Lt_0004:
mov eax, dword ptr [ebp+12]
add eax, dword ptr [ebp+8]
mov dword ptr [ebp-4], eax
.Lt_0005:
mov eax, dword ptr [ebp-4]
mov esp, ebp
pop ebp
ret 8
.balign 16

.globl _HELLO@0
_HELLO@0:
.Lt_0006:
push 1
push 5
push offset _Lt_0008
call _fb_StrAllocTempDescZEx@8
push eax
push 0
call _fb_PrintString@12
.Lt_0007:
ret
.balign 16

.globl _MYPRINT@4
_MYPRINT@4:
push ebp
mov ebp, esp
.Lt_0009:
push 1
push dword ptr [ebp+8]
push 0
call _fb_PrintInt@12
.Lt_000A:
mov esp, ebp
pop ebp
ret 4
.balign 16

.globl _main
_main:
push ebp
mov ebp, esp
and esp, 0xFFFFFFF0
sub esp, 4
mov dword ptr [ebp-4], 0
call ___main
push 0
push dword ptr [ebp+12]
push dword ptr [ebp+8]
call _fb_Init@12
.Lt_0002:
call _HELLO@0
push 1
push 1
push 1
call _ADDNUMBERS@8
push eax
push 0
call _fb_PrintInt@12
push 5
call _MYPRINT@4
.Lt_0003:
push 0
call _fb_End@4
mov eax, dword ptr [ebp-4]
mov esp, ebp
pop ebp
ret
#procedures.bas' compilation took 0.002902044813286153 secs

.section .data
.balign 4
_Lt_0008: .ascii "hello\0"


And the C output when compiled with 0.90.1 as a console app with -gen gcc:

// Compilation of procedures.bas started at 12:57:54 on 09-15-2013

typedef signed char byte;
typedef unsigned char ubyte;
typedef unsigned short ushort;
typedef signed int integer;
typedef unsigned int uinteger;
typedef unsigned long ulong;
typedef signed long long longint;
typedef unsigned long long ulongint;
typedef float single;
typedef struct _string { char *data; int len; int size; } string;
void __stdcall fb_PrintInt( integer, integer, integer );
void __stdcall fb_PrintString( integer, string*, integer );
string* __stdcall fb_StrAllocTempDescZEx( ubyte*, integer );
void __stdcall fb_Init( integer, ubyte**, integer );
void __stdcall fb_End( integer );
integer __stdcall ADDNUMBERS( integer, integer );
void __stdcall HELLO( void );
void __stdcall MYPRINT( integer );

integer __stdcall ADDNUMBERS( integer A$1, integer B$1 )
{
integer fb$result$1;
__builtin_memset( &fb$result$1, 0, 4 );
label$2:;
fb$result$1 = A$1 + B$1;
goto label$3;
label$3:;
return fb$result$1;
}

void __stdcall HELLO( void )
{
label$4:;
string* vr$3 = fb_StrAllocTempDescZEx( (ubyte*)(ubyte*)"hello", 5 );
fb_PrintString( 0, vr$3, 1 );
label$5:;
}

void __stdcall MYPRINT( integer NUM$1 )
{
label$6:;
fb_PrintInt( 0, NUM$1, 1 );
label$7:;
}

integer main( integer __FB_ARGC__$0, ubyte** __FB_ARGV__$0 )
{
integer fb$result$0;
__builtin_memset( &fb$result$0, 0, 4 );
fb_Init( __FB_ARGC__$0, __FB_ARGV__$0, 0 );
label$0:;
HELLO(  );
integer vr$5 = ADDNUMBERS( 1, 1 );
fb_PrintInt( 0, vr$5, 1 );
MYPRINT( 5 );
label$1:;
fb_End( 0 );
return fb$result$0;
}

// Total compilation time: 0.00207652090124455 seconds.


I recall the original developer of FreeBASIC and the gcc backend stating that the C compiler was being used as a sort of assembler. IIRC the emitted C code at that time was very different than the code above, and at least for me hard to follow, and, although I did not test this, looked like something that a compiler, tuned to optimize "normal" C code, would not be able to optimize well. But as stated in the FreeBASIC documentation, "the goal of the C emitter (when complete) will be to make it possible to port FreeBASIC-compiled programs (and fbc itself) to other platforms."