在vc中win32 console32 application下编译,如何使此程序能编译通过呀?
#include <stdio.h>
_TEXT SEGMENT BYTE PUBLIC 'CODE';
_TEXT ENDS
_DATA SEGMENT WORD PUBLIC 'DATA';
_DATA ENDS
_BSS SEGMENT WORD PUBLIC 'BSS';
_BSS ENDS
DGROUT GROUP_DATA,_BSS;
ASSUME CS:_TEXT,DS:DGROUT;SS:DGROUP
_DATA SEGMENT
PUBLIC _num
_num DW 0
_DATA ENDS
_TEXT SEGMENT
PUBLIC _incnum
_incnum PROC NEAR
PUSH BP
MOV BP,SP
INC _mun
MOV SP,BP
POP BP
RET
_incnum ENDP
_TEXT ENDS
END
extern int num;
extern int incnum(void);
void main(void)
{int i;
for(i=0;i<10;i++)
{
incmun();
printf("%d",num);
}
}
9 个解决方案
#1
TURBO C支持程序内嵌汇编子程序,VC下的WIN32 APPLICATION支持吗
#2
incnum.asm:
_TEXT SEGMENT BYTE PUBLIC 'CODE';
_TEXT ENDS
_DATA SEGMENT WORD PUBLIC 'DATA';
_DATA ENDS
_BSS SEGMENT WORD PUBLIC 'BSS';
_BSS ENDS
DGROUT GROUP_DATA,_BSS;
ASSUME CS:_TEXT,DS:DGROUT;SS:DGROUP
_DATA SEGMENT
PUBLIC _num
_num DW 0
_DATA ENDS
_TEXT SEGMENT
PUBLIC _incnum
_incnum PROC NEAR
PUSH BP
MOV BP,SP
INC _mun
MOV SP,BP
POP BP
RET
_incnum ENDP
_TEXT ENDS
END
TURBO C中直接调用incnum函数就行了,在vc下该如何做呀?
_TEXT SEGMENT BYTE PUBLIC 'CODE';
_TEXT ENDS
_DATA SEGMENT WORD PUBLIC 'DATA';
_DATA ENDS
_BSS SEGMENT WORD PUBLIC 'BSS';
_BSS ENDS
DGROUT GROUP_DATA,_BSS;
ASSUME CS:_TEXT,DS:DGROUT;SS:DGROUP
_DATA SEGMENT
PUBLIC _num
_num DW 0
_DATA ENDS
_TEXT SEGMENT
PUBLIC _incnum
_incnum PROC NEAR
PUSH BP
MOV BP,SP
INC _mun
MOV SP,BP
POP BP
RET
_incnum ENDP
_TEXT ENDS
END
TURBO C中直接调用incnum函数就行了,在vc下该如何做呀?
#3
一样的方法
#4
我这样做不行呀
#5
我不行!只能up了!
#6
我再up
#7
up!
#8
楼主这样写是用了16位汇编的格式吧
在VC里面直接内嵌汇编就完了
不愿意的话就编译完了再LINK在一起
在VC里面直接内嵌汇编就完了
不愿意的话就编译完了再LINK在一起
#9
#include <windows.h>
char szAppName[] = "API Test";
void main()
{
char szHello[] = "Hello, world!";
__asm
{
PUSH MB_OK OR MB_ICONINformATION
PUSH OFFSET szAppName ; 全局变量用OFFSET
LEA EAX, szHello ; 局部变量用LEA
PUSH EAX
PUSH 0
CALL DWORD PTR [MessageBoxA] ; 注意这里,我费了好大周折才发现不是CALL
MessageBoxA
}
}
#1
TURBO C支持程序内嵌汇编子程序,VC下的WIN32 APPLICATION支持吗
#2
incnum.asm:
_TEXT SEGMENT BYTE PUBLIC 'CODE';
_TEXT ENDS
_DATA SEGMENT WORD PUBLIC 'DATA';
_DATA ENDS
_BSS SEGMENT WORD PUBLIC 'BSS';
_BSS ENDS
DGROUT GROUP_DATA,_BSS;
ASSUME CS:_TEXT,DS:DGROUT;SS:DGROUP
_DATA SEGMENT
PUBLIC _num
_num DW 0
_DATA ENDS
_TEXT SEGMENT
PUBLIC _incnum
_incnum PROC NEAR
PUSH BP
MOV BP,SP
INC _mun
MOV SP,BP
POP BP
RET
_incnum ENDP
_TEXT ENDS
END
TURBO C中直接调用incnum函数就行了,在vc下该如何做呀?
_TEXT SEGMENT BYTE PUBLIC 'CODE';
_TEXT ENDS
_DATA SEGMENT WORD PUBLIC 'DATA';
_DATA ENDS
_BSS SEGMENT WORD PUBLIC 'BSS';
_BSS ENDS
DGROUT GROUP_DATA,_BSS;
ASSUME CS:_TEXT,DS:DGROUT;SS:DGROUP
_DATA SEGMENT
PUBLIC _num
_num DW 0
_DATA ENDS
_TEXT SEGMENT
PUBLIC _incnum
_incnum PROC NEAR
PUSH BP
MOV BP,SP
INC _mun
MOV SP,BP
POP BP
RET
_incnum ENDP
_TEXT ENDS
END
TURBO C中直接调用incnum函数就行了,在vc下该如何做呀?
#3
一样的方法
#4
我这样做不行呀
#5
我不行!只能up了!
#6
我再up
#7
up!
#8
楼主这样写是用了16位汇编的格式吧
在VC里面直接内嵌汇编就完了
不愿意的话就编译完了再LINK在一起
在VC里面直接内嵌汇编就完了
不愿意的话就编译完了再LINK在一起
#9
#include <windows.h>
char szAppName[] = "API Test";
void main()
{
char szHello[] = "Hello, world!";
__asm
{
PUSH MB_OK OR MB_ICONINformATION
PUSH OFFSET szAppName ; 全局变量用OFFSET
LEA EAX, szHello ; 局部变量用LEA
PUSH EAX
PUSH 0
CALL DWORD PTR [MessageBoxA] ; 注意这里,我费了好大周折才发现不是CALL
MessageBoxA
}
}