Advertisement
DennisBoone2020

assemblyassignment1

Jan 24th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. ;;Dennis Boone
  2. ;; CS 371 Assignment 1 olly and masm
  3.  
  4.  
  5.  
  6.  
  7. include 371-prologue.inc ; suck in standard prologue
  8.  
  9. .const
  10. BUFFER_LENGTH equ 20 //declaring a constant number to be the buffer length
  11.  
  12. .data
  13. a dd 2 ;assigning variables as dd numbers to use for axsquared + bx + c
  14. b dd 3
  15. r dd 1 ;r will be c
  16. x dd 4
  17. unsigned_integer_format BYTE "%lu ", 0
  18.  
  19. .data?
  20. buffer BYTE BUFFER_LENGTH dup(?)
  21.  
  22. result dd ? ;;declaring result uninitialized for later use
  23.  
  24.  
  25. .code
  26. main proc
  27.  
  28.  
  29. mov eax, x ;;move x to eax so we can use the mul function to multiply x by itself
  30. mul x ;this is practically x times x
  31. mul a ; ax squared
  32. mov result, eax ;eax data which is ax squared is stored in unitialized variable
  33.  
  34. mov eax, b ;overwriting the eax number to be b since eax data was already stored in result
  35. mul x ; equivalent of bx
  36. add result, eax ;adding this to result so its now ax squared plus bx
  37.  
  38. mov ebx, r ;moving r which is my c into a register and adding it to result
  39. add result, ebx
  40.  
  41. push result
  42. push offset unsigned_integer_format
  43. push offset buffer
  44. call wsprintf ;procedure for printing
  45. add esp, 12 ;;offsetting to go into stack
  46. push offset buffer
  47. call StdOut
  48.  
  49.  
  50. push 0 ; standard exit
  51. call ExitProcess
  52. main endp
  53. end main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement