📜  att asm stdin - 任何代码示例

📅  最后修改于: 2022-03-11 14:58:31.286000             🧑  作者: Mango

代码示例1
.text
        .global _start
_start:
        # read(STDIN_FILENO, buf, 1)
        movl    $1, %edx    # size_t nbyte
        movl    $buf, %ecx  # void *buf
        movl    $0, %ebx    # int filedes
        movl    $3, %eax    # sys_read
        int     $0x80

        cmp     $1, %eax    
        jne     bye         # EOF or read() error

        cmp     $'A', (%ecx)
        jl      output      # *buf < 'A'

        cmp     $'Z', (%ecx)
        jg      output      # *buf > 'Z'
        je      z           # *buf == 'Z'

        incl    (%ecx)      # *buf >= 'A' && *buf < 'Z'
        jmp     output

z:
        movl    $'A', (%ecx)

output:
        # write(STDOUT_FILENO, buf, 1)
        movl    $1, %ebx    # int filedes
        movl    $4, %eax    # sys_write
        int     $0x80
        jmp     _start

bye:
        # exit(0)
        movl    $0, %ebx    # int status
        movl    $1, %eax    # sys_exit
        int     $0x80

.data
buf:
        .byte 0