Like Tree6Likes
  • 1 Post By brewbuck
  • 1 Post By Subsonics
  • 2 Post By Elkvis
  • 2 Post By Fordy

asm asciz question

This is a discussion on asm asciz question within the Tech Board forums, part of the Community Boards category; Bellow is the example that I am going to use. The bellow code should compile on GNU assembler. Syntax is ...

  1. #1
    Registered User
    Join Date
    Dec 2011
    Posts
    69

    asm asciz question

    Bellow is the example that I am going to use.


    The bellow code should compile on GNU assembler. Syntax is AT&T incase any numbies are curious.
    Code:
    .data 
    
    
    HelloWorldString:
    	.asciz "Hello"
    
    
    .text 
    
    
    .globl _start 
    
    
    _start:
    	# Load all the arguments for write () 
    
    
    	movl $4, %eax
    	movl $1, %ebx
    	movl $HelloWorldString, %ecx
    	movl $6, %edx #<-- This is where the number matters.
    	int $0x80
    
    
    	# Irrelivant. Just the exit syscall
    	movl $1, %eax
    	movl $0, %ebx
    	int $0x80
    Okay, I am using the write syscall. Did I do it correctly? Would I have to allocate 6 bytes of space(like I did), instead of just five? Because of the NUL? Thanks.

  2. #2
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,269
    It's not C, there is no need for the string to be null terminated, nor to send a null character at the end of the string (in fact, it's probably wrong to do so)
    Salem likes this.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  3. #3
    Registered User
    Join Date
    Dec 2011
    Posts
    69
    Are you ........ing kidding me? Where did you learn ASM?
    Last edited by inu11byte; 10-16-2012 at 03:58 AM.

  4. #4
    Registered User
    Join Date
    Jan 2009
    Posts
    1,485
    In this case you use the write system call, it's not a string function and does not rely on a terminating zero, instead it writes the amount of bytes you give as an argument. Let's call it from C.

    Code:
    int main()
    {
        const char *s = "Hello";
    
        write(STDOUT_FILENO, s, 5);
    
        return 0;
    }
    Salem likes this.

  5. #5
    Registered User
    Join Date
    Oct 2006
    Posts
    2,578
    Quote Originally Posted by inu11byte View Post
    Are you ........ing kidding me? Where did you learn ASM?
    do you really think you're going to get useful help by responding to people that way?
    Salem and anduril462 like this.

  6. #6
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    Quote Originally Posted by inu11byte View Post
    Are you ........ing kidding me? Where did you learn ASM?
    Where did you learn it if you need to run to a forum for a bit of code that makes 2 system calls?

  7. #7
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,269
    Quote Originally Posted by inu11byte View Post
    Are you ........ing kidding me? Where did you learn ASM?
    I'm glad that my response has put you in a state of awe, but seriously... The compliments are unnecessary.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  8. #8
    Registered User
    Join Date
    Dec 2011
    Posts
    69
    Okay, I'm sorry, I shouldn't have replied like that. :/ I understand you were just trying to help. Anyway, if I was shifting that variable to another area of memory, would that area of memory have to have 6 bytes of space, or just 5?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 1
    Last Post: 03-23-2011, 10:00 AM
  2. *szString = things question/memory question
    By Jang in forum C Programming
    Replies: 3
    Last Post: 01-20-2011, 04:59 AM
  3. Newbish Question file reading question....
    By kas2002 in forum C Programming
    Replies: 23
    Last Post: 05-17-2007, 01:06 PM
  4. java question, how do you interpret this question.
    By indigo0086 in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 11-02-2006, 10:30 AM
  5. Self regiserting DLLs question and libraries question.
    By ApocalypticTime in forum Windows Programming
    Replies: 2
    Last Post: 03-22-2003, 02:02 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21