开发者

Problem with output, doesn't read jump

.section .data
msgI:
 .ascii "x = y\n"
msgI_end:


msgM:
 .ascii "x > y\n"
msgM_end:


msgL:
 .ascii "x < y\n"
msgL_end:


.section .text
.globl main
main:
    movl $5, %eax            #x = 5
    movl $5, %ebx            #y = 10
    cmp %ebx, %eax

    je IGUAL

    jg  MAYOR开发者_如何学C

    jl  MENOR

IGUAL:                       #Esta seccion de cogido se encarga
    movl $4, %eax            #de imprimir si x = y usando       
    movl $1, %ebx            #los system calls de Linux     
    pushl $msgI
    call printf             
    #movl $size, %edx           
    int $0x80                           
    jmp EXIT

MAYOR:                       #Esta seccion de cogido se encarga
    movl $4, %eax            #de imprimir si x > y usando       
    movl $1, %ebx            #los system calls de Linux     
    pushl $msgM
    call printf             
    #movl $size, %edx           
    int $0x80                           
    jmp EXIT

MENOR:                       #Esta seccion de cogido se encarga
    movl $4, %eax            #de imprimir si x < y usando       
    movl $1, %ebx            #los system calls de Linux     
    pushl $msgL
    call printf             
    #movl $size, %edx           
    int $0x80                           
    jmp EXIT

EXIT:
    movl $1, %eax            #System calls para salir del programa
    int $0x80


    movl $5, %ebx                    #y = 10

Code does not match comments.

    int $0x80                                                   
    jmp EXIT

Why are you calling the interrupt? printf is already done printing, and has overwritten registers like %eax.

Now, the reason why you're getting your messages all jumbled together: printf takes a NUL-terminated string. If it doesn't see a '\0', it keeps on going.

Solution: add a \0 to the end of your msg* strings. printf will then stop printing there.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