Advertisement
Guest User

Question(ASM)

a guest
Oct 16th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. section .data
  2.     Snippet db "KANGAROO"
  3.  
  4. section .text
  5.     global  _start
  6. _start:
  7.     nop
  8. ; Put your experiments between the two nops...
  9.  
  10.     mov ebx,Snippet             ; ebx has the copy of memory address of Snippet
  11.     mov eax,8                   ; immediate addressing .. eax has the value 0x8
  12.     DoMore: add byte [ebx],32   ; whatever the Memory address that is inside ebx is pointing to,[ebx] has the data of that
  13.                                   memory address. And added 32 to the ascii value (one byte of that data). Now the character
  14.                                   is in lowercase.
  15.     inc ebx                     ; incrementing ebx memory address by 1 so that in the next loop [ebx] can
  16.                                   point to first "A" of "kANGAROO". So, this concludes that every byte has
  17.                                   its own memory address and registers are array of memory
  18.     dec eax                     ; For ZF register
  19.     jnz DoMore                  ; ZF ! set go to DoMore
  20.  
  21. ; Put your experiments between the two nops...
  22.     nop
  23.  
  24. ;=========================================================================
  25. ;Questions:
  26. ;   1. [ebx] should contain "KANG" only as it is 32 bit only in size, but, how were we able to change whole
  27. ;      "KANGAROO" to lowercase when the letters we had were only 4 ?
  28. ;       -> My answer to this question is :
  29. ;           yes 32 bit register can only contain 4 characters. If we see the line/instruction
  30. ;           .
  31. ;           .
  32. ;           -- inc ebx
  33. ;           .
  34. ;           .
  35. ;           what we are doing here is increasing memory location by one, so that memory location inside ebx
  36. ;           increase by 1 byte, so that it points to the second letter "A" from "KANGAROO". So, while      
  37. ;           accessing it with line/instruction
  38. ;           .
  39. ;           --add byte [ebx],32
  40. ;           .
  41. ;           we are adding number 32 to ascci value of "A" as memory location inside ebx starts from (memory
  42. ;           location of "K"+1 byte)="A" and [ebx] has the value "ANGA".
  43. ;
  44. ;
  45. ;
  46. ;
  47. ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement