Advertisement
kamasazi99

asm lab 6, oprocz ostatniego

Nov 30th, 2019
337
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .386
  2. .MODEL FLAT, STDCALL
  3.  
  4. STD_OUTPUT_HANDLE equ -11
  5. STD_INPUT_HANDLE equ -10
  6.  
  7. GetStdHandle PROTO :DWORD
  8. WriteConsoleA PROTO :DWORD, :DWORD, :DWORD, :DWORD, :DWORD
  9. ReadConsoleA PROTO :DWORD, :DWORD, :DWORD, :DWORD, :DWORD
  10. ScanInt PROTO
  11. ExitProcess PROTO :DWORD
  12. fillRegister PROTO
  13. wsprintfA PROTO C :VARARG
  14.  
  15. .data
  16. buffor DWORD 255 dup(0)
  17. Pliczbe BYTE "Podaj liczbe: "
  18. suma DWORD 0
  19. wynik BYTE "Wynik: %i"
  20.  
  21. hout DWORD 0 ;out wypisanie MACRO
  22. hin DWORD 0 ;inp wpisanie MACRO
  23. rout DWORD 0 ;dl znakow
  24. rinp DWORD 0 ;dl znakow wsprintfA
  25.  
  26.  
  27. .code
  28. ReturnDecryptor MACRO handleConstantIn :REQ, handleOut :REQ
  29. invoke GetStdHandle, handleConstantIn
  30. mov handleOut, eax
  31.  
  32.  
  33.  
  34. ENDM
  35.  
  36.     main proc
  37.     invoke fillRegister
  38.     ReturnDecryptor STD_OUTPUT_HANDLE, hout
  39.     ReturnDecryptor STD_INPUT_HANDLE, hin
  40.    
  41.  
  42.  
  43. mov ecx,4
  44. petla:
  45. push ecx
  46.  
  47. invoke WriteConsoleA,hout,offset Pliczbe,lengthof Pliczbe,offset rout,0
  48.  
  49.  
  50. invoke ReadConsoleA,hin,offset buffor,255,offset rinp,0
  51.  
  52. mov ebx, OFFSET buffor
  53. add ebx, rinp
  54. mov [ebx-2], BYTE PTR 0
  55.  
  56.  
  57. push OFFSET buffor
  58. call ScanInt
  59.  
  60. add suma, eax
  61.  
  62. pop ecx
  63. loop petla
  64.  
  65.  
  66. invoke wsprintfA,offset buffor,offset wynik,suma
  67.  
  68.  
  69.  
  70. invoke WriteConsoleA, hout,offset buffor,lengthof wynik,offset rout,0
  71.  
  72.  
  73.  
  74.  
  75. invoke ExitProcess,0
  76. main endp
  77.  
  78.  
  79.     END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement