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
7
votes
1 answer

How to write an absolute target for a near direct relative call/jmp in MASM

To make a normal (near direct relative) call to an absolute address, in NASM or AT&T syntax you write call 0x1234567, and the assembler + linker take care of calculating a rel32 to reach that target from wherever the linker puts the call…
Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
7
votes
2 answers

x86 register flag abbreviations

I'm currently studying assembly language. In Microsoft visual studio 2017, I wanted to check the current status of the register flags. I wanted to know what each register flag abbreviation stands for, so I checkout the wiki page on x86 register…
Thor
  • 9,638
  • 15
  • 62
  • 137
7
votes
3 answers

Difference between masm32 and masm?

I am trying to learn assembly for windows and see that there are 2 assemblers: masm : https://www.microsoft.com/downloads/en/details.aspx?FamilyID=7a1c9da0-0510-44a2-b042-7ef370530c64 masm32 : http://masm32.com/index.htm are these equivalent? which…
Jumbo
  • 533
  • 3
  • 8
  • 15
7
votes
3 answers

Call C standard library function from asm in Visual Studio

I have a problem with calling C function from asm project created in visual studio (Win10 x64, Visual Studio 2015). Project consist of one asm file: .586 .model flat, stdcall option casemap:none includelib msvcrt.lib ExitProcess PROTO…
Sunrise
  • 1,311
  • 3
  • 18
  • 28
7
votes
4 answers

How to code a far absolute JMP/CALL instruction in MASM?

How can I write a far absolute JMP or CALL instruction using MASM? Specifically how do I get it to emit these instruction using the EA and CA opcodes, without manually emitting them using DB or other data directives? For example consider the case of…
Ross Ridge
  • 38,414
  • 7
  • 81
  • 112
7
votes
3 answers

Assembly Language (x86): How to create a loop to calculate Fibonacci sequence

I am programming assembly language (x86) in MASM using Visual Studio 2013 Ultimate. I am trying to use an array to calculate a Fibonacci sequence for n elements using an array. In other words, I am trying to go to an array element, obtain the two…
jshapy8
  • 1,983
  • 7
  • 30
  • 60
7
votes
1 answer

Why am I having to rebuild an unchanged project?

I have the following MASM code: .386 .model flat, stdcall option casemap :none include \masm32\include\masm32rt.inc .data NewLine db 13, 10, 0 .code LibMain proc instance:dword,reason:dword,unused:dword mov eax, 1 ret LibMain…
Corey Ogburn
  • 24,072
  • 31
  • 113
  • 188
7
votes
2 answers

Assembly difference between TASM and MASM

I am learning TASM at University, but information regarding TASM on the web seems to be very limited. I have found more information on MASM. My question is, what is the different between MASM and TASM?
Wizard
  • 10,985
  • 38
  • 91
  • 165
7
votes
3 answers

How do I use a buffer in an assembly procedure?

So, I understand the general abstract concept of a buffer: it's an allocation in memory that holds data before it gets processed. I'm trying to complete a homework problem which requires me to write an ASCII string into a buffer within a procedure.…
santeyio
  • 95
  • 1
  • 1
  • 8
6
votes
0 answers

CMake not adding preprocessor definitions for ASM_MASM

In build system generated (Visual Studio 2017 Generator) with the following cmake, the 'test.asm' source file isn't compiled with the preprocessor definition MY_MASM_DEFINITION: cmake_minimum_required(VERSION…
AlastairHolmes
  • 427
  • 2
  • 10
6
votes
5 answers

x86 assembly works on which CPUs?

I have spent a few years coding in C and Java. I enjoy how I can make a program display a message box or perform some file operations and it works on every (I think?) CPU without any dramas. Although I have never coded anything advanced. I want to…
securityauditor
  • 293
  • 3
  • 13
6
votes
4 answers

Printing Hexadecimal Digits with Assembly

I'm trying to learn NASM assembly, but I seem to be struggling with what seems to simply in high level languages. All of the textbooks which I am using discuss using strings -- in fact, that seems to be one of their favorite things. Printing hello…
BSchlinker
  • 3,401
  • 11
  • 51
  • 82
6
votes
1 answer

Why does Visual Studio assemble mov eax, [edx][ebx][ecx][edi] without complaint?

In Visual Studio, I wrote: mov eax, [edx][ebx][ecx][edi] But it assembles just fine. Why it is not invalid effective address?
6
votes
1 answer

Assembly - x86 call instruction and memory address?

I've been reading some assembly code and I've started seeing that call instructions are actually program counter relative. However, whenever I'm using visual studio or windbg to debug, it always says call 0xFFFFFF ... which to me means it's saying…
halivingston
  • 3,727
  • 4
  • 29
  • 42
6
votes
2 answers

How can I transpose an image in Assembly?

I'm working on a project and I need to compute something based on the rows and columns of an image. It's easy to take the bits of the rows of the image. However, to take the bits of each column I need to transpose the image so the columns become…
Nick
  • 155
  • 1
  • 8