what is rep scasw?
and what about repz scasw? Any more info on things that come after rep, or info what rep is precisely? I use rep stosw in graphics to move the double buffer to the video buffer, it moves data it seems in one instruction. But what about the others?
: and what about repz scasw? Any more info on things that come after rep, or info what rep is precisely? I use rep stosw in graphics to move the double buffer to the video buffer, it moves data it seems in one instruction. But what about the others?
rep means repeat. repZ means repeat while zero flag set.
rep is only good in a loop . u can move a value to cx to set
how often u want to repet an instruction.
mov cx,32000 ; how often to loop
rep scasw ; repeat 32000 times scasw
will repeat scasw 32000 times.
scasw means scan string ( wordwise ). this compares a string
adressed by es:di with the ax-register. after this it will
increase di by 2 .
there r some other versions of rep. for example:
repNZ ( repeat while not zero )
repE ( repeat while equal )
repNE ( repeat while not equal )
but repe is the same as repz and repne is the same as repnz .
u should buy a book about the basics of asm.
Thanks A lot!
I do have a book on basic assembly (Assembly language Step by step). It explains rep stosw, so I understood rep, and it explains what the flags are, but I didn't know if it was rep affecting the flags or the string instruction. So since SCASW means SCAn String Word-wise, SCASB means SCAn String Byte-wise? And it increases di by 1? And what about CMPS? It compares a string of bytes? Then di would be increased by the string length? And are there any SCASD for doubles? Thanks for your help!
: Thanks A lot!
: I do have a book on basic assembly (Assembly language Step by step). It explains rep stosw, so I understood rep, and it explains what the flags are, but I didn't know if it was rep affecting the flags or the string instruction. So since SCASW means SCAn String Word-wise, SCASB means SCAn String Byte-wise? And it increases di by 1? And what about CMPS? It compares a string of bytes? Then di would be increased by the string length? And are there any SCASD for doubles? Thanks for your help!
the string instruction is causing the zeroflag. lets look what
if u compare something ur cpu will subtract the 2 things so:
cmp ax,bx ;
; here the cpu will jump if ax=bx
the difference between a normal subtraction and compare is
that cmp will never save the result, it will just set the flags.
so if ax is equal to bx and u subtract ( ax-bx or bx-ax )
the result will be 0 . the cpu will set the zeroflag. thats
why u can write jz instead of je . all in all the flags are set
by the scas instruction and repz just checks the zeroflag.
yes scasb means scan string bytewise and increase di by 1.
there is also a scasd for doubles. but u have to switch to
386 instruction-mode before u can use it. remember 32bit-
registers are not available for older cpus.
cmps: this compares 2 strings :
cmps bstring1,bstring2 ; strings of byte
cmps wstring1,wstring2 ; word
cmps dstring1,dstring2 ; dword ( set 386 instructions )
be sure that ds-register is set to the segment of string1 and
es-register is set to the segment of string2.
or u just set ds:si to the adress of string1 and es:si to
the adress of string2.
ur code might look like this:
push ds ; push ds to stack
pop es ; and pop it to es so es=ds
; i assume that the strings r in the same segment
mov si,offset string1 ; ds:si points to string1 now
mov di,offset string2 ; es:di points to string2 now
repe cmpsb ; repeat compare while equal ( zeroflag set )
si and di will be increased by 1 ( bytewise) so that they point
to the next bytes of each string. use cmpsw for wordwise,
cmpsd for dwordwise ( again, 386 necessary
It looks like you're new here. If you want to get involved, click one of these buttons!
Assembly Code Share
Getting started in assembly
C and C++
C/C++ on Linux/Unix
C/C++ Windows API
C++ Game Development
Delphi and Kylix
Java Server Pages
Access databases and VB
Advance Visual Basic
DirectX Game dev
Newbie Game Programmers
Cooling & Overclocking
Database & SQL
Sound & Music
FreeLance Software City
C# & VB.NET School Support
Join the Team
Comments on this site
New programming languages
Off topic board
Mobile & Wireless
Operating Systems & Platforms
Witsbits Go Cloud
Embedded / RTOS
Windows CE & Pocket PC
Networking And Security
Windows 2003 Server
RUP & UML
Quality & Testing
Active Server Pages
HTML & WEB-Design
Mobile Internet & Messaging
WEB-Services / SOAP
In this Discussion