1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

I need some help with some basic concepts here.

Discussion in 'Assembly Language Programming (ALP) Forum' started by Punchinello, Apr 18, 2009.

  1. Punchinello

    Punchinello New Member

    Joined:
    Apr 18, 2009
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hello! I'm a beginner of IBM PC assembly language programming and I'm confused with some concepts here so think I need some help.:D
    What are 32-bit instructions and what are 16-bit instructions?
    What is operand-size attribute?
    And with the MOVSX/MOVZX instrucion, if the destination operand is a 32-bit register and the source operand is a memory location, how does the machine decide whether to read a byte or a word from that location?
    Thank you in advance!:D
     
  2. SaswatPadhi

    SaswatPadhi ~ Б0ЯИ Τ0 С0δЭ ~

    Joined:
    May 5, 2009
    Messages:
    1,343
    Likes Received:
    55
    Trophy Points:
    0
    Occupation:
    STUDENT !
    Location:
    Orissa, INDIA
    Home Page:
    (1) Do you mean 16 bit and 32 bit instructions or registers ??
    16 bit registers are ax, bx, cx, dx and 32 bit registers are eax, ebx, ecx, edx.

    (2) Operand size : Any time a memory reference is given as part of an instruction, the size of the memory operand is either implied or must be specified.
    Consider this :
    Code:
    mov ax, ds:bx
    Here, the operand-size WORD is implied since the AX register is one word in size.

    Now, consider this :
    Code:
    inc ds:bx  ;incorrect !!!!!
    This is incorrect since compiler will be confused whether the value pointed to by bx is byte or word in size.
    Correction :
    Code:
    inc word ds:bx  ;increment word at [bx]
    or
    Code:
    inc byte ds:bx  ;increment byte at [bx]
    In the correction, word and byte are operand-size attributes.

    (3) Partly answered in (2). Look at the first example above :
    Code:
    mov ax, ds:bx
    Here compiler assumes that value of [bx] is word because ax has size 1 word. To override, you can write :
    Code:
    mov ax, byte ds:bx
    This will move byte value pointed by bx to ax.

    Hope I cleared your doubts. :pleased:
     
    shabbir likes this.
  3. mayjune

    mayjune New Member

    Joined:
    Jun 14, 2009
    Messages:
    817
    Likes Received:
    33
    Trophy Points:
    0
    Occupation:
    Student
    Location:
    Pune,Delhi
    very well explained saswat..
     
  4. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,012
    Likes Received:
    203
    Trophy Points:
    0
    Occupation:
    Senior Support Engineer
    Location:
    England
    A 32-bit instruction is an instruction that takes up 32 bits, i.e. 4 bytes, whereas a 16-bit instruction is one that takes up 2 bytes.
    Lots of CPUs have varying length instructions, even the old Z80 did; most were one byte but some were as long as 4 bytes.
     
  5. SaswatPadhi

    SaswatPadhi ~ Б0ЯИ Τ0 С0δЭ ~

    Joined:
    May 5, 2009
    Messages:
    1,343
    Likes Received:
    55
    Trophy Points:
    0
    Occupation:
    STUDENT !
    Location:
    Orissa, INDIA
    Home Page:
    Thanx for the feedback ! :)
     

Share This Page