;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
按下debug后,出现3个错误:1〉主要对象:错误LNK2019:在function _main 1〉main.obj中引用了未解析的外部符号_printf:错误LNK2019:function _main 1〉LINK中引用了未解析的外部符号_scanf:错误LNK2001:未解析的外部符号_mainCRTStartup
我还想补充的是,我从构建器依赖项中选择了masm,并在链接器输入中添加了库msvcrt.lib和legacy_stdio_definitions.lib。
1条答案
按热度按时间yyhrrdl81#
正如@RbMn指出:将msvcrt.lib和/或libcmt.lib添加到链接器搜索路径中。