Tuesday 15 April 2014

x86 - Why This NASM Assembly is Not Printing? -


I'm trying to learn NASM assembly (Linux, AT & T syntax), but I get the code given below through the "Hello world" syscall and walk well, but it does not print anything . Any clue why?
  .text .globl main main: movl $ 4,% ex movl $ 1,% ebx movl string1,% ecx movl $ 20,% edx int $ 0x80 .data string 1: string "Hello World"   

UPDATE : I found this. I need to include a $ symbol in front of "string 1", so any clarification of what happens when the line becomes "movl $ string1,% ecx" whenever it is not included?

The syscall you are using is expected in ecx An indicator for This adds the $ - the value of string to value in ecx . If you leave $ , then you are entering the first word in string1 on ecx - numeric value equivalent to hell is the ASCII string (which should be your case) on a small-endian machine, this means that you are entering 0x6c6c6568 in ecx . It is not that this value is a valid indicator for any type of string, so syscall does not print anything. It can be easily crashed or may be due to some other kind of crazy behavior.

No comments:

Post a Comment