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
6
votes
2 answers

16 colors for background in MCGA BIOS text mode (AL = 03h)

MCGA supports 4-bits color depth, that is 16 colors. But when I try to print all of these colors, I get only first 8 of them and the rest 8 simply duplicate them as on the pic below. Can it be that I'm doing something wrong here or it is all because…
yulian
  • 1,601
  • 3
  • 21
  • 49
6
votes
3 answers

How to populate a 64 bit register with duplicate byte values

I'm doing some x64 assembly with Visual C++ 2010 and masm ('fast call' calling convention). So let's say I have a function in C++: extern "C" void fillArray(unsigned char* byteArray, unsigned char value); The pointer to array will be in RCX and…
Dziugas
  • 1,500
  • 1
  • 12
  • 28
6
votes
2 answers

Is there a difference between MASM shellcode and NASM shellcode

I am new to StackOverflow. Recently, I began studying assembly and am fairly new to assembly, completely new to shellcode. I am using RadAsm to compile using MASM assembler and I tried studying shellcode from this website Shellcoding for Linux and…
David
  • 183
  • 1
  • 2
  • 14
6
votes
2 answers

Retrieve arguments of a x64 masm assembly procedure

I have a function with the signature : extern "C" int foo(int a, int b, int c, int d, int e); which is in fact written in assembly. With ml(32 bits), using standard calling convention you can pretty much write .code foo PROC a: DWORD, b: DWORD ,c:…
UmNyobe
  • 22,539
  • 9
  • 61
  • 90
6
votes
1 answer

Converting problem: __asm__ __volatile__ from GNU C to MSVC for in / out wrappers

I have been dealing with Nasm and GNU C inline asm on a Linux environment for some time and this function worked great... but now I am switching to a windows environment and I want to use Masm (with VS2008) I cant seem to get this to work... void…
Fredrick
  • 513
  • 4
  • 17
6
votes
1 answer

Intel assembly syntax OFFSET

Now that i know u can use gcc for Intel syntax instead of default at&t with gcc -S -masm=intel test.c There is this line mov DWORD PTR [ebp-16], OFFSET FLAT:base Is it the same as mov dword[ebp-16], base? Otherwise what must i do?
Weigel Gram
  • 185
  • 1
  • 2
  • 11
6
votes
5 answers

LNK 2001 unresolved external symbol _mainCRTStartup MASM

I'm learning Assembly at my university, and we were given a CD with MASM 615 on it, and we're using the Irvine32 include library. Everything works fine with it on the school computer, but when I try to compile and run the same code on my home…
6
votes
6 answers

Using Visual Studio 2008 to Assemble, Link, Debug, and Execute MASM 6.11 Assembly Code

I would like to use Visual Studio 2008 to the greatest extent possible while effectively compiling/linking/building/etc code as if all these build processes were being done by the tools provided with MASM 6.11. The exact version of MASM does not…
5
votes
1 answer

Why does the MASM keyword SIZEOF MyByteArray always return 1 when using EXTERNDEF MyByteArray:BYTE

Created an include file with this single externdef keyword num.inc EXTERNDEF MyByteArray:BYTE Created an assembly file which defines a 10 byte array and includes num.inc num.asm option casemap:none include num.inc .data? MyByteArray BYTE 10 DUP…
vengy
  • 1,548
  • 10
  • 18
5
votes
1 answer

Execute RDMSR and WRMSR instructions from C/C++ code

I need to control C-State configuration. Specifically, I'd probably like to execute the following asm code: __asm { rdmsr and eax, 0x00 or eax, 0x01 wrmsr } Currently, I got this exception on rdmsr line: Unhandled exception at…
Lutosław
  • 606
  • 7
  • 24
5
votes
2 answers

How do we clear the console in assembly?

I am looking for a win32 api function that clears the console, much like the cls command Thanks! Devjeet
devjeetroy
  • 1,855
  • 6
  • 26
  • 43
5
votes
1 answer

How to use pop and ret in MASM

I have recently started learning x86 Assembly using the MASM language. I am using the Udemy course "x86 Assembly Language From Ground Up" by Isreal Gbati to learn. The code below is from a lesson in the course, (It's not code that I came up with).…
RobotMan
  • 605
  • 1
  • 5
  • 10
5
votes
1 answer

How to store 4 characters in a define doubleword in assembly language?

I'm currently doing assembly programming (16-bit) on DOSBox using MASM. var1 dd 'abcd' For the above code MASM is generating the error: A2010: syntax error What is wrong with the syntax? I am simply storing 4 characters in a doubleword. I am…
Hassaan Raza
  • 187
  • 3
  • 12
5
votes
2 answers

How do you use printf in x86 assembly in Visual Studio 2017?

Unhandled exception at 0x777745BA (ntdll.dll) in MASM1.exe: 0xC0000005: Access violation writing location 0x00000014. I'm using x86 assembly in visual studios 2017 and it keeps returning this error I have included all of the libraries and installed…
Mike D
  • 57
  • 1
  • 3
5
votes
1 answer

Upper bits of EBX are zeroed out when single-stepping in CodeView

I have the following simple program written in MASM for an i386 processor: TITLE BLA .MODEL SMALL .386 .STACK .DATA .CODE MAIN PROC FAR .STARTUP MOV EBX,0FFFFFFFFH; (1) …
jupiter_jazz
  • 333
  • 2
  • 8