内联装配控制台打印

编程入门 行业动态 更新时间:2024-10-25 00:27:55
本文介绍了内联装配控制台打印的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

所以,我想制作一个简单的程序来在控制台上打印一个字符串,为了做到这一点,我创建了一个带内联汇编的简单函数,我的意思是,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?"[^].

更多推荐

内联装配控制台打印

本文发布于:2023-11-28 09:03:56,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1641777.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:内联   控制台

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!