Skip to content

Instantly share code, notes, and snippets.

@dekay
Created July 21, 2013 18:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dekay/6049547 to your computer and use it in GitHub Desktop.
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.
# 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