Question

I need help writing an x86 assembly language program that asks for a number and prints...

I need help writing an x86 assembly language program that asks for a number and prints from 1 to that number using a loop?
0 0
Add a comment Improve this question Transcribed image text
Answer #1

X86-64 GCC 9.3 code:

std::ios_base::Init::Init()@plt:

jmp    QWORD PTR [rip+0x2fca]        # 404030 <std::ios_base::Init::Init()@GLIBCXX_3.4>

push   0x3

jmp    401020 <.plt>

std::ostream::operator<<(int)@plt:

jmp    QWORD PTR [rip+0x2fc2]        # 404038 <std::ostream::operator<<(int)@GLIBCXX_3.4>

push   0x4

jmp    401020 <.plt>

std::ios_base::Init::~Init()@plt:

jmp    QWORD PTR [rip+0x2fba]        # 404040 <std::ios_base::Init::~Init()@GLIBCXX_3.4>

push   0x5

jmp    401020 <.plt>

main:

push   rbp

mov    rbp,rsp

sub    rsp,0x10

mov    esi,0x402005

mov    edi,0x404060

call   401050 <std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)@plt>

lea    rax,[rbp-0x8]

mov    rsi,rax

mov    edi,0x404180

call   401030 <std::istream::operator>>(int&)@plt>

mov    DWORD PTR [rbp-0x4],0x1

mov    eax,DWORD PTR [rbp-0x8]

cmp    DWORD PTR [rbp-0x4],eax

jg     4011cb <main+0x59>

mov    eax,DWORD PTR [rbp-0x4]

mov    esi,eax

mov    edi,0x404060

call   401070 <std::ostream::operator<<(int)@plt>

mov    esi,0x402016

mov    rdi,rax

call   401050 <std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)@plt>

add    DWORD PTR [rbp-0x4],0x1

jmp    4011a1 <main+0x2f>

mov    eax,0x0

leave  

ret    

_GLOBAL__sub_I_main:

push   rbp

mov    rbp,rsp

mov    esi,0xffff

mov    edi,0x1

call   4011d2 <__static_initialization_and_destruction_0(int, int)>

pop    rbp

ret    

nop    WORD PTR cs:[rax+rax*1+0x0]

nop

if you like the answer please provide a thumbs up

Add a comment
Know the answer?
Add Answer to:
I need help writing an x86 assembly language program that asks for a number and prints...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT