Thread: Strcpy Assembly

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    "Hello World" requires at least 13 bytes (that's counting from one), because of the terminating zero. The zero goes into the twelfth subscript.

  2. #2
    The Dragon Reborn
    Join Date
    Nov 2009
    Location
    Dublin, Ireland
    Posts
    629
    Quote Originally Posted by whiteflags View Post
    "Hello World" requires at least 13 bytes (that's counting from one), because of the terminating zero. The zero goes into the twelfth subscript.
    but "Hello World" is 11 characters, +1 for the terminating zero. So 12bytes? counting from 1
    so in assembly it doesn't start from 0....
    I changed it to 13 bytes but i still get a seg fault
    I believe it is this line
    Code:
    movb %cl, (%edi)
    but I don't know why
    You ended that sentence with a preposition...Bastard!

  3. #3
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    Quote Originally Posted by whiteflags View Post
    "Hello World" requires at least 13 bytes (that's counting from one), because of the terminating zero. The zero goes into the twelfth subscript.
    I only count 12 bytes.

    I think you get the crash because you are attempting to write to the .text section. You should declare your copyString in the .data section instead. It's been a long time since I've done any assembly though, so I could be wrong.
    bit∙hub [bit-huhb] n. A source and destination for information.

  4. #4
    The Dragon Reborn
    Join Date
    Nov 2009
    Location
    Dublin, Ireland
    Posts
    629
    oh ja.
    gut idee.
    Will try it out now! Danke!
    You ended that sentence with a preposition...Bastard!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. loading 2 character arrays in a row
    By rivkyfried1 in forum C Programming
    Replies: 4
    Last Post: 12-09-2010, 10:40 AM
  2. C to assembly interface
    By Roaring_Tiger in forum C Programming
    Replies: 4
    Last Post: 02-04-2005, 03:51 PM
  3. assembly language...the best tool for game programming?
    By silk.odyssey in forum Game Programming
    Replies: 50
    Last Post: 06-22-2004, 01:11 PM
  4. True ASM vs. Fake ASM ????
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 04-02-2003, 04:28 AM
  5. C,C++,Perl,Java
    By brusli in forum C Programming
    Replies: 9
    Last Post: 12-31-2001, 03:35 AM