;programul citeste de la tastatura doua numere intregi si le afiseaza.
.386 ;folosim instructiuni cu operanzi pe 32 biti
.MODEL FLAT, C ;memoria este organizata liniar si conventia de apel a functiilor este cea din C
.STACK 100h ;dimensunea stivei alocate
printf PROTO arg1:ptr BYTE, printlist:VARARG
scanf PROTO arg2:ptr BYTE, inputlist:VARARG ;prototipurile functiilor printf si scanf
.DATA
format1 BYTE "%s",0
format2 BYTE "%d",0
format3 BYTE "%s %04d si %04d",10,0
mesaj1 BYTE "Introduceti numerele:",0Ah,0
mesaj2 BYTE "num1=",0
mesaj3 BYTE "num2=",0
mesaj4 BYTE 0Ah,"Numerele sunt: ",0
num1 SDWORD ? ;sdword=signed double word --> numar de 32 de biti cu semn; echivalentul int
num2 SDWORD ?
.CODE
main PROC
;printf("%s","Introduceti numerele:\n");
INVOKE printf, ADDR format1, ADDR mesaj1
;printf("%s","num1=");
;scanf("%d",&num1);
;printf("%s","num2=");
;scanf("%d",&num2);
;printf("%s %d si %d\n","\nNumerele sunt:",num1,num2);
INVOKE printf, ADDR format1,ADDR mesaj2
INVOKE scanf, ADDR format2,ADDR num1
INVOKE printf, ADDR format1,ADDR mesaj3
INVOKE scanf, ADDR format2,ADDR num2
INVOKE printf, ADDR format3, ADDR mesaj4, num1, num2
ret
main ENDP
END
按调试后,我有 3 个错误: 1>main.obj:错误 LNK2019:未解析的外部符号 _printf 在函数 _main 中引用 1>main.obj:错误 LNK2019:未解析的外部符号 _scanf 在函数 _main 1>LINK 中引用:错误 LNK2001 : 未解析的外部符号 _mainCRTStartup
我还想补充一点,我从 Builder Dependencies 中选择了 masm,并在 Linker Input 中添加了库 msvcrt.lib 和 legacy_stdio_definitions.lib。你知道可能是什么问题吗?