Thread: C Programming and Assembly

  1. #1
    Registered User
    Join Date
    Nov 2017
    Posts
    4

    C Programming and Assembly

    Hello, if anyone knows about assembly and C, I would appreciate you to help me in this:
    Let's say I have the following assembly codes:

    Code:
    
    F1:
    lea ex, [0+rdi*16]
    ret
    
    F2:
    movzx eax, BYTE PTR [rdi+4]
    ret
    
    F3:
    mov eax, DWORD PTR [rdi+16]
    ret
    
    F4:
    mov eax,edi
    sal eax,2
    ret
    
    Now I have the following C codes:
    
    int scooby(int* a){
    return a[4];
    }
    
    int scrappy(char*a)
    {
    return a[4];
    }
    
    
    Which assembly function corresponds with its C function?
    Last edited by XavierPacheco; 11-09-2017 at 09:36 PM.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    37,765
    gcc -c -s prog.c
    and take a look at what the compiler produces.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. ASSEMBLY LEVEL Programming
    By kiwi101 in forum C Programming
    Replies: 6
    Last Post: 09-15-2013, 06:29 PM
  2. Assembly Programming...
    By Junior89 in forum Tech Board
    Replies: 35
    Last Post: 04-22-2007, 02:01 PM
  3. Inline Assembly programming
    By steevo in forum C Programming
    Replies: 10
    Last Post: 09-29-2006, 01:37 PM
  4. debug and assembly programming
    By akhitesh in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 09-27-2003, 01:59 AM
  5. Assembly Programming
    By Korn1699 in forum A Brief History of Cprogramming.com
    Replies: 22
    Last Post: 06-06-2002, 11:54 AM

Tags for this Thread