MIPS assembly on Visual Studio 2013 - visual-studio

I am looking for a way to program for MIPS assembly using VS2013 - but there is no assembly type project.
Is there a way to do this and get the .s output files of MIPS so I can later run them on other machines, and if I can't do this on VS2013 than how do I program MIPS on Windows 7?
Thanks

The assembler used in visual studio is Microsoft assembler (MASM), and yes you can program assembly language on it.
select an "Empty Project" then configure the "Build Customizations" of the project to use MASM, after that add a new c++ source file and rename it to any name .asm
Here are the detailed steps:
http://kipirvine.com/asm/gettingStartedVS2013/index.htm
And as for assembling your code to run on MIPS, I guess you can't do that with MASM, because it's a x86 assembler,
here is a list of the supported processor types directives on masm
.386
.386P
.387
.486
.486P
.586
.586P
.686
.686P
.K3D
.MMX
.XMM
Refer to
https://msdn.microsoft.com/en-us/library/vstudio/8t163bt0%28v=vs.100%29.aspx
the processor section.
Nevertheless, there is an option in the project "Properties" > "Linker" > "advanced" that let you chose between different machines, including Mips, but I guess this will merely set the Machine Flag in the PE header to MIPS and when the assembler try to build your module it will find a conflict between the machine type flag and the code in the module. But I'm not sure If you can build codes for MIPS.

To run MIPS programs on Windows 7, you need some type of emulator and a corresponding tool set. In the case of ARM processors, there are emulators that include a source level debugger and tool sets, including compilers, assemblers, linkers, and binary image output utilities for embedded systems. There's also a debugger for embedded systems that is run from Windows and some type of connection to the embedded system. The tool set runs on Windows, but targets the emulator or an actual embedded system. I don't know if there's a equivalent tool set and emulator like this for the MIPS processor.

Related

64-bit inline assembly Microsoft Visual Studio 2010

Is there some kind of plugin, extension or something that would enable 64-bit inline assembly in Microsoft Visual Studio 2010?
From http://msdn.microsoft.com/de-de/library/4ks26t93%28v=vs.100%29.aspx
Programs with inline assembler code are not fully portable to other
hardware platforms. If you are designing for portability, avoid using
inline assembler.
Inline assembly is not supported on the ARM and x64 processors.
Not that I know of, but you don't really need it - you can simply assemble the assembly code separately and link it in. You don't even need a plugin for that, just right click the project, go to build customizations, and enable masm. Then you just add some assembly files.
If you don't really like masm with its "dword ptr" and strange semantics for variables and so on, you can use yasm plugin (which is enabled in the same way, except you enable yasm in the build customizations instead of masm).

SIMULINK - use .dll and .OBJ files (compiled using visual studio compiler) in a host machine (with different compiler)

