Sponsored Content
Full Discussion: Understanding Assembly Code
Top Forums Programming Understanding Assembly Code Post 302931995 by Azrael on Sunday 18th of January 2015 01:04:54 AM
Old 01-18-2015
Understanding Assembly Code

As the title suggests, I want to better understand the following assembly code:

Code:
section .text
    global main          ; must be declared for linker (gcc)
main:                        ; tell linker entry point
    mov    edx, len     ; message length
    mov    ecx, msg    ; message to write
    mov    ebx, 1         ; file descriptor (stdout)
    mov    eax, 4         ; syscall for write (sys_write)
    int      0x80           ; call kernel

    mov    edx, 9        ; message length
    mov    ecx, s2       ; message to write
    mov    ebx, 1        ; file descriptor (stdout)
    mov    eax, 4        ; syscall number for write (sys_write)
    int      0x80          ; call kernel
    mov    eax, 1        ; system call (sys_exit)
    int      0x80          ; call kernel

section .data
msg db 'Displaying 9 stars', 0xa ; a message
len equ $ - msg            ; length of message
s2 times 9 db '*'

As you can see I already have descriptions in the comments from the tutorial I found here. Here are some of the things I don't understand:

1. - What is s2? Is this just a variable or a register I know nothing about?

2. When '1' is moved into ebx, is this a parameter to the sys_exit later called in eax? I found a listing of Linux syscalls here and it does seem sys_exit does take one parameter in ebx that's an integer. If this is the case why not exit cleanly with zero?

I just want to make sure I understand everything correctly in this. Thanks in advance!
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Understanding Code in IF LOOP

Hello All, I would like to know and understand the difference between the below 3 IF loops and also if possible what are the different other parameters i could use other than those mentioed in the below lF LOOP conditions, appreciate your help. Thanks, Sam. (1 Reply)
Discussion started by: Ariean
1 Replies

2. UNIX Desktop Questions & Answers

Understanding the code

hello all, May i know what is this "DEBUG_ME $DEBUG_CMD main" doing in the below code. I am confused with alias also "alias DEBUG_ME='#'". Thanks for your help. set -x alias DEBUG_ME='#' if ; then . /product/apps/informatica/v7/pc/ExtProc/debug.ksh "$1" fi # Declaring the... (1 Reply)
Discussion started by: Ariean
1 Replies

3. Programming

Need assembly code for C program

Dear Buddies, I need assembly code for a compiled c program in unix. Kindly help me.... Thanking you in advance. (1 Reply)
Discussion started by: karthik537
1 Replies

4. Programming

Help with assembly code

I want make simple assembly code for some thing like this a^6+6a^2+2a and range of a is between -3 to 3. I tried but it is not working properly. As this is my first assembly program that I am going to try, I want some help with it. I found this example online but i dont want this kind of... (2 Replies)
Discussion started by: Learnerabc
2 Replies

5. Shell Programming and Scripting

Help understanding Perl code.

Well, I found myself trying to fix some Perl code (Ive never done any Perl in my life) and I pinpointed the place where the bug could be. But to be sure I have to know what does a few line of code mean: $files_lim =~ (/^\d*$/) $files_lim =~ (/^\d*h$/)$files_age =~ s/h//The code where this was... (0 Replies)
Discussion started by: RedSpyder
0 Replies

6. Shell Programming and Scripting

Help understanding some Perl code.

Well, I found myself trying to fix some Perl code (Ive never done any Perl in my life) and I pinpointed the place where the bug could be. But to be sure I have to know what does a few line of code mean: $files_lim =~ (/^\d*$/) $files_lim =~ (/^\d*h$/) $files_age =~ s/h// The code where... (2 Replies)
Discussion started by: RedSpyder
2 Replies

7. Programming

Understanding perl code

What is the difference between the two statements below? A: $a->{"$fruit"}->{"$color"}->{size} = $size B: $size = $a->{"$fruit"}->{"$color"}->{size} Please assist. Thanks! (0 Replies)
Discussion started by: onlinelearner02
0 Replies

8. Shell Programming and Scripting

auto-generating assembly code by variables found by script

Hi everybody I'm working on a list of registers(flip-flops to be exact), now i need to extract some value from this list and use them as arguments to pass them to some assembly code for example i have: 118 chain79 MASTER (FF-LE) FFFF 1975829 /TCK F FD1TQHVTT1 ... (1 Reply)
Discussion started by: Behrouzx77
1 Replies

9. Shell Programming and Scripting

Help with perl code understanding

Hi, I need to understand below perl code, can some one advise me. perl -MDate::Parse -e'BEGIN{$main::now=time;$main::old=(time-60*30)}' -nE'if(/^(\w+\s+\d+\s+\d+:\d+:\d+)/) {$t=str2time $1; $t > $old && $t < $now && print}' (1 Reply)
Discussion started by: learnbash
1 Replies

10. Shell Programming and Scripting

[Solved] Help understanding this code!!

