progs/example1b.s
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Fri, 21 Oct 2016 21:15:47 +0100
changeset 482 73ca7e916739
parent 396 2f4296a0ab21
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
395
60f64793266f added assembly programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     1
_foo:   
396
2f4296a0ab21 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 395
diff changeset
     2
  push    %ebp                     ; push current sp onto stack
2f4296a0ab21 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 395
diff changeset
     3
  mov     %esp,%ebp                ; current sp into esp
2f4296a0ab21 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 395
diff changeset
     4
  sub     $0x10,%esp               ; subtract 16 from esp
2f4296a0ab21 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 395
diff changeset
     5
  movl    $0x64636261,-0x6(%ebp)   ; store abcd in ebp - 6
2f4296a0ab21 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 395
diff changeset
     6
  movw    $0x65,-0x2(%ebp)         ; store e in ebp - 2
2f4296a0ab21 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 395
diff changeset
     7
  movl    $0x34333231,-0x10(%ebp)  ; store 1234 in ebp - 16
2f4296a0ab21 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 395
diff changeset
     8
  movl    $0x38373635,-0xc(%ebp)   ; store 5678 in ebp - 12
2f4296a0ab21 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 395
diff changeset
     9
  movw    $0x39,-0x8(%ebp)         ; store 9    in ebp - 8
2f4296a0ab21 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 395
diff changeset
    10
  leave                            ; pop last sp into ebp
2f4296a0ab21 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 395
diff changeset
    11
  ret                              ; pop return address and 
2f4296a0ab21 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 395
diff changeset
    12
                                   ; go back to main