3 Replies - 1576 Views - Last Post: 26 January 2013 - 04:21 PM

#1 c3phalex1n  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 25-January 13

What it does CL Register in this source code?

Posted 26 January 2013 - 01:10 PM

Hi all programmer...!
I'm a new programmer with assemblly language and i have a lot of problem...!

Friends, who can describe follow source code for me?!
I can not understand register cl what It does in follow source code!
.section .text 
.globl _start 
_start: 
       nop 
       movl $279, %ecx 
       movzx [b]%cl[/b], %ebx 
       movl $1, %eax 
       int $0x80



Thanks...!

Is This A Good Question/Topic? 0
  • +

Replies To: What it does CL Register in this source code?

#2 andrewsw  Icon User is offline

  • It's just been revoked!
  • member icon

Reputation: 3822
  • View blog
  • Posts: 13,543
  • Joined: 12-December 12

Re: What it does CL Register in this source code?

Posted 26 January 2013 - 01:23 PM

The CX register is used as a decrementing counter, stopping when the counter reaches zero. CL is its least significant byte.

Wikibooks

Quote

It is also possible to address the first four registers (AX, CX, DX and BX) in their size of 16-bit as two 8-bit halves. The least significant byte (LSB), or low half, is identified by replacing the 'X' with an 'L'. The most significant byte (MSB), or high half, uses an 'H' instead. For example, CL is the LSB of the counter register, whereas CH is its MSB.


You might use it if you are only performing a limited number of counts or iterations.
Was This Post Helpful? 1
  • +
  • -

#3 GunnerInc  Icon User is offline

  • "Hurry up and wait"
  • member icon




Reputation: 868
  • View blog
  • Posts: 2,310
  • Joined: 28-March 11

Re: What it does CL Register in this source code?

Posted 26 January 2013 - 04:11 PM

Actually from that code snippet, there is no loop, so CL is NOT used as a counter. You cannot just expect EcX to be used as a counter, I don't always us it as a counter. Certain instructions do rely on EcX as a counter and increment/decrement that register, but nowhere in that code is a loop.

What that code is doing is simple. It loads the number 279 into the 32 bit register ECX, next it moves the lower 8 bits of ECX (lower 8 bits of ECX = CL) and moves that value into EBX and zeroing out the upper unused 24 bits of EBX
Was This Post Helpful? 1
  • +
  • -

#4 andrewsw  Icon User is offline

  • It's just been revoked!
  • member icon

Reputation: 3822
  • View blog
  • Posts: 13,543
  • Joined: 12-December 12

Re: What it does CL Register in this source code?

Posted 26 January 2013 - 04:21 PM

URL REMOVED... might prove useful - a summary of the different registers available and their intended purpose.



*** Edit ***
please keep links to sites that contain crackme how tos, to yourself, thanks

This post has been edited by GunnerInc: 26 January 2013 - 10:33 PM
Reason for edit:: removed url

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1