Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; CpS 230 Lab 5: Stone Champion College-Student (scham978)
  2. ;---------------------------------------------------
  3. ; Warm-up lab exercise to introduce the basics of
  4. ; writing, building, and running IA-64 assembly code
  5. ; programs on Windows.
  6. ;---------------------------------------------------
  7. default rel
  8.  
  9. ; We use these functions (printf and scanf) from an external library
  10. extern _printf
  11. extern _scanf
  12.  
  13.  
  14. ; Begin the "code" section of our output OBJ file
  15. section .text
  16.  
  17.  
  18.  
  19. ; Mark the label "main" as an exported/global symbol
  20. global _main
  21.  
  22. ; "main" marks the spot where our code actually is (i.e., calling "main()" takes you here)
  23. _main:
  24.     ; Boilerplate "function prologue"
  25.     push    rbp
  26.     mov     rbp, rsp
  27.     sub     rsp, 32             ; create shared shadow space
  28.    
  29.     lea     rdi, [prompt1]
  30.     call    _printf
  31.  
  32.     lea     rdi, [prompt1]
  33.     lea     rsi, [guess]
  34.     call    _scanf
  35.    
  36.     lea     rsi, [guess]
  37.     lea     rdi, [output]
  38.     call    _printf
  39.     ; Boilerplate "function epilogue"/return
  40.     mov     rsp, rbp
  41.     pop     rbp
  42.     ret
  43.  
  44. ; Begin the "data" section of our output OBJ file
  45. section .data
  46.  
  47.     guess: dd 0
  48.     prompt1: db "I'm thinking of a number between 1 and 100. What is it? ", 0
  49.     output: db "The guess was %d", 10, 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement