daily pastebin goal
63%
SHARE
TWEET

Untitled

a guest Apr 16th, 2018 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.                                                                      
  2.                                                                      
  3.                                                                      
  4.                                              
  5. TITLE StringSearch.asm
  6.  
  7.  
  8.  
  9. INCLUDE Irvine32.inc
  10.  
  11.  
  12.  
  13. PrepareMap PROTO,
  14.     string: PTR BYTE,
  15.     map: PTR BYTE
  16.  
  17.  
  18.  
  19. CharacterSearch PROTO,
  20.         map: PTR BYTE,
  21.         char: BYTE
  22.  
  23. .data
  24. stringMap byte 32 dup(0)
  25. testString byte "hello, assembly language programming!",0
  26. msg1 byte " is not in the string.",0
  27. msg2 byte " is in the string.",0
  28.  
  29. ;Code test driver
  30. .code
  31.     main PROC
  32.  
  33.  
  34.    
  35.            
  36.  
  37.     INVOKE PrepareMap, addr testString, addr stringMap
  38.    
  39.  
  40.    
  41.     INVOKE CharacterSearch, addr stringMap, 'h'
  42.    
  43.        
  44.  
  45.     exit
  46.     main ENDP
  47.    
  48.  
  49.  
  50.  
  51.     PrepareMap PROC USES ECX EBX EAX EDX ESI EDI EBP, string: PTR BYTE, map: PTR BYTE
  52.     mov esi, string
  53.     mov edi, map
  54.     mov ebp, 0
  55.    
  56. ForLoop:
  57.    
  58.     cmp ebp, 32
  59.     JGE L9
  60.  
  61.     LeftSide:
  62.        
  63.         mov al, [esi]
  64.         shr al, 3
  65.         add [edi], al
  66.  
  67.     RightSide:
  68.         mov cl, [esi]
  69.         AND cl, 7
  70.         mov bl, 1
  71.         shl bl, cl
  72.  
  73.     OrStatement:
  74.         OR [edi], bl
  75.         inc ebp
  76.        
  77.         JMP ForLoop
  78.  
  79.  
  80.    
  81.  
  82.     L9:
  83.         ret
  84.     PrepareMap Endp
  85.  
  86.  
  87.  
  88.  
  89.     CharacterSearch PROC map: PTR BYTE, char: BYTE
  90.  
  91.     LeftSide:
  92.         ;mov al, char
  93.         ;call WriteChar
  94.         mov edi, map
  95.         mov cl, char
  96.         shr cl, 3
  97.         mov [edi], cl
  98.    
  99.     RightSide:
  100.         mov cl, char
  101.         AND cl, 7
  102.         mov al, 1
  103.         shl al, cl
  104.  
  105.     AndStatement:
  106.         mov bl, [edi]
  107.         AND bl, al
  108.  
  109.  
  110.     IfStatement:
  111.         cmp bl, 0
  112.         JE NotIn
  113.         mov edx, offset msg2
  114.         call WriteString
  115.         JMP L9
  116.  
  117.    
  118.     NotIn:
  119.         mov edx, offset msg1
  120.         call WriteString
  121.  
  122.     L9:
  123.     ret
  124.     CharacterSearch endp
  125.    
  126.    
  127.     END main
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
 
Top