Changes

Jump to navigation Jump to search
222 bytes added ,  23:38, May 13, 2009
Line 20: Line 20:     
==Sample Assembly Source Code==
 
==Sample Assembly Source Code==
The following is a sample of assembly code for the Intel 8086 CPU:
+
The following is a sample program written in assembly for an ARM [[CPU]] running Linux kernel with [[ARM EABI]] system call conventions. The program will print "hello world" to standard output.
    +
<pre>
 +
# Arguments are passed in registers r0-6, the system call number in r7
   −
; The purpose of this code is to output a new line
+
# Write msglen bytes starting from address msg to standard output (file descriptor 1)
 +
mov r0, #1
 +
adr r1, msg
 +
mov r2, #msglen
 +
mov r7, #4
 +
swi #0
   −
.DEFINE OUTR
+
# Exit with status 0
 +
mov r0, #0
 +
mov r7, #1
 +
swi #0
   −
      MOV  AX, 02H
+
# Assembler macros that specify the data
   −
      INT  21H
+
msg:
 
+
.ascii "hello world\n"
.ENDDEF
+
msglen = . - msg
 
+
</pre>
CRLF:  PUSH  DX
  −
 
  −
      PUSHF
  −
 
  −
      MOV  DL, _CR
  −
 
  −
      OUTR
  −
 
  −
      MOV  DL, _LF
  −
 
  −
      OUTR
  −
 
  −
      POPF
  −
 
  −
      POP  DX
  −
 
  −
      RET
  −
 
  −
      END
      
==References==
 
==References==
9

edits

Navigation menu