Advertisement
Guest User

Untitled

a guest
Nov 9th, 2018
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. section .data
  2.     str: db "Hello world!", 0xa
  3.     strlen equ $-str
  4.     num: dd 1337
  5.     buf: db '0000000000'
  6.  
  7. section .text
  8.  
  9. global _start
  10.  
  11.  
  12. _start:
  13.     mov eax, 1337;start value
  14.    
  15.     ;inits
  16.     mov ebx,buf+9   ;schreibe ergebnis hierhin
  17.     mov ecx,10      
  18.     mov edi,10      ;dividor 10
  19.    
  20.     call _loop
  21.     call _print
  22.     call _exit
  23.  
  24. _loop:
  25.     mov edx,0       ;clear before divide
  26.     div edi         ;divide by 10
  27.     add edx,48      ;convert to ascii value
  28.     mov [ebx],dl    ;write into memory
  29.     dec ebx         ;decrement pointer
  30.     loop _loop      ;loop it
  31.  
  32.     ret
  33.  
  34.  
  35.    
  36. _print:
  37.     mov eax,4           ;schreibe
  38.     mov ebx,1           ;auf Terminal
  39.     mov ecx,buf
  40.     mov edx,11      ;11 Bytes
  41.     int 80h
  42.  
  43.     ret
  44.  
  45. _exit:
  46.     mov eax, 1
  47.     mov ebx, 0
  48.     int 80h
  49.  
  50.     ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement