0

I want to move that number in CX(counter register). And it's not possible to move al into Cx.

5
  • 1
    AL is not 16 bits anyway so it wouldn't really help. Anyway could you give some more context to this? Commented Nov 22, 2016 at 13:46
  • 1
    AL is 8bits and CX is 16bit, so you could use MOVZX Commented Nov 22, 2016 at 13:48
  • I want to get the input from user and store it in counter register so loop can run according to the input.. I know there are other ways I can use instead of loop. But I only want to use loop.. Is there any way to store it in Cx? Commented Nov 22, 2016 at 15:08
  • You need to read a number symbol by symbol, convert each symbol to the corresponding digit (i.e. '9' to 9) and make a number out of the digits (i.e. 1, 2, 4 to 124). On documentation there is something about this. Commented Nov 22, 2016 at 15:35
  • @programmer: the LOOP instruction is slow. Compilers never use it, so I'd recommend just looping a different way, if you want to learn to read compiler output. LOOP is useful when optimizing for code-size at the expense of speed, though, but it sounds like not in this case because it will take you extra instructions to set up for it. Commented Nov 23, 2016 at 0:40

1 Answer 1

1

You can move al into cl and then zero out ch:

mov cl,al
xor ch,ch
Sign up to request clarification or add additional context in comments.

1 Comment

I'd prefer xor cx, cx / mov cl, al. That pattern still works for 32-bit registers where you can't zero the upper halves separately. It also avoids partial-register stalls on Intel P6-family microarchitectures.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.