I need to use some library file that have been build using Visual Studio 2010 Professional (MSVCRT2010 compiler?!) and I am having trouble building my s-functions in another host machine. My target host machine does not have Visual Studio so MATLAB cannot pickup the C++ compiler. Also, LCC (MATLAB's native) compiler is probably different. How can I manage to do that without causing minimum hassle?
I can think about one thing - retargetting the library to be cross-compiler friendly. I have already done that when I got the library from my legacy code pool (UNIX GNU platform) and it was supposed to be running okay with any compiler after my retargetting. However, it has come back to bit me.
Is it something regarding redistributable VS files? or am I driving myself insane?
The error msg I am getting is:
Writing library for y_ing_sl_ver.mexw32
File c_src_~1\lg_com~1\y_ing.obj contains unknown section .rtc$TMZ.
.text section assumed
File c_src_~1\lg_com~1\y_ing.obj contains unknown section .rtc$IMZ.
.text section assumed
c_src_~1\lg_com~1\ymginteg.obj .rtc$TMZ: undefined reference to '__RTC_Shutdown'
c_src_~1\lg_com~1\ymginteg.obj .rtc$IMZ: undefined reference to '__RTC_InitBase'
C:\PROGRA~2\MATLAB\R2013A\BIN\MEX.PL: Error: Link of 'y_ing_sl_ver.mexw32' failed.

WIN32 Preprocessor definition in 64bit windows platform

Should we change the preprocessor definition from WIN32 to WIN64 while migrating Visual 2012 C++ Projects to Target 64-Bit Platforms.
Now I have built the project with below settigns
MACHINE (Specify Target Platform) is set to /MACHINE:X64.
Target Environment is set to /env x64
in C/C++ project settings -> Code Generation, Struct Member
Allignment to 8 BYtes
Please guide me what else project settings i should target to change.
It's important to note that only the underscore versions of these preprocessor definitions are relevant to the distinction between 32-bit vs. 64-bit machines.
The underscore versions, _WIN32 and _WIN64 are built-ins that relate to the actual physical CPU of the computer that VC++ is running on. On a 32-bit machine, _WIN32 will always be defined (user does not need to define it), but _WIN64 will not be defined. On a 64-bit machine, _WIN64 will always defined and also _WIN32 may be defined but code can rely on _WIN64 to determine if machine is 64 bit.
For Visual Studio 2019 (perhaps other VS versions also):
The non-underscore WIN32 is not well documented and appears to have no bearing on 32 vs 64 machine type. Standard Visual C++ projects for Windows generally don't appear to use it (it may not be in use at all). Thank you to BTJ for making that point.
Another side note for Visual Studio: If you run Visual Studio on a 64-bit machine and select the Win32 vs x64 build configurations, you will notice that WIN32 is defined for the Win32 build configuration but it is not defined for an x64 build configuration. This does not affect the object/binary machine target e.g. 32 vs 64. It's purpose is unclear. It may be for convenience if one wishes to use it to #ifdef certain parts of the source code that are to be compiled differently for X86 vs X64, but again, it has no bearing on the architecture that the compiler targets. For the compiler, the target architecture is determined by the toolset that is selected based on the project target selected "Platform". The linker also has /MACHINE arg e.g. /MACHINE:X86.
Did you mean _WIN32 and _WIN64 macros? If you specified all parameters right (see P.S.) then you don't need change your code. In 64-bit solution must be defined _WIN32 and _WIN64 both. _WIN32 macro specifies that you can use Win32 API and _WIN64 macro specifies that compilation for 64-bit mode. Also you can use different macro for Itanium (_M_IA64) and x86-64 (_M_AMD64). See details in MSDN.
P.S. Did you choose platform parameters manually? You can specify it via VS:
Build Menu -> Configuration Manager.
Select New in Active Solution Platform.
Type or select new platform -> x64 and click OK.
Now in "Platform" row you can simple choose x64.
In VS2015 at least, linker/All Options/Target Machine
this assumes that you're not using a 3rd-party tool (say widget support or hardware driver) that is configured to use x86 code or is built 32-bit while you're trying to build x64, or vice-versa

_AMD64_ not defined in VS2010

I created a new c++ project in VS2010. I added x64 as a new solution platform. I tried setting "copy settings from" to both "Win32" and "empty", but neither worked. _AMD64_ is not defined when I select x64 as the platform. Shouldn't it be? Is there another step I am unaware of for compiling for 64 bit?
In anticipation to questions: I am using VS2010 Ultimate, Windows 7 64bit, x64 compilers were selected during VS installation.
You've got all the steps right. An _AMD64_ symbol is not predefined by default by Visual Studio. You'll need to define it yourself if you want to use it:
#if defined _M_X64 || defined _M_AMD64
#define _AMD64_
#endif
But you're not making up the memory of its existence. The Windows DDK comes with makefiles that define this symbol, in addition to some others. Check in makefile.def. The possibilities are:
_X86_
Variously known as x86, i386, and IA-32
(this is the same as VS's predefined _M_IX86)
_AMD64_
Variously known as AMD64, x64, x86-64, IA-32e, and Intel 64
(this is the same as VS's predefined _M_X64 and _M_AMD64)
_IA64_
Intel Itanium (IA-64)
(this is the same as VS's predefined _M_IA64)
…and some others for architectures nobody targets anymore
Ideally, you would configure your build system to predefine a set of known macros that you will then use in your own code. If you don't have a build system, at least set something up in a precompiled header file. That way, you're not relying on implementation-dependent symbols everywhere, and switching compilers is not a colossal chore—the target architecture symbols predefined by GCC are very different from MSVC, for example.

Microsoft MIPS assembler

I was searching for an assembler to generate MIPS binary from asm files and stumbled upon this. Where can I find this assembler. Did not find a link to download this. I have Visual Studio 2010 installed, it doesn't show Assembler project types. Basically I need to generate MIPS binaries to test the disassembler I did as part of course work.
I think MIPS is supported with Windows CE. Otherwise the Gnu toolchain for MIPS is widely available. That will give you a MIPS cross-assembler and linker.
the MIPS Assembler is present in VS 2008 but not in VS 2010. it is a stand alone tool and found in %program files%\Microsoft Visual Studio 9.0\VC\ce\bin\x86_mips

Resources