NASM Forum > Using NASM

How do you overide the address size in NASM when using movsb?

(1/2) > >>

ben321:
For example, in 16 bit mode, the movsb command looks only at the si and di registers (first 16 bits of the esi and edi registers). However I can use "db 0x67" to manually insert the address size override byte in front of the movsb opcode. This will force it to use the entire 32bits of the esi and edi registers. However, I'm wondering if there's a proper instruction for this. I've tried "movsb long", and "movsb far". And so far I can't find any instruction that will cause NASM to write the 0x67 byte in front of the opcode for movsb.

debs3759:
You can use the a32 prefix to override the address size. In your case, that would be


--- Code: ---a32 movsb

--- End code ---

Similarly, to use 16 bit addressing in 32 bit code, you can use the a16 prefix

To override operand size, it's o16 and o32

ben321:

--- Quote from: debs3759 on December 16, 2023, 05:38:46 PM ---You can use the a32 prefix to override the address size. In your case, that would be


--- Code: ---a32 movsb

--- End code ---

Similarly, to use 16 bit addressing in 32 bit code, you can use the a16 prefix

To override operand size, it's o16 and o32

--- End quote ---

Thanks for the info. Is that somewhere in the manual? Or more of a hidden function?

Also, movsb is usually used with rep, so where does the a32 go in this case? Before or after the rep?

debs3759:
Yes, it's in the manual, that's what I checked before replying. In version 2.07 of the manual, it's described in section 10.3. In version 0.98, it was section 9.3. They're the two version I currently use for reference.

I think the REP would be the first prefix, so you repeat the o32 each time round. Not sure on that though, it may work the other way round as well.

Frank Kotler:

"rep" gets its parameter from cx or ecx. np?

Best.
Frank

Navigation

[0] Message Index

[#] Next page

Go to full version