Vulpes

225MP3_ASM

Oct 16th, 2011
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. extern printf
  2.  
  3. segment .data
  4. c_pt_s  db `char: '%c' is 0x%.8X`,10,0  ;for char_print  printf("char: %d is %c\n",eax,eax);
  5. n_pt_s  db `x%.8X `,10,0
  6.  
  7. segment .bss
  8.  
  9.  
  10.  
  11. segment .txt
  12.         global  t1
  13. t1:
  14.         enter   0,0                 ; setup routine
  15.  
  16.         mov esi,        [ebp+8]         ;
  17.         mov ecx,        0
  18.         mov edi,        [ebp+12]    ;tallybuff
  19. loop1:      mov eax,        0
  20.         mov al,     [esi+ecx]       ;
  21.         ;call   char_print 
  22.         ;mov    edx,        edi+4*al   
  23.         mov ebx,        [edi+4*eax]    
  24.         inc ebx
  25.         mov [edi+4*eax],    ebx         ;
  26.         inc ecx
  27.         cmp al,     0               ;check to see if null
  28.         je  done
  29.         jmp     loop1      
  30.  
  31.         ;add    esp,    4               ;
  32. done        mov eax,    0               ;this puts my return value in place
  33.        
  34.         leave   ;; comment these to asm print out tally
  35.         ret ;; comment these to asm print out tally
  36.  
  37.         mov ecx,    0
  38. ptall       mov ebx,    [edi+4*ecx]
  39.         call    num_print
  40.         inc ecx
  41.         cmp ecx,    80h
  42.         je  done1
  43.         jmp ptall
  44. done1       leave
  45.             ret
  46.        
  47.  
  48. num_print   pusha
  49.  
  50.         push    ebx
  51.         push    n_pt_s
  52.        
  53.         call    printf
  54.         add esp,    8  ;remove 2 pushes on stack
  55.        
  56.         popa
  57.         ret
  58.  
  59.  
  60.  
  61.  
  62.  
  63. char_print  pusha
  64.  
  65.         push    eax
  66.         push    eax
  67.         push    c_pt_s
  68.        
  69.         call    printf
  70.         add esp,    12  ;remove 2 pushes on stack
  71.        
  72.         popa
  73.         ret
Advertisement
Add Comment
Please, Sign In to add comment