Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7623741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:46:49+00:00 2026-05-31T04:46:49+00:00

I read a book, which give the next example: There is a list, which

  • 0

I read a book, which give the next example:
There is a list, which each member has the next member’s adress in it four first bytes. The last member has the value of 0. It say that the next implementation is wrong, and I don’t understand why:

freeList
   mov eax, [ebp+8]
   cmp eax, 0
   jne cont
   ret
cont:
   mov ebx, [eax]
   mov [ebp+8], ebx
   push eax
   call free
   pop eax
   call freeList

(I don’t need the correct implementation, I have one. I just need to understand what wrong with this one)

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T04:46:50+00:00Added an answer on May 31, 2026 at 4:46 am

    The last line of the incorrect implementation is call freeList. But when the (recursive) call completes, it will try to return to the non-existent code after that line. Appending a ret instruction would make the code work, but normally you try to avoid that except when debugging code in which case it sometimes helps to be able to see all the intermediate calls. Instead you can simplify the call freeList; ret to a simple jmp freeList.

    Example of debugging high-level code:

    function freeList(list) {
        if (list) {
            var next = list->next;
            free(list);
            freeList(next);
        }
    }
    

    If you compile with optimisations, the compiler may want to write the recursive call to freeList(next) by coping next to list and performing a jmp, however this would destroy the value of list. This means that when you try to debug the function you can’t tell what elements of the list have already been freed. So you would want to disable this optimisation when you are trying to debug a problem in the function.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I read a book about assembly, which have the next code. The code comapre
I read a book that write the next program in C, and convet the
I am Newbie to C++ and Looking for some book/URL which has lot of
I read a book that uses infix, infixr, and infixl in the sample programs.
I read the book Algorithm Design, chapter 1, it gave a very short description
I've read the book Programming Collective Intelligence and found it fascinating. I'd recently heard
When I read the book Code Complete, the word construction is referenced frequently. What
I want to read a book that systematically introduces dom with live examples. Any
Recently I read a book( CleanCode ) in this book, FUNCTION SHOULD DO ONE
I've read this book section about git branches. I have create a branch called

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.