daily pastebin goal
43%
SHARE
TWEET

Untitled

a guest Apr 16th, 2018 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. scanf(„%s” , buffer)
  2.    
  3. .data
  4.  
  5. name: .ascii "What is your name?n"
  6. name2: .ascii "Your name is:"
  7. formatScanf: .ascii "%s"
  8. .bss
  9. buffer: .size 100 #100 bytes for string input
  10.  
  11. .text
  12. .globl main
  13. main:
  14.  
  15. #Printing question #works fine
  16. pushl $name      
  17. call printf
  18.  
  19. #Get answers
  20. push $buffer    #2nd argument for scanf
  21. push $formatScanf #1st argument of scanf
  22. call scanf
  23.  
  24.  
  25.  
  26. #Exiting
  27. pushl $0
  28. call exit
  29.    
  30. lab3.s: Assembler messages:
  31. lab3.s:8: Error: expected comma after name `' in .size directive
  32.    
  33. #printf proba
  34. .data
  35.  
  36.  
  37. name2: .string "Your name is: %s "
  38. formatScanf: .string "%s"
  39. name: .string "What is your name?n"
  40. .bss
  41. buffer: .space 100
  42.  
  43. .text
  44. .globl main
  45. main:
  46.  
  47. #Printing question #works fine
  48. pushl $name      
  49. call printf
  50.  
  51. #Get answers
  52. push $buffer    #2nd argument for scanf
  53. push $formatScanf #1st argument of scanf
  54. call scanf
  55.  
  56. push $buffer
  57. push $name2
  58. call printf
  59.  
  60. #Exiting
  61. pushl $0
  62. call exit
  63.    
  64. buffer: .space 100
  65.    
  66. .size buffer, 100
RAW Paste Data
Top