Video Link - http://videos.securitytube.net/Assembly-...trings.mp4
& Here - http://www.securitytube.net/video/225
Description: This is Part 7 of the "Assembly Language Primer for Hackers" video series. Please begin here, by watching Part 1, if you have not already done so. In this video we will look at how to work with strings in Assembly. We will demonstrate how we can move strings from one memory location to the other using the MOVS instruction set, discuss the concept of the Direction Flag (DF) and how to set and clear it using STD and CLD, how to execute multiple string copy instructions using the REP instruction, how to load strings from memory into the EAX register using the LODS instruction set, how to store strings from the EAX register back into memory using the STOS instruction set and finally we shall look at how to compare strings using the CMPS instruction set.
Please download StringBasics.s to try out the various exercises discussed in this video.
Disclaimer: We are a infosec video aggregator and this video is linked from an external website. The original author may be different from the user re-posting/linking it here. Please do not assume the authors to be same without verifying.
& Here - http://www.securitytube.net/video/225
Description: This is Part 7 of the "Assembly Language Primer for Hackers" video series. Please begin here, by watching Part 1, if you have not already done so. In this video we will look at how to work with strings in Assembly. We will demonstrate how we can move strings from one memory location to the other using the MOVS instruction set, discuss the concept of the Direction Flag (DF) and how to set and clear it using STD and CLD, how to execute multiple string copy instructions using the REP instruction, how to load strings from memory into the EAX register using the LODS instruction set, how to store strings from the EAX register back into memory using the STOS instruction set and finally we shall look at how to compare strings using the CMPS instruction set.
Please download StringBasics.s to try out the various exercises discussed in this video.
Code:
.data
HelloWorldString:
.asciz "Hello World of Assembly!"
H3110:
.asciz "H3110"
.bss
.lcomm Destination, 100
.lcomm DestinationUsingRep, 100
.lcomm DestinationUsingStos, 100
.text
.globl _start
_start:
nop
# 1. Simple copying using movsb, movsw, movsl
movl $HelloWorldString, %esi
movl $Destination, %edi
movsb
movsw
movsl
# 2. Setting / Clearing the DF flag
std # set the DF flag
cld # clear the DF flag
# 3. Using Rep
movl $HelloWorldString, %esi
movl $DestinationUsingRep, %edi
movl $25, %ecx # set the string length in ECX
cld # clear the DF
rep movsb
std
# 4. Loading string from memory into EAX register
cld
leal HelloWorldString, %esi
lodsb
movb $0, %al
dec %esi
lodsw
movw $0, %ax
subl $2, %esi # Make ESI point back to the original string
lodsl
# 5. Storing strings from EAX to memory
leal DestinationUsingStos, %edi
stosb
stosw
stosl
# 6. Comparing Strings
cld
leal HelloWorldString, %esi
leal H3110, %edi
cmpsb
dec %esi
dec %edi
cmpsw
subl $2, %esi
subl $2, %edi
cmpsl
# The exit() routine
movl $1, %eax
movl $10, %ebx
int $0x80