Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int char_get() {
- int res;
- volatile char c;
- asm volatile(
- "movl %1, %%eax\n"
- "movl %3, %%ebx\n"
- "movl %2, %%ecx\n"
- "movl %4, %%edx\n"
- "int $0x80"
- "movl %%eax, %0"
- : "=g"(res)
- : "g"(__NR_read),
- "g"(&c),
- "g"(0),
- "g"(1)
- : "eax", "ebx", "ecx", "edx", "memory"
- );
- if (res <= 0) {
- return -1;
- }
- if (c >= 'a' && c <= 'z') {
- c = 'A' + c - 'a';
- }
- asm volatile(
- "movl %0, %%eax\n"
- "movl %2, %%ebx\n"
- "movzb %1, %%ecx\n"
- "movl %3, %%edx\n"
- "int $0x80"
- "movl %%eax, %0"
- : : "g"(__NR_write),
- "g"(c),
- "g"(1),
- "g"(1)
- : "eax", "ebx", "ecx", "edx", "memory"
- );
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement