Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

Mahlatse1 Group Title

how to make a while loop in assembly?

  • one year ago
  • one year ago

  • This Question is Closed
  1. slotema Group Title
    Best Response
    You've already chosen the best response.
    Medals 3

    You'll need something like the following structure: label: <loop body> ... <loop condition check> <conditional branch to 'label'> <loop's finished here>

    • one year ago
  2. Mahlatse1 Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    can u please show me with a simple example that does all those things

    • one year ago
  3. slotema Group Title
    Best Response
    You've already chosen the best response.
    Medals 3

    which architecture? X86, amd64, MIPS?

    • one year ago
  4. Mahlatse1 Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    x86

    • one year ago
  5. slotema Group Title
    Best Response
    You've already chosen the best response.
    Medals 3

    Here a simple example that calculates 2 * n: movl $0, %eax # i = 0 movl $0, %ebx # result = 0 movl $10, %ecx # n = 10 jmp check # without this jmp, it'd be a do-while loop loop: addl $2, %ebx # result = 2 * result addl $1, %eax # i++ check: cmp %ecx, %eax jl loop # Jump if i < n Btw, most compilers can also output assembly code. If you compile some C-code with gcc, you need to add the `-S` flag. Then, gcc will only generate ASM for you.

    • one year ago
  6. walters Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    wat are this ( $)

    • one year ago
  7. Mahlatse1 Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    i'm getting errors

    • one year ago
    1 Attachment
  8. slotema Group Title
    Best Response
    You've already chosen the best response.
    Medals 3

    There are two different syntaxes for writing x86 ASM: AT&T and Intel. The code I wrote is in AT&T syntax while your assembler probably expects Intel syntax. @walters The $ is part of the AT&T syntax to indicate an immediate (or constant) value. % indicates a register. A quick (but not tested yet) rewrite: mov eax, 0 mov ebx, 0 mov ecx, 10 jmp check loop: add ebx, 2 add eax. 1 check: cmp eax, ecx jl loop

    • one year ago
  9. AuthenticationError Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    that is why u have to analyse numbers correctly u'll get it

    • one year ago
  10. walters Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    @slotema i get it

    • one year ago
  11. Mahlatse1 Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    OOOH! I SEE IT! @slotema

    • one year ago
  12. Mahlatse1 Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    @AuthenticationError WHAT DO YOU MEAN BY Numbers?

    • one year ago
  13. walters Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    so using assembly @slotema how to do modulus because this is giving me errors a mod b

    • one year ago
  14. walters Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    like looping if x is even is'nt i have to do modulus like in c and c+

    • one year ago
  15. slotema Group Title
    Best Response
    You've already chosen the best response.
    Medals 3

    If you really have different questions, you should start a new thread, so Mahlatse1 won't get a lot of notifications. For modulo, you'll need to do a division. After e.g. `div eax, ebx`, eax will contain the quotient and edx will contain the remainder. But divisions are costly. If you just want to check whether or not a number is even, there are faster ways of doing that. Like checking the LSB of the number (if it's 1, the number is odd).

    • one year ago
    • Attachments:

See more questions >>>

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.