所以,我想制作一个简单的程序来在控制台上打印一个字符串,为了做到这一点,我创建了一个带内联汇编的简单函数,我的意思是,proint一个字符串而不使用windows lib或C / C ++函数,比如printf或cout ....所以,我知道VC ++的宏汇编程序编译器使用masm sintax ...所以,我有这样的:
So, i''m tring to make a simple program to print a string on console, to make this, I have created a simple function with inline assembly, my ideia is, proint a string without use a windows lib or C/C++ functions, like printf or cout.... so, I know the macro assembler compiler of VC++ use the masm sintax... so, I have maded this:
void print(char *msg) { __asm { mov ah, 9 mov dx, msg int 21h } } int main() { print("hello"); return 0; }BUt,我认为使用旧的DOS中断不能正常工作:( 所以,有一种方法,使用printf或cout或c / c ++函数,只需要C和汇编???
BUt, i think the use of old DOS interrupts not work fine :( So, have a way to make this, whiout use printf or cout or c/c++ functions , just C and assembly ???
推荐答案你必须调用 Windows API 。您可以在网上找到一些示例,例如,请查看 Stack Overflow问题:如何在windows下的汇编程序中编写hello world? [ ^ ]。 You have to call Windows API from the assemby language. You may find some examples on the web, for instance check out this Stack Overflow question: "how to write hello world in assembler under windows?"[^].
更多推荐
内联装配控制台打印
发布评论