内联装配控制台打印 [英] Inline assembly console print

查看:90
本文介绍了内联装配控制台打印的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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


这篇关于内联装配控制台打印的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