Questions tagged [masm]

MASM is Microsoft's Macro Assembler tool for converting assembly language to object code. It processes x86 instructions and pseudo instructions written in "Intel syntax". MASM is the standard low-level language for all MSDOS and Windows environments and is currently being supported in the 32-bit and 64-bit versions.

This tag is for questions related specifically to MASM. General questions about assembly language should be tagged or . Questions specifically about the CPU should be tagged and/or . Further, questions about the SDK and IDE should also be tagged accordingly. Other competing assemblers include and : Check the documentation of the respective softwares to verify the degree of compatibility with MASM specific source code.

MASM has been available since MSDOS 1.0 in 1981 and was a separate product until about 1999; since then it has been packaged with other tools, primarily Visual Studio. While the most current version is no longer available for download, it is provided with Visual C++ and accessible via the command line.

MASM contains a powerful macro capability, a preprocessor with access to program symbols and can string manipulation, conditional assembly, and some C-like syntax (if...elseif...else...endif, while..endw, and repeat..until). Other features include variable typing, type casting and argument type checking.

Much of the difficulty of using MASM is related to the complexity and non-orthogonality of Intel's CPU architecture. Because of advances in processor technology, the assembly language has similarly expanded and advanced, though sometimes haphazardly. For example, the LOOP and REP instructions are implicitly only able to use the register CX (or ECX in 32-bit mode), owed to the design of the instruction set.

Expect extensive pre-planning and graduate level research to be required for usage of MASM to be fruitful.

Resources:

2604 questions
9
votes
1 answer

Returning a __m128d from MASM procedure to a C caller

I am porting a function from inline assembly to MASM in Visual Studio 2013 and am having trouble getting a return value out of it. Here is the C caller and the assembly function prototype: extern "C" void AbsMax(__m128d* samples, int len, __m128d*…
jaket
  • 9,140
  • 2
  • 25
  • 44
8
votes
3 answers

Assembly language - Stack machine

I am learning assembly language in my spare time to become a better developer. I understand the difference between stack-based machines and register-based machines at a conceptual level, but I am wondering how stack-based machines are actually…
w0051977
  • 15,099
  • 32
  • 152
  • 329
8
votes
2 answers

bt assembly instruction

I have quesetion about bt assembly instruction. I have excerpted part of book to provide context. Please see last example, bt Testme, bx. Why does that copy TestMe+8? Shouldn't it copy TestMe+65? Very much thank you for help! 6.6.4.2 The Bit Test…
tina nyaa
  • 991
  • 4
  • 13
  • 25
8
votes
2 answers

What is the difference between MASM.exe and ml.exe?

When i install masm assembler, it asked to install Microsoft visual c++ 2005 express edition. I installed it. Now i can find only "ml.exe". Where is masm.exe? Even i tried in cmd by typing masm.exe, but it didn't work. Is masm.exe and ml.exe same?
user3718000
  • 399
  • 5
  • 9
8
votes
2 answers

Write a maximum of two instructions to clear, set and complement some bits in the AL register

You are required to write a maximum of two instructions in assembly to do the following: Clear bits 0 and 7 of register AL, i.e. make them 0 Set bits 3 and 4 of register AL, i.e. make them 1. Complement bits 1 and 5 of register AL. Keep all other…
Nick
  • 155
  • 1
  • 8
8
votes
2 answers

Quick, beginner MASM register question - DX:AX

I am currently studying for an exam I'll have on x86 assembly. I didn't have much luck googling for ":", too common of a punctuation mark :/ IDIV - Signed Integer Division Usage: IDIV src Modifies flags: (AF,CF,OF,PF,SF,ZF undefined) Signed…
F. P.
  • 5,018
  • 10
  • 55
  • 80
8
votes
3 answers

Detecting architecture at compile time from MASM/MASM64

How can I detect at compile time from an ASM source file if the target architecture is I386 or AMD64? I am using masm(ml.exe)/masm64(ml64.exe) to assemble file32.asm and file64.asm. It would be nice to create a single file, file.asm, which should…
botismarius
  • 2,977
  • 2
  • 30
  • 29
8
votes
1 answer

Move quadword between xmm and general-purpose register in ml64?

In a simple program written for Microsoft's x64 assembler, I want to move a 64-bit value between an SSE register (say xmm0) and a general-purpose register (say rcx), as in : mov xmm0, rcx ... mov rcx, xmm0 These two lines…
0xbe5077ed
  • 4,565
  • 6
  • 35
  • 77
8
votes
3 answers

TSL instruction reference

I want to use "TSL" instruction in assembly , but it has no reference for understand .in some articles this instruction is introduced for mutual exclusion problem but it has no reference or complete example to understand completely.
RF27
  • 99
  • 1
  • 4
8
votes
8 answers

Taking an Assembly Course, Stuck in DOS!

I'm taking a course on Microprocessor Programming as part of my Electronic Engineering degree. Unfortunately, in the labs, we have to work in DOS using MASM. Now, I don't really find DOS a hindrance, but I just don't have it on a computer at home…
Saad
  • 81
  • 1
  • 2
8
votes
2 answers

__cdecl, __stdcall and __fastcall are all called the exact same way?

I am using Visual C++ 2010, and MASM as my x64-Assembler. This is my C++ code: // include directive #include "stdafx.h" // functions extern "C" int Asm(); extern "C" int (convention) sum(int x, int y) { return x + y; } // main function int…
Name
  • 2,037
  • 3
  • 19
  • 28
8
votes
2 answers

Why can't I change the value of a segment register? (MASM)

I decided to teach myself assembly language. I have realized that my program will not compile if I attempt to change the value of any segment register. Every article that I have found says that I can indeed change the value of at least 4 segment…
Ed S.
  • 122,712
  • 22
  • 185
  • 265
7
votes
2 answers

Injecting 64 Bit DLL using code cave

I'm trying to inject a 64 Bit DLL into 64 Bit Process (explorer for the matter). I've tried using Remote-thread\Window Hooks techniques but some Anti-Viruses detects my loader as a false positive. After reading this article : Dll Injection by…
Omer
  • 661
  • 7
  • 21
7
votes
1 answer

How to remove unused .CONST data in MASM?

I'm using macros in MASM to generate about 2000 functions, for each of which I define a string, but I only use around ~30 of them in any given program. (There is no way to predict which ones I will use ahead of time; I use them as needed.) Is…
user541686
  • 205,094
  • 128
  • 528
  • 886
7
votes
3 answers

Les instruction purpose?

What is purpose of les instruction in assembly? Why do we need to load es segment and a register? Book gives following example: les bx, p ; Load p into ES:BX mov es:[bx], al ; Store away AL Why do we need to load es and bx in…
tina nyaa
  • 991
  • 4
  • 13
  • 25