stevennathaniel

Meminta Input Angka & Menampilkan Angka

Aug 21st, 2015
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. section .data                               ;   Data segment
  2.  
  3.     userMsg db 'Silahkan memasukan angka: ' ;   Meminta user untuk memasukan angka
  4.  
  5.     lenUserMsg equ $-userMsg                ;   Panjang Pesan
  6.  
  7.     dispMsg db 'Anda sudah memasukan: '     ;   Pesan yg disampaikan
  8.  
  9.     lenDispMsg equ $-dispMsg
  10.  
  11. section .bss                                ;   Uninitialized data
  12.  
  13.     num resb 5
  14.  
  15. section .text                               ;   Code segment
  16.  
  17.     global _start
  18.  
  19. _start:
  20.  
  21.     mov eax, 4
  22.  
  23.     mov ebx, 1
  24.  
  25.     mov ecx, userMsg
  26.  
  27.     mov edx, lenUserMsg
  28.  
  29.     int 80h
  30.  
  31.  
  32.     ;Read and store the user input
  33.  
  34.     mov eax, 3
  35.  
  36.     mov ebx, 2
  37.  
  38.     mov ecx, num
  39.  
  40.     mov edx, 5                          ; 5 bytes (numeric, 1 for sign) of that information
  41.  
  42.     int 80h
  43.  
  44.  
  45.  
  46.     ;Output the message 'Angka yg dimasukan adalah: '
  47.  
  48.     mov eax, 4
  49.  
  50.     mov ebx, 1
  51.  
  52.     mov ecx, dispMsg
  53.  
  54.     mov edx, lenDispMsg
  55.  
  56.  
  57.  
  58.  
  59.     ;Output the number entered
  60.  
  61.     mov eax, 4
  62.  
  63.     mov ebx, 1
  64.  
  65.     mov ecx, num
  66.  
  67.     mov edx, 5
  68.  
  69.     int 80h
  70.  
  71.  
  72.     ;Exit code
  73.  
  74.     mov eax, 1
  75.  
  76.     mov ebx, 0
  77.  
  78.     int 80h
Add Comment
Please, Sign In to add comment