Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

byte PTR

edspitedspit Member Posts: 12
What exactly does this instruction mean?

mov al, byte ptr[si]

Comments

  • brewskibrewski Member Posts: 18
    : What exactly does this instruction mean?
    :
    : mov al, byte ptr[si]
    :
    Byte pointer...it means you want to fetch a byte from the adress.
    if it said word ptr or dword ptr, you would get a word or dword from the adress in source index.

    if you want to move a byte from memory into ax you could use movsx or movzx.
    (extend or zero extend)

    movsx ax,byte ptr[si] - move signed byte to al & the sign into ah...

    movzx ax,byte ptr[si] - move unsigned byte into al & zero into ah...

    same goes for word/mem into dword/reg---movsx eax,word ptr [si] etc...




  • AsmGuru62AsmGuru62 Member Posts: 6,519
    Also, in this case you do not need to say what is the size of data you gonna move, because AL 'says' it will be byte. You can just omit it:
    [code]
    mov al, [si]
    [/code]
    But, here is the place when you need it - say, you have a DWORD as a far pointer (in 16-bit apps) and you have to store ES:BX into that DWORD - here is the sizes of operands are not the same: DWORD = 32bit and ES = 16bit, BX = 16bit, so:
    [code]
    .DATA
    FarDataPtr Dd 0 ; DWORD declared
    .CODE
    mov word ptr [FarDataPtr], bx ; Low word first
    mov word ptr [FarDataPtr+2], es ; High word second

    ; --- Now you can load it into other pair with one shot:
    lds si, FarDataPtr ; DS:SI now points to the same location
    [/code]
    Cheers!

  • Sephiroth2Sephiroth2 Member Posts: 423
    : Also, in this case you do not need to say what is the size of data you gonna move, because AL 'says' it will be byte. You can just omit it:
    : [code]
    : mov al, [si]
    : [/code]
    : But, here is the place when you need it - say, you have a DWORD as a far pointer (in 16-bit apps) and you have to store ES:BX into that DWORD - here is the sizes of operands are not the same: DWORD = 32bit and ES = 16bit, BX = 16bit, so:
    : [code]
    : .DATA
    : FarDataPtr Dd 0 ; DWORD declared
    : .CODE
    : mov word ptr [FarDataPtr], bx ; Low word first
    : mov word ptr [FarDataPtr+2], es ; High word second
    :
    : ; --- Now you can load it into other pair with one shot:
    : lds si, FarDataPtr ; DS:SI now points to the same location
    : [/code]
    : Cheers!
    :
    :
    What, why can you store es in memory all of a sudden? Did I miss an important event?
    Anyway, the word ptr keyword is not needed here either. It is used only in cases like "inc word ptr [blah]" and "move byte ptr [di-1],0"
  • AsmGuru62AsmGuru62 Member Posts: 6,519
    What Assembler are you on? (heh! good one!) I used TASM and it does not allow to store 16-bit reg inside a DWORD without the 'word ptr []'.

Sign In or Register to comment.