SHARE
TWEET

Untitled

a guest Sep 30th, 2017 26 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .text
  2. .globl  _start
  3.  
  4. start = 0
  5. max = 31
  6.  
  7. _start:
  8.         mov     $start,%r15     /* starting value for loop */
  9.         mov     $0x30,%r12         /* value of 0 in hex to ascii*/
  10.  
  11.  
  12. loop:  
  13.         // division for 2-digit number
  14.         mov     $0,%rdx         /* clear remainder for division */
  15.         mov     %r15,%rax       /* set rax to be divided */
  16.         mov     $10,%r10        /* set divisor */
  17.         div     %r10            /* divide */
  18.         mov     %rax,%r14       /* store quotient */
  19.         mov     %rdx,%r13       /* store remainder */
  20.  
  21.         // modify msg
  22.         add     $0x30,%r14      /* convert to ascii */
  23.         add     $0x30,%r13      /* convert to ascii */
  24.         mov     %r13b,msg+7     /* modify single byte in msg */
  25.  
  26.         // skip if first digit is 0
  27.         cmp     %r12,%r14
  28.         je      print
  29.         mov     %r14b,msg+6     /* modify single byte in msg */
  30.  
  31. print:
  32.         // print out
  33.         mov     $len,%rdx       /* length of string */
  34.         mov     $msg,%rsi       /* string */
  35.         mov     $1,%rdi         /* stdout */
  36.         mov     $1,%rax         /* write */
  37.         syscall
  38.  
  39.         // loop
  40.         inc     %r15            /* increment register */
  41.         cmp     $max,%r15       /* compare max to increment value */
  42.         jne     loop            /* back to loop if not equal */
  43.  
  44.         // exit
  45.         mov     $0,%rdi         /* exit status */
  46.         mov     $60,%rax        /* syscall 60 = exit */
  47.         syscall
  48.  
  49. .data
  50. msg:    .ascii  "Loop:   \n"
  51. len = . - msg
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top