Hi guys, I am still learning awk and much apprecated to shed some light on the following: the questions asked is below! { total = i = 0 do { ++i total += $i } while ( total <= 100 ) print i, ":", total } File used: cat test.do 45 25 60 20 10 105 50 40 33 5 9 67 108 3 5 4 (2 Replies)
Discussion started by: Apollo
2 Replies
al(1)							      General Commands Manual							     al(1)

NAME
al, al2 - Mono Assembly Linker SYNOPSIS
al [option] [source-files] DESCRIPTION
AL is the Mono assembly linkder. This linker is used to put together assemblies from a collection of modules (.netmodule files), assembly manifest files and resources. Do not confuse this with the monolinker, which is a tool to reduce the size of assemblies based on the code used. Use al for processing 1.0 assemblies, use al2 to process 2.0 assemblies. OPTIONS
@<filename> Read response file for more options. -algid:<id> Algorithm used to hash files. The <id> must be specified in hexadecimal. -base:<addr> | -baseaddress:<addr> Base address for the library. THIS FEATURE ISN'T IMPLEMENTED. -bugreport:<filename> Create a 'Bug Report' file. THIS FEATURE ISN'T IMPLEMENTED. -comp:<text> | -company:<text> This inserts the company name into the assembly metadata. This is equivalent to adding the [AssemblyCompany ("<text>")] attribute into C# source code. -config:<text> | -configuration:<text> This inserts the configuration string into the assembly metadata. This is equivalent to adding the [AssemblyConfiguration ("<text>")] attribute into C# source code. -copy:<text> | -copyright:<text> This inserts the copyright message into the assembly metadata. This is equivalent to adding the [AssemblyCopyright ("<text>")] attribute into C# source code. -c:<text> | -culture:<text> This inserts the supported culture into the assembly metadata. This is equivalent to adding the [AssemblyCulture ("<text>")] attribute into C# source code. -delay | -delay+ | -delaysign | -delaysign+ The generated assembly will be delay signed. This is equivalent to adding the [AssemblyDelaySignAttribute (true)] attribute into C# source code. -delay- | -delaysign- The generated assembly will be fully signed (i.e. not delay signed). This is the default option when signing (-keyfile or -key- name). -descr:<text> | -description:<text> This inserts a description of the assembly into the assembly metadata. This is equivalent to adding the [AssemblyDescription ("<text>")] attribute into C# source code. -e:<filename> | -evidence:<filename> This embed into the assembly the specified file as assembly security evidences. -fileversion:<version> Optional Win32 version. This overrides the normal assembly version. -flags:<flags> Assembly flags. The <flags> must be specified in hexadecimal. -fullpaths Display files using fully-qualified filenames. -keyf:<filename> | -keyfile:<filename> Strongname (sign) the output assembly using the key pair present in the specified strong name key file (snk). A full key pair is required unless the delay signing option is also specified (-delay+). This is equivalent to adding the [AssemblyKeyFile ("<text>")] attribute into C# source code. -keyn:<text> | -keyname:<text> Strongname (sign) the output assembly using the key pair present in the specified container. Delay signing isn't supported when using key containers. This is equivalent to adding the [AssemblyKeyName ("<text>")] attribute into C# source code. -main:<method> Specifies the method name of the assembly entry point. -nologo Suppress the startup banner and copyright message. -out:<filename> Output file name for the assembly manifest. -prod:<text> | product:<text> This inserts the product name into the assembly metadata. This is equivalent to adding the [AssemblyProduct ("<text>")] attribute into C# source code. -productv[ersion]:<text> This inserts the product version into the assembly metadata. This is equivalent to adding the [AssemblyInformationalVersion ("<text>")] attribute into C# source code. -t[arget]:<target> | -target=<target> Valid <target>s are: lib | library to create a library (.dll), exe to create a console executable (.exe), and win | winexe to create a Windows executable (.exe). -template:<filename> Specifies an assembly to get default options from. -title:<text> This inserts an assembly title into the assembly metadata. This is equivalent to adding the [AssemblyTitle ("<text>")] attribute into C# source code. -trade:<text> | -trademark:<text> This inserts a trademark message into the assembly metadata. This is equivalent to adding the [AssemblyTrademark ("<text>")] attribute into C# source code. -v:<version> | -version:<version> This inserts the assembly version into the assembly metadata. You can use * to auto-generate remaining numbers. This is equivalent to adding the [AssemblyVersion ("<text>")] attribute into C# source code. -win32icon:<filename> Use this icon for the output. -win32res:<filename> Specifies the Win32 resource file. -? | -help Display information about AL SEE ALSO
sn(1), monolinker(1) COPYRIGHT
Copyright (C) 2005 Novell, Inc (http://www.novell.com) MAILING LISTS
Visit http://lists.ximian.com/mailman/listinfo/mono-devel-list for details. WEB SITE
Visit: http://www.mono-project.com for details al(1)
All times are GMT -4. The time now is 11:03 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy