Howdy, Stranger!

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

Categories

adding registers of different sizes

hello

It is possible to do something like this?: add ax,bl (adding registers of different sizes?)

(apparently no, because it gives me an error when a try to compile... )

I'm a beginner and I need some help plz.

Comments

  • BretBret Member Posts: 114
    In general, you can't do any type of mathematical operations (ADD, SUB, MUL, DIV, IMUL, IDIV) on registers of two different sizes. In your example (assuming you need BX to remain unchanged), you would need to do something like this if the values in the registers are unsigned:

    PUSH BX
    MOV BH,0
    ADD AX,BX
    POP BX

    and something like this if the values are signed:

    PUSH BX
    XCHG AX,BX
    CBW
    ADD AX,BX
    POP BX

    If you don't need BX to be preserved, you can omit the PUSH & POP.
  • __digital____digital__ Member Posts: 2
    I see

    Great response time!
    Thank you Bret
Sign In or Register to comment.