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 7697897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:06:59+00:00 2026-05-31T22:06:59+00:00

I read a book that write the next program in C, and convet the

  • 0

I read a book that write the next program in C, and convet the call of this function to assembler code:

int *p;    /* pointer to integer */
int foo (int n, int *q) {}
/* function get int and pointer to int, returns int */
/* Now, let's call the function: */    
*p = foo (*p, p);

It convert to:

MOV EBX, [P]
PUSH EBX
PUSH DWORD [EBX]
CALL foo
MOV EBX, [P]
MOV [EBX], EAX
ADD ESP, 8

I didn’t understood why it is correct, as I understood it the code should looks like this:

MOV EBX, P   ;; **CHANGE**
PUSH EBX
PUSH DWORD [EBX]
CALL foo
MOV EBX, P ;; **CHANGE**
MOV [EBX], EAX
ADD ESP, 8

and that because P is a pointer. If we do MOV EBX, [P], as the book suggest, we got the integer number (Not the adress), and then if we do PUSH DWORD [EBX], we got illigal instruction.

Where i’m wrong?

  • 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-31T22:07:01+00:00Added an answer on May 31, 2026 at 10:07 pm

    P is a label, which equates to the address of a variable (your pointer variable). [P] would be the value at that address, which is the pointer.

    Note, though, some assemblers do things a bit differently. NASM and its derivatives are pretty strict about brackets and such. MASM, not so much; there are times it will let you treat a label almost as if it were a variable in its own right.

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

Sidebar

Related Questions

I read a book that uses infix, infixr, and infixl in the sample programs.
I want to read a book that systematically introduces dom with live examples. Any
A few years ago, I read a book that described how you could override
My buddy read an OpenGL book that said interleaving your vertex pointers and the
I have read in a Java book that says: Because a String is immutable,
I read in the Essential C# 3.0 and .NET 3.5 book that: GetHashCode()’s returns
I was fairly sure that I had read (in Richter's C# book) that objects
History: I read from one of Knuth's algorithm book that first computers used the
Is there any book or links that I can read some tutorial about the
The next few lines I'm going to write come from the book The C++

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.