help with assembly assignment

Please support our Assembly advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Oct 2009
Posts: 1
Reputation: amw2326 is an unknown quantity at this point 
Solved Threads: 0
amw2326 amw2326 is offline Offline
Newbie Poster

help with assembly assignment

 
0
  #1
Oct 21st, 2009
so I am working on an assignment in class, and I've hit a road block. the assignment is to replace certain letters (b, c) with others, (x, y). Right now, my program is not recognizing 'b' in ebx, and the second letter in the array, 'b', (stored in eax) as being the same, so it is not changing them. I know im doing something wrong, but I can't figure out what. Any hints would be much appreciated, meanwhile i will keep plugging away at it. Also, I cannot get the new array in edx to show up without subtracting sixteen, and im not sure how to fix that so that is not necessary. Thanks so much.

  1.  
  2. INCLUDE Irvine32.inc
  3. .data
  4. array byte 'a', 'b', 'c', 'd', 'e', 'f', 'a', 'b', 'c',
  5. 'd', 'e', 'f', 'a', 'b', 'c'
  6. letter byte ?
  7. newArray byte 15 dup (?)
  8. .code
  9. main PROC
  10. mov ecx, lengthof array ;moves ecx to beginning of array as a counter
  11. mov esi, offset array ;moves esi to the beginning of array to obtain letters
  12. mov eax, [esi] ;moves first position of array into eax
  13.  
  14. doLoop: ;starts a loop
  15. mov ebx, 'b' ;moves first letter comparison (b) into ebx
  16. cmp ebx, eax ;compares letters
  17. je check4C ;if it is b, then jump to check for c
  18. add edx, eax ;if not b, store first letter of newArray in edx
  19. add esi, type array ; increment esi to next letter in array
  20.  
  21. loop doLoop ;loop back to the beginning
  22.  
  23. mov edx, offset newArray
  24. sub edx, 16
  25.  
  26. call writestring ;print newArray string with new letters
  27. call crlf ;enters a blank line
  28. call waitmsg ;waits til user closes screen
  29.  
  30. exit ;exit
  31.  
  32. check4C: ;check for c
  33. add edx, 'x' ;adds x for b into new array
  34. add esi, type array ;move esi down the array
  35. mov eax, [esi] ;move esi into eax for next comparison
  36. mov ebx, 'c' ;move c into ebx for comparison
  37. cmp ebx, eax ;compare registers
  38. je replace ;if the letter is matches c go to replace
  39. add edx, eax ;store next letter of newArray in edx
  40. add esi, type array ;move esi down the array
  41. jmp doLoop ;go to the top of the loop
  42.  
  43. replace: ;replaces y for c
  44. add edx, 'y' ;moves y into array instead of c
  45. add esi, type array ;move esi down the array
  46. jmp doLoop ;go to the top of the loop
  47.  
  48. main ENDP
  49.  
  50. END main
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 140
Reputation: NotNull is an unknown quantity at this point 
Solved Threads: 14
NotNull's Avatar
NotNull NotNull is offline Offline
Junior Poster
 
0
  #2
Oct 21st, 2009
mov eax, dword [esi] ;moves first position of array into eax
And also moves a double word EAX=44434241h, I think so,
not sure.


To read each byte at a time do:
xor eax, eax
mov al, byte [esi]

mov ebx, 'b' ;moves first letter comparison (b) into ebx
cmp ebx, eax ;compares letters EAX=44434241h EBX=00000042h
je check4C
Last edited by NotNull; Oct 21st, 2009 at 10:10 pm.
----------------------------------------------------------
To control a mind violates a man, and all it has been used for is
hurting and afflicting. Nowonder I progam in assembly...
--->Now available http://dotcoding.netai.net/
Reply With Quote Quick reply to this message  
Reply

Message:



Similar Threads
Other Threads in the Assembly Forum
Thread Tools Search this Thread



Tag cloud for Assembly
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC