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

NASM is pure assembly, but MASM is high level Assembly?

I'm learning assembly, motivation being able to reverse engineer. I'm trying to find the assembler I should begin with, so that I can then find tutorials and start writing some assembly. I came to know that MASM has a lot of built in constructs, so…
questions
  • 2,337
  • 4
  • 24
  • 39
12
votes
2 answers

error LNK2001: unresolved external symbol _MessageBox

I am trying to create a helloworld program using only masm and not masm32 libs. Here is the code snippet: .386 .model flat, stdcall option casemap :none extrn MessageBox : PROC extrn ExitProcess : PROC .data HelloWorld db "Hello There!",…
Jumbo
  • 533
  • 3
  • 8
  • 15
12
votes
2 answers

Referencing the contents of a memory location. (x86 addressing modes)

I have a memory location that contains a character that I want to compare with another character (and it's not at the top of the stack so I can't just pop it). How do I reference the contents of a memory location so I can compare it? Basically how…
DrakeJacks
  • 187
  • 1
  • 2
  • 8
12
votes
1 answer

Confusing brackets in MASM32

I am trying to get to grips with MASM32 and am confused by the following: I thought that brackets were used for indirection so if I have the a pre-defined variable .data item dd 42 then mov ebx, item would put the contents of 'item', i.e.…
Penguino
  • 2,136
  • 1
  • 14
  • 21
11
votes
5 answers

Force visual studio to always 'rebuild all' when debugging

Edit: Basically what I need is for visual studio to always rebuild all when I hit debug. I'm currently using visual studio to compile my assembly programs, using MASM and in general it's working fine. However I've run into an annoying issue: If I…
Cam
  • 14,930
  • 16
  • 77
  • 128
11
votes
3 answers

masm division overflow

I'm trying divide two numbers in assembly. I'm working out of the Irvine assembly for intel computers book and I can't make division work for the life of me. Here's my code .code main PROC call division exit main ENDP division PROC mov…
10
votes
2 answers

Difference between `bx` and `bp`?

What is the difference between bx and bp in assembly? Example here: mov bx, 1h mov bp, 1h Do they reference to the same memory? Is it the same with ss and sp?
tina nyaa
  • 991
  • 4
  • 13
  • 25
10
votes
1 answer

Assembly programming - WinAsm vs Visual Studio 2017

I'm here to ask you some stuff about VS2017. In the past I had used WinAsm for MASM and I never got problems with it. However, when I'm trying to do something with MASM in VS2017, I always gonna get problems and stuff... I've checked the whole…
Gregan Dark
  • 101
  • 1
  • 5
10
votes
2 answers

Infected compiler, or malfunction?

I've encountered something very strange, and things just don't add up. First of all, I posted this here because I'm not sure if this has anything to do with computer virusses at all. And if it does, could you please direct me to a place to find…
Rick
  • 103
  • 4
10
votes
3 answers

Outputting Hello World in MASM using WIN32 Functions

Contents Intro Code Assembling and Running Miscellaneous Question 1. Intro This isn't a question per se (though there is one at the bottom) but a HelloWorld app for people on StackOverflow to experiment with. When I was first trying programing…
Zimm3r
  • 3,369
  • 5
  • 35
  • 53
10
votes
1 answer

x86 assembly equ vs =

I am taking a class in x86 assembly language and it's starting to move rather fast. There is one thing that the book keeps doing without mentioning how it works, and that is using the equ and = operators when defining data. So it seems like equ is…
Backwardsman
  • 142
  • 1
  • 9
10
votes
3 answers

JMP to absolute address (op codes)

I'm trying to code a exe packer/protector as a way of learning more about assembler, c++, and how PE files work. I've currently got it working so the section containing the EP is XORed with a key and a new section is created that contains my…
Christopher Tarquini
  • 11,176
  • 16
  • 55
  • 73
10
votes
2 answers

Why doesn't MS-DOS initialize the DS and ES registers?

Why does the initialization of the DS and ES registers has to be done manually by the programmer? For example: MOV AX, DTSEG MOV DS, AX On the other hand, the CS and SS registers are initialized by the operating system (in MS-DOS). Why is this…
mohammad mahed
  • 511
  • 2
  • 6
  • 11
9
votes
3 answers

Assembly language for Reverse Engineering

What should I choose NASM or MASM for learning assembly. I want to learn assembly, motivation being Reverse Engineering. So that when I disassemble some executable, I can understand the code by looking at disassembled code. Update: I think I dint…
questions
  • 2,337
  • 4
  • 24
  • 39
9
votes
3 answers

How are dw and dd different from db directives for strings?

Let's say I want to define a initialized variable string before running my assembly program (in section .data). The variable I chose to create is called Digits and it is a string that contains all the hexadecimal symbols. Digits: db…
Pichi Wuana
  • 732
  • 2
  • 9
  • 35