0

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.

Employed Russian
  • 199,314
  • 34
  • 295
  • 362
TheoVate
  • 11
  • 2
  • What tool chain are you using? If you're under e.g. Linux `int 21h` won't work even if translated to AT&T syntax. – user786653 Nov 18 '11 at 12:50
  • No i'm using int 0x80, the code runs. I've just had trouble finding a read no echo syscall in at&t – TheoVate Nov 18 '11 at 12:52
  • That's because it's platform specific. You should include the exact platform you're running under e.g. 32-bit x86 Linux. The answer is going to be the same as for C/C++/etc. and will probably involve tcsetattr. See e.g. [this](http://stackoverflow.com/questions/6856635/hide-password-input-on-terminal) SO question. – user786653 Nov 18 '11 at 13:14
  • I'm using the "as" compiler on linux x86 with AT%T syntax, if that helps. – TheoVate Dec 11 '11 at 17:00
  • What exactly are you having trouble doing? Creating an assembly program? Reading input from that program? Is it just about getting keyboard input without echo? – user786653 Dec 12 '11 at 22:35
  • Just getting input without echo, i tried to research it as best i could but it just ended up as an intel solution. So i really just need the AT&T version of the intel code above. Or a solution that does the same thing. Only in AT&T. Thanks for the responses. – TheoVate Dec 14 '11 at 11:17

1 Answers1

0

Please correct me if I'm wrong:

In AT&T assembly hexadecimal is written C-style: 0x30 instead of 30h. Octals are also like in C, prefixed with a 0.

And depending on what size memory you are manipulating you have to use that size's postfix on the operand. That means movl instead of mov on 32bit long memory:

8 bits = b      - derived from "byte"
16 bits = w     - derived from "word"
32 bits = l     - I have no idea why 16 bits is usually a "dword"
64 bits = q     - derived from "qword", q for "quad-", so four words in size

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:

movl $ah, $0x08
int 0x21

movl $dl, $2ah
movl $ah, $0x02
int $0x21

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:

movl <source>, <dest>

while in Intel syntax this will be:

mov <dest>, <source>

Any corrections are welcome as I'm still learning as well.

Hawken
  • 2,059
  • 19
  • 34