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

Instruction operands must be of the same size error

I have defined the array in data segment like - myArray byte 01, 03, 02, 05 In the code I have a line mov eax, BYTE PTR myArray[ecx] the assembler throws a build error here instruction operands must be of the same size What could be the…
ishita
  • 23
  • 5
0
votes
0 answers

undefined symbol in data segment of assembly program

Putting the statement data byte 1h in the assembly program builds fine. But when I replace the same with data byte AAh it throws an error undefined symbol : AAh What could be the reason for that AA is a valid hexadecimal character and AA is one…
pensee
  • 375
  • 1
  • 10
0
votes
1 answer

8086 Assembly SHR instruction dividing by 3 problem

I know how shr division works but it dividing just even numbers. I want to divide the number by 3. What is the assembly 8086 code of this problem? Thanks.
rapa rapa
  • 11
  • 2
0
votes
1 answer

Integer Overflow irvine32

i wrote a code for this c++ expression in assembly language using 32 bit unsigned operands If (val2 ==0) then {val2 = 1} val1 = (val3 / val2) * (val1 + val3) but i got error "overflow Integer" the error is at div val2 when i enter the val1 = 600,…
0
votes
1 answer

Down Convert DWORD to BYTE, Assembly 32 bits

I would like to down convert Dword to Byte so that I can store it to a textfile in readable text by call WriteToFile. How can I do it? .386 .model flat, stdcall INCLUDE Irvine32.inc .stack 4096 .Data total DWORD ? …
Skyb
  • 11
  • 5
0
votes
1 answer

Getting a byte from a maze using offset calculation Assembly

For this project I am given a maze represented as an array of bytes that either contains 20h (empty space that can be moved into) or anything else (full space that cannot be moved into) From the driver program I am given x pointer si y …
DomC
  • 13
  • 3
0
votes
1 answer

Assembly maze solver not modifying si di and bx registers

I'm trying to program a maze solver in assembly. We are given a driver program that sends the current x position in the si register, the y position in the di register, the moving direction in the bx register and the maze itself in the bp…
DomC
  • 13
  • 3
0
votes
0 answers

How to Open Existing File and Write to File (Overwrite contents) in assembly language MASM , irvine32 bits

the problem focuses on MASM and using Irvine 32 bits only. I don't plan to use macro or etc unless really needed. .386 .model flat, stdcall INCLUDE Irvine32.inc .stack 4096 .Data inputFilename byte "Enter filename : ",0 …
Skyb
  • 11
  • 5
0
votes
0 answers

Assembly Language: Write a general-purpose program that correct an extra character in a string

I am trying to solve the following problem using Assembly Language with MASM: Write a general-purpose program that correct an extra character in a string. For example, in “Excellent time too listen to music” program should remove the extra o. Here…
hongkongbboy
  • 300
  • 1
  • 5
  • 14
0
votes
1 answer

How does VS 2019 select for which .asm file to create a listing file

I have a standard (?) project (vcxproj) with multiple .asm files in Visual Studio 2019 Community 16.6. In Configuration properties->MASM I have not set anything Still the .lst file is created for the project. So, there must be some "hidden"…
tinmanjk
  • 301
  • 1
  • 9
0
votes
0 answers

how to read value from file then make comparison to the respective requirement? the compare/jump command does not work

this is for masm assembly. here it reads from file. file contents is put into buffer mov edx, OFFSET buffer mov ecx, SIZEOF buffer call ReadFromFile mov buffer[eax],0 mov edx, offset…
Skyb
  • 11
  • 5
0
votes
0 answers

Why do add/sub instructions for partial 32bit register clear the upper 32bits of a 64bit register

EDIT: This is not a duplicate - in the supposed duplicate there is no mention of sub/add instructions - only MOV. Thanks to harold for the helpful replies... I know that the mov instruction using partial registers, such as eax, will clear the upper…
tinmanjk
  • 301
  • 1
  • 9
0
votes
0 answers

How to access the value of a stack parameter?

Extremely new to MASM here. I'm having trouble figuring out how to access the values passed into a procedure through the stack? For instance, here I try to simply add 2 vars, but the output gives me some crazy long address. Any suggestions? INCLUDE…
0
votes
0 answers

How to display results of a column sum in masm

I have to create a program using masm for windows. The program should read data from a file and store it into a 2d array, then display the column sum. I have successfully opened the file and calculated the sum but how do I display it? I am new to…
0
votes
0 answers

How to break infinite loop assembly Windows x64

I'm trying to add arrA and arrB and store the values into arrC and print out.. once I run the code it takes me to infinite loop. How can I break the loop? Any suggestions greatly appreciated. ExitProcess PROTO WriteHex64 PROTO .data arrA BYTE 10h,…
Lin
  • 9
  • 3
1 2 3
99
100