line 29: byte is a reserved word that means one byte and you are attepting to add a 16-bit register value to it. You will probably have to use a different general register to do it
mov edx,esi
add byte[eax], dl
But when you do that you might as well replace esi with edx everywhere in that loop to avoid repeated copying.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
>>I'm curious why you said to move esi to edx?
esi is a 32-bit register and can only be copied to another 32-bit register.
>>Also could you explain a little about dl?
Its just an 8-bit register just like al. Only eax, ebx, ecx, edx contain 32-bit, 16-bit and 8-bit registers. And you have to use an 8-bit register to do anything with just one byte of memory.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
> OK, so would eax, ax and al all be the same register/memory.
Yes and no. Read on.
> Can all three of those contain seperate values?
Yes and no. Read on.
AL is the low-order byte of AX. AH is the high-order byte of AX. Thus, AX is a 16-bit value (composed of two eight-bit values).
Likewise, AX is the low-order word of EAX. You can swap the low- and high-order words of EAX using the ROL opcode, say: ROL EAX, 16 .
So, if you set AL to 07h and AH to 8Ah, then it is the same as setting AX to 8A07h.
Hope this helps.
Duoas
Postaholic
2,043 posts since Oct 2007
Reputation Points: 1,140
Solved Threads: 229
Back when people had to count nanoseconds on older processors it actually made a difference how you used certain registers.
Nowdays, just say MOV AL, 7 or MOV AX, 78Ah --whichever is needed.
LikeTight_Coder_Ex said, make sure you get a good reference. ROL, RCL, etc. are woefully underused opcodes, but very powerful. Look them up.
Follow along:
mov ax, 78Ah ; AH == 07h, AL == 8Ah; AX == 078Ah
rol ax, 4 ; AH == 78h, AL == A0h; AX == 78A0h
rol ax, 4 ; AH == 8Ah, AL == 07h; AX == 8A07h
Hope this helps.
Duoas
Postaholic
2,043 posts since Oct 2007
Reputation Points: 1,140
Solved Threads: 229