Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

If someone could help me with this!!

Hi,

I have got this code working, but how can I find that it's giving me the right answer. I have tried like doing arithmetic on paper but I get different answer and gdb debugger gives me different answer. So if some one could help me than that would be great, I will really appreciate it.

Okay, the code is:

.text
.globl main

main: pushl %ebp #save caller's base pointer
movl %esp, %ebp #establish our base pointer

movb $0xff, %al
movb $0xff, %dl
movb $0x12, %al
movb $0x34, %dl
addb %al, %dl

movb $0xff, %al
movb $0xff, %dl
movb $0x72, %al
movb $0x68, %dl
subb %al, %dl

movb $0xff, %ah
movb $0xff, %dh
movb $0xee, %ah
movb $0xdd, %dh
addb %ah, %dh

movb $0xff, %ah
movb $0xff, %dh
movb $0x85, %ah
movb $0x87, %dh
subb %ah, %dh

movl $0xffff, %eax
movl $0xffff, %edx
movl $0x1234, %eax
movl $0x3456, %edx
addl %eax, %edx

movl $0, %eax #return 0 to caller
movl %ebp, %esp #restore stack pointer
popl %ebp #restore caller's base pointer
ret #back to caller

Please if somebody could like work this out on debugger and than tell me about my answer than please reply soon.

Thank you,

Ami

Comments

  • frizzzfrizzz Member Posts: 49
    : Hi,
    :
    : I have got this code working, but how can I find that it's giving me the right answer. I have tried like doing arithmetic on paper but I get different answer and gdb debugger gives me different answer. So if some one could help me than that would be great, I will really appreciate it.
    :
    : Okay, the code is:
    :
    : .text
    : .globl main
    :
    : main: pushl %ebp #save caller's base pointer
    : movl %esp, %ebp #establish our base pointer
    :
    : movb $0xff, %al
    : movb $0xff, %dl
    : movb $0x12, %al
    : movb $0x34, %dl
    : addb %al, %dl
    :
    : movb $0xff, %al
    : movb $0xff, %dl
    : movb $0x72, %al
    : movb $0x68, %dl
    : subb %al, %dl
    :
    : movb $0xff, %ah
    : movb $0xff, %dh
    : movb $0xee, %ah
    : movb $0xdd, %dh
    : addb %ah, %dh
    :
    : movb $0xff, %ah
    : movb $0xff, %dh
    : movb $0x85, %ah
    : movb $0x87, %dh
    : subb %ah, %dh
    :
    : movl $0xffff, %eax
    : movl $0xffff, %edx
    : movl $0x1234, %eax
    : movl $0x3456, %edx
    : addl %eax, %edx
    :
    : movl $0, %eax #return 0 to caller
    : movl %ebp, %esp #restore stack pointer
    : popl %ebp #restore caller's base pointer
    : ret #back to caller
    :
    : Please if somebody could like work this out on debugger and than tell me about my answer than please reply soon.
    :
    : Thank you,
    :
    : Ami
    :
    : I can't help You in the way You think.
    But I just published an OS, written in nasm, that is meant to be helpful in every case of testing code or machine. Look at my homepage www.rfriz.de
    or contact me at asmos@rcfriz.de
    frizzz
Sign In or Register to comment.