AT&T 组装屏蔽输入
我正在尝试在 AT&T Assembly 中创建一个简单的密码程序,但在屏蔽输入方面遇到问题。我想要发生的是当用户输入字符时,它们在屏幕上显示为星号'。在 intel 语法中,它相对简单:
mov ah, 08h
int 21h
mov dl,2ah
mov ah,02h
int 21h
它使用 intel 命令读取输入而不回显它,而是打印星号。 我正在尝试用 AT&T 语法解决这个问题,但遇到了一些麻烦。
任何意见将不胜感激。 提前致谢。
I'm trying to create a simple password program in AT&T Assembly but i'm having trouble with masking an input. What i want to happen is when the user enters characters, they appear on the screen as asterisk'. In intel syntax it's relatively simple:
mov ah, 08h
int 21h
mov dl,2ah
mov ah,02h
int 21h
This uses the intel command to read an input without echoing it and instead print an asterisk.
I'm trying to solve this problem in AT&T syntax and I'm having some trouble.
Any input would be greatly appreciated.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我错了,请纠正我:
在 AT&T 汇编中,十六进制是 C 风格的:
0x30
而不是30h
。八进制也类似于 C 语言,以0
为前缀。根据您要操作的内存大小,您必须在操作数上使用该大小的后缀。这意味着在 32 位长内存上用
movl
而不是mov
:值也以美元符号为前缀:
$0x41
(变量也是如此?)寄存器以百分号为前缀:%eax
。因此,如果我正确地阅读了此内容,您的代码应该是:
我不敢相信我在编写答案时错过了这一点,AT&T 语法已颠倒了具有两个输入的指令的源-目标顺序。
即 AT&T 是:
而在英特尔语法中,这将是:
欢迎任何更正,因为我也在学习。
Please correct me if I'm wrong:
In AT&T assembly hexadecimal is written C-style:
0x30
instead of30h
. Octals are also like in C, prefixed with a0
.And depending on what size memory you are manipulating you have to use that size's postfix on the operand. That means
movl
instead ofmov
on 32bit long memory:Also values are prefixed with a dollar sign:
$0x41
(as are variables?) and registers are prefixed with percent signs:%eax
.So if I'm reading this correctly your code should be:
I can't believe I missed this when I wrote the answer, AT&T syntax has reversed source-destination order for instructions with two inputs.
I.e. AT&T is:
while in Intel syntax this will be:
Any corrections are welcome as I'm still learning as well.