一个简单的;“你好,世界”;C/C++;
我使用devcpp和borlandc编译器一个简单的;“你好,世界”;C/C++;,c,assembly,x86,inline-assembly,C,Assembly,X86,Inline Assembly,我使用devcpp和borlandc编译器 asm { mov ax,4 // (I/O Func.) mov bx,1 // (Output func) mov cx,&name // (address of the string) mov dx,6 // (length of the string) int 0x21 // system call } 在上面的代码片段中,我想在汇编语言的
asm {
mov ax,4 // (I/O Func.)
mov bx,1 // (Output func)
mov cx,&name // (address of the string)
mov dx,6 // (length of the string)
int 0x21 // system call
}
在上面的代码片段中,我想在汇编语言的帮助下打印一个字符串。。。
但是如何将字符串的地址放入寄存器cx
代码中有什么错误吗?只需将变量名放在那里:
mov ax,4 // (I/O Func.)
mov bx,1 // (Output func)
mov cx,name // (address of the string)
mov dx,6 // (lenght of the string)
int 0x21 // system call
免责声明:我不太擅长汇编。我手边没有Borland编译器,所以我可能记错了它的语法,但您是否尝试过:
asm {
mov ax,4 // (I/O Func.)
mov bx,1 // (Output func)
lds cx,"Hello, world" // (address of the string)
mov dx,6 // (length of the string)
int 0x21 // system call
}
或者这个:
char msg[] = "Hello, world";
asm {
mov ax,4 // (I/O Func.)
mov bx,1 // (Output func)
lds cx, msg // (address of the string)
mov dx,6 // (length of the string)
int 0x21 // system call
}
编辑:尽管这将被编译(现在我已经将MOV更改为LDS),但它仍然会在运行时抛出错误。我会再试一次…0x21-非常感谢您了解基本知识:-)字符串是如何存储的?i、 e:name的声明是什么?我建议忽略16位实模式汇编程序,直接从32位汇编程序开始。这几天要容易得多,实用得多。。。。但是有没有办法获取字符串的地址并放回cx寄存器。。。或者你曾经尝试过内联汇编。。。我只需要一点帮助…这样我就可以从asm开始。。。有什么例子吗???没有,没用。。。它给出了错误。。。。。。。。是否有其他方法可以获取字符串的地址..然后将其放回cx寄存器..据我所知,
mov-cx,msg
将msg
的地址放入cx
寄存器。你得到了什么?@vs4vijay你不应该接受不工作的解决方案作为答案,因为它是错误的。