Created
July 21, 2013 18:56
-
-
Save dekay/6049547 to your computer and use it in GitHub Desktop.
Listing 2 from http://www.ibm.com/developerworks/library/l-gas-nasm/ translated to GNU as and written using intel syntax.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example adapted from http://www.ibm.com/developerworks/library/l-gas-nasm/ | |
# Assemble with: as --gstabs+ -o nasm2gas2.o nasm2gas2.s | |
# Link with ld -o nasm2gas2 nasm2gas2.o | |
# Check program return status with "echo $?" | |
# | |
# Support intel syntal vs. ATT and don't use % before register names | |
.intel_syntax noprefix | |
.section .data | |
var1: .int 40 | |
var2: .int 20 | |
var3: .int 30 | |
.section .text | |
# Program entry point | |
.globl _start | |
_start: | |
# Move the contents of variables | |
mov ecx, [var1] | |
cmp ecx, [var2] | |
jg check_third_var | |
mov ecx, [var2] | |
check_third_var: | |
cmp ecx, [var3] | |
jg _exit | |
mov ecx, [var3] | |
_exit: | |
mov eax, 1 | |
mov ebx, ecx | |
int 0x80 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment