problem about masm-Collection of common programming errors


  • ktodisco
    visual-studio-2010 assembly linker masm
    A while ago I posted this question regarding strange behavior I was experiencing in trying to step through a MASM program.Essentially, given the following code:; Tell MASM to use the Intel 80386 instruction set. .386 ; Flat memory model, and Win 32 calling convention .MODEL FLAT, STDCALL ; Treat labels as case-sensitive (required for windows.inc) OPTION CaseMap:Noneinclude windows.inc include masm32.inc include user32.inc include kernel32.inc include macros.asmincludelib masm32.lib includelib us

  • Shumail Mohy-ud-Din
    assembly masm
    I have written a simple small assembly program in MASM but the output i am getting is unexpected and is prefixed by 3. Like i have entered 12345 on displaying it shows output as31 32 33 34 35Where as if i don’t take input from user and hard code it like mystring byte 1,2,3,4,6 – It shows output like 01 02 03 04 06Help me in understanding this behavior – Thanks in advanceHere is program code: INCLUDE Irvine32.inc.data disp byte “Enter String : “,0 mystring byte 5 dup(?).code main PROC mov edx,of

  • Gunner
    assembly libraries masm masm32
    I have the following code:include stdlib.a includelib stdlib.libBut on assembling, it gives me an error: “cannot open file : stdlib.a”I haven’t any file called “stdlib.lib” or “stdlib.a”.I’ve been searching for those files, but I can’t find them. The only file I can find is “stdlib.h”(look Ramhound’s answer), but WinAsm doesn’t recognise it on compiling.Is there any way to transform the “stdlib.h” to “stdlib.lib” or “stdlib.a”, or to use in assembly? ( From Ramhound’s answer : * “stdlib.h” is a

  • Alexander Maier
    masm null-terminated getmodulefilename
    In my program i call the GetModuleFileName function from the Windows Api. The function tells me the path of the running *.exe. On Windows XP machines the string (szSrc) is not null-terminated according to the MSDN. invoke GetModuleFileName,NULL,szSrc,255How can i null terminate it?

  • CDUB
    c# assembly masm ilasm
    whats the relation(if any) of MASM assembly language and ILASM. Is there a one to one conversion? Im trying to incorporate Quantum GIS into a program Im kinda writing as I go along! I have GIS on my computer, I have RedGate Reflector and it nor the Object Browser of Visual Studio 2008 couldnt open one(of several which I dont have a strong clue to how they behave) of the .dlls in Quantum. I used the MASM assembly editor and “opened” the same dll and it spewed something I didnt expect to neces

  • JMP
    assembly masm
    I’ve been wrapped around the axle all day trying to figure out why INSTR isn’t finding a carriage return in my text file. How do I get the INSTR macro to read the text and find the line breaks?.dataCRLF db 13,10,0.data?hFile DWORD ?bytesRead DWORD ?tmpstr BYTE 1825 DUP (?).codeprintln_arr MACRO arrlea EAX, arrprint EAX ENDMstart:mov hFile, fopen(“books.txt”)mov bytesRead, fsize(hFile)mov bytesRead, fread(hFile, addr tmpstr, 1825)strpos TEXTEQU @InStr( , tmpstr, CRLF)print “Position of first ins

  • Jon Bright
    runtime zlib msvcrt masm
    Can zlib be used with masm without all the c runtime libraries such as msvcrt.dll and many others? If so, can you tell me how?

  • Will
    c++ flash dll assembly masm
    I am working with the Adobe Flash ocx by loading it into my C++ program. The ocx is supposed to be 64 bit but for some reason it has issues when I compile with the x64 platform. I have read up on this and found that it is likely that some function receives DWORD userData instead of void* userData through some structure and then casts it to an object pointer. This works ok in a 32-bit environment, but crashes in 64-bit.The disassembly of the function calls inside the ocx that cause the crash ar

  • starblue
    assembly x86 executable masm opcode
    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 decryption code. Everything works out great except when I try and JMP to the original EP after decryption.Basically I do this:DWORD originalEntryPoint = optionalHeader->AddressOfEntryPoint; // — snip — //crypted.put(0xE9);crypted.write((char*)&orgin

  • Help I’m in college
    assembly x86 masm
    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 PROCcall divisionexit main ENDPdivision PROCmov eax, 4mov ebx, 2div ebxcall WriteDecret divison ENDPEND mainWhere WriteDec should write whatever number is in the eax register (should be set to the quotient after the division call). Instead everytime I run it visual studio crashes (the program does compile however).

  • Marshall Tigerus
    assembly x86 masm
    I get a crash whenever I execute code that has an array in a procedure, and I’m not sure what I’m doing wrong. I’ve done this succesfully before, but my new implementation makes it fail and crash hard.here’s the part in main that sets up the whole thing:push OFFSET list push OFFSET looper push OFFSET count push tester push OFFSET error_2 push OFFSET error_1 call validate and here’s the part of validate that crashes:mov eax, [ebp + 16]; mov edx, [ebp+28] mov ecx, [ebp+20] mov [edx + 4 * ecx], e

  • Dylan Karr
    assembly compilation linker masm ml
    I’m working on a project for class, and the professor wants us to use MASM instead of any other assembler. (I know thats is stupid, talk to him not me.) When I run ML.exe to compile my code, it crashes. Not the program I’m writing, but the assembler itself. What could possibly cause that? It’s running for a really long time before it goes, so maybe it’s an infinite loop of some sort.Here’s my code:.386 .MODEL FLATPUBLIC compute_b_procpoints EQU [ebp + 16] bs EQU [e

  • Luis Armando
    assembly crash masm
    I’m trying to make a loop in masm32 running under Windows Vista, however I did it this way and even though it actually finishes the loop, it crashes and I see no obvious reason why…any ideas?.386 .model flat, stdcall option casemap :noneinclude \masm32\include\windows.inc include \masm32\include\kernel32.inc include \masm32\include\masm32.inc includelib \masm32\lib\kernel32.lib includelib \masm32\lib\masm32.lib.data ProgramText db “Looping!”, 0.data? loop_stopper dd ?.code start:mov loo

  • starblue
    assembly x86 masm
    I’ve just begun learning some x86 assembly on win32, and I’ve used masm with visual studio 2008 using the custom build rule that comes with the ide for .asm files. I’ve been trying to use the DOS interrupt to print to the console, but instead I receive the message: “Unhandled exception at 0x00401004 in ASMTest.exe: 0xC0000005: Access violation reading location 0xffffffff.” on the 8th line. I’m trying to output the single ascii character ‘A’ (41h) Here is the masm code:.386 .MODEL flat, stdcall.C

  • Jonathan Gleason
    visual-studio assembly visual-studio-2012 masm
    Here is a copy of the source:extrn MessageBoxA: PROC extrn ExitProcess: PROC.data mytit db ‘The 64-bit world of Windows & assembler…’, 0 mymsg db ‘Hello World!’, 0.code main proc mov r9d, 0 ; uType = MB_OK lea r8, mytit ; LPCSTR lpCaption lea rdx, mymsg ; LPCSTR lpText mov rcx, 0 ; hWnd = HWND_DESKTOP call MessageBoxA mov ecx, eax ; uExitCode = MessageBox(…) call ExitProcess main endpEndRight now, I am just trying to get my ‘first’ x64 assembly program up and running

  • NREZ
    visual-studio-2005 masm
    While debugging in \Vvisual Studio 2005 , getting the below error:Unhandled exception at 0x0041421d in text_new.exe: 0xC0000005: Access violation reading location 0x99ac95b4.Code line is: movq mm1, [eax+ecx*2]

  • Nic Young
    visual-studio-2010 assembly x86 nasm masm
    My program is supposed to read an integer n from the user and then calculate all the divisors and if they are prime or not. I am using the Irvine 32 library. Now this is the weird part, when I enter in an even number my program executes as it is supposed to. When I enter in and odd number my program gets the error which is the title of this post.My main Proc:main PROC ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; This block displays greeting and newline; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

  • user1852050
    assembly recursion masm
    I’ve written a program in assembly language (MASM) to allow students to practice calculating combinations. The program calculates the factorials recursively. I use a procedure called combinations which receives n and r, then gets (n=r)!, n!, and r! by calling a procedure called factorial. Factorial is recursive. .data n DWORD ? r DWORD ? result DWORD ? answer DWORD ? divisor DWORD ?.code MAIN PROC(some preliminary procedure calls)push OFFSET divisor ;eb

  • tina nyaa
    assembly masm masm32
    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 Instructions: BT, BTS, BTR, and BTCOn an 80386 or later processor, you can use the bt instruction (bittest) to test a single bit. Its second operand specifies the bit indexinto the first operand. Bt copies the addressed bit into the carryflag. For example

  • Ratz
    assemblies symbols masm
    I’m just starting to learn intel assembly and I’m having trouble with this simple program.main PROC ;program execution begins here A = 1 ;define A with 1 B = 12o ;define B with 12 octal X dword A1h ;initialize the variable X with value A1 hex Y dword 11001001b ;initialize the variable Y with value 11001001 binarySUM dword 0 ;initializes the sum variable to 0 ADD EAX, A ;adds A to sum ADD EAX, B ;adds B to

  • Francisco P.
    assembly masm cpu-registers
    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 DivisionUsage: IDIV srcModifies flags: (AF,CF,OF,PF,SF,ZF undefined)Signed binary division of accumulator by source. If source is abyte value, AX is divided by “src” and the quotient is stored inAL and the remainder in AH. If source is a word value, DX:AX isdivided by “src”, and the quotient is stored in AL and theremainder in DX.T

  • starblue
    x86 assembly masm
    I am trying to assembly this code, but it returns an error. Could you please help me to fix it? Thanks.INCLUDE irvine16.inc .dataarray db 31h,32h,33h,34h ;use db to define arrayCOUNT = ($-array) ;The $ operator gives the value of the location counter. .code main procmov ax, @data ;copy the address of the data segment mov ds, ax ;@data into the DS registermov bx, offset array ;the offset operator returns the 16-bit offset of a labelmov cx, COUNT ;set up cx register as a

  • cab0lt
    string comparison masm
    If I try to assemble the following code, I get a A2006 error ( error A2006: undefined symbol : StrCmp).Here’s my code:.386 .model flat,stdcall option casemap:noneinclude \masm32\include\windows.inc include \masm32\include\kernel32.inc include \masm32\include\masm32.inc include \masm32\include\user32.incincludelib \masm32\lib\kernel32.lib includelib \masm32\lib\masm32.lib includelib \masm32\lib\stdlib.lib includelib \masm32\lib\user32.lib.data YvanSoftware db “(c) YvanSoftware – A

Web site is in building