Search code examples
variablesassemblysegment

what will moving variable to the code segment do in assembly?


when I do

 mov [cs:10], dl 

what change does it make in the code? isn't dl stored in the data segment?

thank you


Solution

  • what change does it make in the code?

    The instruction mov [cs:10], dl does not necessarily change anything to the code. It just overwrites whatever byte value that is at address 10 in the code segment. This byte could contain (part of) an instruction or it could contain just data.

    isn't dl stored in the data segment?

    Since the instruction had a CS: segment override the DL register contents are stored in the code segment. Without this segment override the DL register contents would have been stored in the data segment addressed by DS.

    what will moving variable to the code segment do in assembly?

    The assembly language needs you to be exact. The instruction does not reference any variable. It envolves a register.