I want to move that number in CX(counter register). And it's not possible to move al into Cx.
Asked
Active
Viewed 2,089 times
0
-
1AL is not 16 bits anyway so it wouldn't really help. Anyway could you give some more context to this? – harold Nov 22 '16 at 13:46
-
1AL is 8bits and CX is 16bit, so you could use `MOVZX` – FCin Nov 22 '16 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? – programmer Nov 22 '16 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. – Margaret Bloom Nov 22 '16 at 15:35
-
@programmer: the [LOOP instruction is slow](http://stackoverflow.com/questions/35742570/why-is-the-loop-instruction-slow-couldnt-intel-have-implemented-it-efficiently). 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. – Peter Cordes Nov 23 '16 at 00:40
1 Answers
1
You can move al
into cl
and then zero out ch
:
mov cl,al
xor ch,ch

fuz
- 88,405
- 25
- 200
- 352
-
1I'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. – Peter Cordes Nov 23 '16 at 00:37