0

i've got this code to just print out whatever is in the register ax currently:

.686p 
.xmm
.model flat,c
.stack  4096


; include C libraries
includelib      msvcrtd
includelib      oldnames
includelib      legacy_stdio_definitions.lib


; imported functions
extrn   printf:near


.data ; initialized global vars
IntegerFormat   db  "The result is: %d",0dh,0ah,0


.code
        
public  main

main proc
    ; your logic goes here.
    mov ax, 3
    
    movsx   eax, ax
    push    eax
    push    offset IntegerFormat
    call    printf  ; call printf(IntegerFormat, 3)
    add     esp, 8 

    xor     eax,eax
    ret
main endp

        end

i've created a C++ empty project and added this .asm file. It didn't run, so I did what's written here: Compiling assembly in Visual Studio

And it worked.

But now, whenever I update the code and build, for example i changed mov ax, 3 to mov ax, 4 It still prints out 3. The only way that seems to solve it is setting the item type (in the properites of the .asm file) to does not participate in build, and then do what written in the link I provided again.

Is there any way to change it so it compiles the new code version every time without having to do the process I described above every time?

Thanks in advance!

nortain32
  • 69
  • 1
  • 7
  • Is [Assembly programming - WinAsm vs Visual Studio 2017](https://stackoverflow.com/q/52796300) helpful? Or [external assembly file in visual studio](https://stackoverflow.com/q/33751509). Those are linked from the tag wiki https://stackoverflow.com/tags/x86/info, but I don't use Visual Studio so IDK if those are applicable. If they are, we can probably close this as a duplicate of one of those. (And maybe update the older Q&A you found.) – Peter Cordes Nov 23 '22 at 04:14

0 Answers0