Microsoft (R) Macro Assembler Version 9.00.30729.01 and visual c++2008 express

Started by eleCtroNics_23, April 20, 2012, 10:52:47 AM

Previous topic - Next topic

eleCtroNics_23

Hi all!

I have code....

.386
.model flat, c
.stack 100 h
printf PROTO arg1:Ptr Byte, printlist:VARARG
.data
msg1fmt byte "%s%d",0Ah,0
msg1 byte "The answer is: ",0
num1 sdword ?
num2 sdword ?
.code
main proc
mov num1,5
mov eax,num1
mov num2,eax
INVOKE printf, ADDR msg1fmt, ADDR msg1, num2
ret
main endp
end


..........and following command line in custom build step
ml -c -Zi "-Fl$(IntDir)\$(InputName).lst" "-Fo$(IntDir)\$(InputName).obj" "$(InputPath)"


...it comes errors like:
temp.asm(3) error A2206:missing operator in expression
temp.asm(2) : error A2206:missing operator in expression
1>Microsoft (R) Macro Assembler Version 9.00.30729.01
1>Copyright (C) Microsoft Corporation.  All rights reserved.
1>Project : error PRJ0019: A tool returned an error code from "Performing Custom Build Step"
1>Asm - 1 error(s), 0 warning(s)

SteveAsm

First, you need to include the header files, (see listing below).


printf PROTO arg1:Ptr Byte, printlist:VARARG


printf does not need a prototype.


.386
.model flat, stdcall
option casemap:none

include \masm32\include\masm32.inc
include \masm32\include\crtdll.inc

includelib \masm32\lib\masm32.lib
includelib \masm32\lib\crtdll.lib

.data
    msg1fmt db  "%s%d",0Ah,0
    msg1    db  "The answer is: ",0

.data?
    num1 sdword ?
    num2 sdword ?

.code
start:

main proc
  mov num1, 5
  mov eax, num1
  mov num2, eax
  INVOKE printf, ADDR msg1fmt, ADDR msg1, num2
  call _getch   ; pause
   
  ret
main endp
end start



I made a few critical changes to your code, to make it work.
As I stated, you need to include the headers for function you intend to use.

hutch--

The current version of MASM32 directly supports "printf" for condsole output.


printf("%d\t%d\t%Xh\n", 123, 456, 1024);
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php