Find some X^2 - Y^2 equal to a given Z












0














Request input (Z) from user, -65535<=Z<=65535. Check if (X^2)-(Y^2)=Z (while 0<=X,Y<=1000).
I wrote a code which will receive Z from user, if it's negative, store the negative value and continue as if Z is positive. Two loops, one which will check Y from 0-1000, after that add 1 to X and continue, until both X and Y are 1000 (meaning no answer) or until an answer is found. If Z contained a negative value, exchange X and Y after answer is found.
Would love to see some reviews.



    .MODEL SMALL
.STACK 100h
.DATA
EnterNum DB 13,10,'Please enter a number between (and including) -65535 and 65535: ',13,10,'$'
AnswerSTR DB 13,10,'Z = , X = , Y = ',13,10,'$'
WrongSTR DB 13,10,'Wrong input, please type a number again (-65535 <= X <= 65535): ',13,10,'$'
NoAnswerSTR DB 13,10,' has no solution below 1000',13,10,'$'
Z DD ?
X DD ?
Y DD ?
I DD ?
J DD ?
NumSign DD 1
Ten DD 10
.CODE
.386
MOV AX,@DATA
MOV DS,AX
XOR EAX,EAX
MOV CX,6 ;Initialize CX for the loop of receiving num
MOV AH,9
MOV DX,OFFSET EnterNum
INT 21h ;Print request num from user
TypeAgain:
XOR DX,DX
ReceiveNum:
MOV AH,1
INT 21h
CMP AL,45 ;Ascii for minus
JE SignSave
CMP AL,13 ;Ascii for enter key
JE EnterKey
SUB AL,'0' ;Convert from Ascii value to numeral value (if reached this point then it's SUPPOSED to be a number)
CMP AL,0
JB WrongInput
CMP AL,9
JA WrongInput ;Check if input is correct (0-9)
XOR AH,AH
ADD Z,EAX ;Save digit in Z
MOV EAX,Z
MUL Ten
MOV Z,EAX ;Save digit multiplied by 10 in order to make place for the new digit (if enter, will go to EnterKey label)
XOR EAX,EAX
LOOP ReceiveNum
MOV AH,1
INT 21h
SUB AL,'0'
CMP AL,0
JB WrongInput
CMP AL,9
JA WrongInput
XOR AH,AH
ADD Z,EAX ;Receive last digit in number
JMP Initialize
WrongInput:
MOV AH,9
MOV DX,OFFSET WrongSTR
INT 21h
JMP TypeAgain
SignSave:
MOV NumSign,-1
JMP ReceiveNum
EnterKey:
XOR EAX,EAX
MOV EAX,Z
DIV Ten
MOV Z,EAX ;Z has number entered by user
Initialize:
MOV X,0
MOV I,0
MOV J,0
JMP CheckAnswerX ;Z will have number from user, NumSign will have -1 if number is negative (remain 1 if positive)
IncX:
XOR EAX,EAX
INC I ;To help with count of X
MOV EAX,I
MOV X,EAX
MUL X
MOV X,EAX ;X contains the value of X^2
CheckAnswerX:
XOR EAX,EAX
MOV Y,0
MOV J,0
CheckAnswerY:
XOR EAX,EAX
MOV EAX,J
MOV Y,EAX
MUL Y
MOV Y,EAX ;Y contains value of Y^2
XOR EAX,EAX
MOV EAX,X
SUB EAX,Y ;EAX - Y, keep value in EAX
CMP EAX,Z
JNE ContinueCheck
JMP Answer ;Meaning they're equal and we have the answer
ContinueCheck:
XOR EAX,EAX
MOV EAX,I
ADD EAX,J
CMP EAX,2002 ;Check if X and Y made their 1001 loop separately (sum of both is 2002)
JE NoAnswerStop
XOR EAX,EAX
MOV EAX,J
CMP EAX,1001 ;Check if Y made it's 0-1000 run
JE IncX ;Meaning Y needs to start from 0 again and add 1 to X
INC J ;To help with count of Y
JMP CheckAnswerY
Answer:
XOR EAX,EAX
MOV EAX,I
MOV X,EAX ;X contains it's original value of the answer (before the degree)
XOR EAX,EAX
MOV EAX,J
MOV Y,EAX ;Y contains it's original value of the answer (before the degree)
CMP NumSign,-1 ;If Z has a negative value
JE ExchangeXY
JMP Answer2 ;Else jump to Answer2 label
ExchangeXY: ;Exchange Y and X values so we receive correct negative Z
XOR EAX,EAX
MOV EAX,X
XCHG EAX,Y
MOV X,EAX
Answer2: ;Start inserting the values of Y, X and Z into the string
XOR CX,CX
MOV CX,4
XOR SI,SI
MOV SI,31
MOV EAX,Y
ReplaceAnswerY:
DIV Ten
ADD DL,'0' ;Convert from numeral value to Ascii value
MOV AnswerSTR[SI],DL
DEC SI
XOR EDX,EDX
LOOP ReplaceAnswerY
XOR CX,CX
MOV CX,4
XOR SI,SI
MOV SI,21
MOV EAX,X
ReplaceAnswerX:
DIV Ten
ADD DL,'0'
MOV AnswerSTR[SI],DL
DEC SI
XOR EDX,EDX
LOOP ReplaceAnswerX
JMP ReplaceAnswerContinueX
NoAnswerStop:
JMP NoAnswer
ReplaceAnswerContinueX:
XOR CX,CX
MOV CX,6
XOR SI,SI
MOV SI,11
MOV EAX,Z
ReplaceAnswerZ:
DIV Ten
ADD DL,'0'
MOV AnswerSTR[SI],DL
DEC SI
XOR EDX,EDX
LOOP ReplaceAnswerZ
CMP NumSign,-1
JE ChangeSignString
MOV AH,9
MOV DX,OFFSET AnswerSTR
INT 21h
JMP CodeEnd
ChangeSignString:
MOV AL,45
MOV AnswerSTR[5],AL
MOV AH,9
MOV DX,OFFSET AnswerSTR
INT 21h
JMP CodeEnd
NoAnswer: ;Insert value of Z into the string
XOR CX,CX
MOV CX,6
XOR SI,SI
MOV SI,7
MOV EAX,Z
ReplaceNoAnswerZ:
DIV Ten
ADD DL,'0'
MOV NoAnswerSTR[SI],DL
DEC SI
XOR EDX,EDX
LOOP ReplaceNoAnswerZ
MOV AH,9
MOV DX,OFFSET NoAnswerSTR
INT 21h
CodeEnd:
MOV AH,4Ch
INT 21h
END









share|improve this question





























    0














    Request input (Z) from user, -65535<=Z<=65535. Check if (X^2)-(Y^2)=Z (while 0<=X,Y<=1000).
    I wrote a code which will receive Z from user, if it's negative, store the negative value and continue as if Z is positive. Two loops, one which will check Y from 0-1000, after that add 1 to X and continue, until both X and Y are 1000 (meaning no answer) or until an answer is found. If Z contained a negative value, exchange X and Y after answer is found.
    Would love to see some reviews.



        .MODEL SMALL
    .STACK 100h
    .DATA
    EnterNum DB 13,10,'Please enter a number between (and including) -65535 and 65535: ',13,10,'$'
    AnswerSTR DB 13,10,'Z = , X = , Y = ',13,10,'$'
    WrongSTR DB 13,10,'Wrong input, please type a number again (-65535 <= X <= 65535): ',13,10,'$'
    NoAnswerSTR DB 13,10,' has no solution below 1000',13,10,'$'
    Z DD ?
    X DD ?
    Y DD ?
    I DD ?
    J DD ?
    NumSign DD 1
    Ten DD 10
    .CODE
    .386
    MOV AX,@DATA
    MOV DS,AX
    XOR EAX,EAX
    MOV CX,6 ;Initialize CX for the loop of receiving num
    MOV AH,9
    MOV DX,OFFSET EnterNum
    INT 21h ;Print request num from user
    TypeAgain:
    XOR DX,DX
    ReceiveNum:
    MOV AH,1
    INT 21h
    CMP AL,45 ;Ascii for minus
    JE SignSave
    CMP AL,13 ;Ascii for enter key
    JE EnterKey
    SUB AL,'0' ;Convert from Ascii value to numeral value (if reached this point then it's SUPPOSED to be a number)
    CMP AL,0
    JB WrongInput
    CMP AL,9
    JA WrongInput ;Check if input is correct (0-9)
    XOR AH,AH
    ADD Z,EAX ;Save digit in Z
    MOV EAX,Z
    MUL Ten
    MOV Z,EAX ;Save digit multiplied by 10 in order to make place for the new digit (if enter, will go to EnterKey label)
    XOR EAX,EAX
    LOOP ReceiveNum
    MOV AH,1
    INT 21h
    SUB AL,'0'
    CMP AL,0
    JB WrongInput
    CMP AL,9
    JA WrongInput
    XOR AH,AH
    ADD Z,EAX ;Receive last digit in number
    JMP Initialize
    WrongInput:
    MOV AH,9
    MOV DX,OFFSET WrongSTR
    INT 21h
    JMP TypeAgain
    SignSave:
    MOV NumSign,-1
    JMP ReceiveNum
    EnterKey:
    XOR EAX,EAX
    MOV EAX,Z
    DIV Ten
    MOV Z,EAX ;Z has number entered by user
    Initialize:
    MOV X,0
    MOV I,0
    MOV J,0
    JMP CheckAnswerX ;Z will have number from user, NumSign will have -1 if number is negative (remain 1 if positive)
    IncX:
    XOR EAX,EAX
    INC I ;To help with count of X
    MOV EAX,I
    MOV X,EAX
    MUL X
    MOV X,EAX ;X contains the value of X^2
    CheckAnswerX:
    XOR EAX,EAX
    MOV Y,0
    MOV J,0
    CheckAnswerY:
    XOR EAX,EAX
    MOV EAX,J
    MOV Y,EAX
    MUL Y
    MOV Y,EAX ;Y contains value of Y^2
    XOR EAX,EAX
    MOV EAX,X
    SUB EAX,Y ;EAX - Y, keep value in EAX
    CMP EAX,Z
    JNE ContinueCheck
    JMP Answer ;Meaning they're equal and we have the answer
    ContinueCheck:
    XOR EAX,EAX
    MOV EAX,I
    ADD EAX,J
    CMP EAX,2002 ;Check if X and Y made their 1001 loop separately (sum of both is 2002)
    JE NoAnswerStop
    XOR EAX,EAX
    MOV EAX,J
    CMP EAX,1001 ;Check if Y made it's 0-1000 run
    JE IncX ;Meaning Y needs to start from 0 again and add 1 to X
    INC J ;To help with count of Y
    JMP CheckAnswerY
    Answer:
    XOR EAX,EAX
    MOV EAX,I
    MOV X,EAX ;X contains it's original value of the answer (before the degree)
    XOR EAX,EAX
    MOV EAX,J
    MOV Y,EAX ;Y contains it's original value of the answer (before the degree)
    CMP NumSign,-1 ;If Z has a negative value
    JE ExchangeXY
    JMP Answer2 ;Else jump to Answer2 label
    ExchangeXY: ;Exchange Y and X values so we receive correct negative Z
    XOR EAX,EAX
    MOV EAX,X
    XCHG EAX,Y
    MOV X,EAX
    Answer2: ;Start inserting the values of Y, X and Z into the string
    XOR CX,CX
    MOV CX,4
    XOR SI,SI
    MOV SI,31
    MOV EAX,Y
    ReplaceAnswerY:
    DIV Ten
    ADD DL,'0' ;Convert from numeral value to Ascii value
    MOV AnswerSTR[SI],DL
    DEC SI
    XOR EDX,EDX
    LOOP ReplaceAnswerY
    XOR CX,CX
    MOV CX,4
    XOR SI,SI
    MOV SI,21
    MOV EAX,X
    ReplaceAnswerX:
    DIV Ten
    ADD DL,'0'
    MOV AnswerSTR[SI],DL
    DEC SI
    XOR EDX,EDX
    LOOP ReplaceAnswerX
    JMP ReplaceAnswerContinueX
    NoAnswerStop:
    JMP NoAnswer
    ReplaceAnswerContinueX:
    XOR CX,CX
    MOV CX,6
    XOR SI,SI
    MOV SI,11
    MOV EAX,Z
    ReplaceAnswerZ:
    DIV Ten
    ADD DL,'0'
    MOV AnswerSTR[SI],DL
    DEC SI
    XOR EDX,EDX
    LOOP ReplaceAnswerZ
    CMP NumSign,-1
    JE ChangeSignString
    MOV AH,9
    MOV DX,OFFSET AnswerSTR
    INT 21h
    JMP CodeEnd
    ChangeSignString:
    MOV AL,45
    MOV AnswerSTR[5],AL
    MOV AH,9
    MOV DX,OFFSET AnswerSTR
    INT 21h
    JMP CodeEnd
    NoAnswer: ;Insert value of Z into the string
    XOR CX,CX
    MOV CX,6
    XOR SI,SI
    MOV SI,7
    MOV EAX,Z
    ReplaceNoAnswerZ:
    DIV Ten
    ADD DL,'0'
    MOV NoAnswerSTR[SI],DL
    DEC SI
    XOR EDX,EDX
    LOOP ReplaceNoAnswerZ
    MOV AH,9
    MOV DX,OFFSET NoAnswerSTR
    INT 21h
    CodeEnd:
    MOV AH,4Ch
    INT 21h
    END









    share|improve this question



























      0












      0








      0







      Request input (Z) from user, -65535<=Z<=65535. Check if (X^2)-(Y^2)=Z (while 0<=X,Y<=1000).
      I wrote a code which will receive Z from user, if it's negative, store the negative value and continue as if Z is positive. Two loops, one which will check Y from 0-1000, after that add 1 to X and continue, until both X and Y are 1000 (meaning no answer) or until an answer is found. If Z contained a negative value, exchange X and Y after answer is found.
      Would love to see some reviews.



          .MODEL SMALL
      .STACK 100h
      .DATA
      EnterNum DB 13,10,'Please enter a number between (and including) -65535 and 65535: ',13,10,'$'
      AnswerSTR DB 13,10,'Z = , X = , Y = ',13,10,'$'
      WrongSTR DB 13,10,'Wrong input, please type a number again (-65535 <= X <= 65535): ',13,10,'$'
      NoAnswerSTR DB 13,10,' has no solution below 1000',13,10,'$'
      Z DD ?
      X DD ?
      Y DD ?
      I DD ?
      J DD ?
      NumSign DD 1
      Ten DD 10
      .CODE
      .386
      MOV AX,@DATA
      MOV DS,AX
      XOR EAX,EAX
      MOV CX,6 ;Initialize CX for the loop of receiving num
      MOV AH,9
      MOV DX,OFFSET EnterNum
      INT 21h ;Print request num from user
      TypeAgain:
      XOR DX,DX
      ReceiveNum:
      MOV AH,1
      INT 21h
      CMP AL,45 ;Ascii for minus
      JE SignSave
      CMP AL,13 ;Ascii for enter key
      JE EnterKey
      SUB AL,'0' ;Convert from Ascii value to numeral value (if reached this point then it's SUPPOSED to be a number)
      CMP AL,0
      JB WrongInput
      CMP AL,9
      JA WrongInput ;Check if input is correct (0-9)
      XOR AH,AH
      ADD Z,EAX ;Save digit in Z
      MOV EAX,Z
      MUL Ten
      MOV Z,EAX ;Save digit multiplied by 10 in order to make place for the new digit (if enter, will go to EnterKey label)
      XOR EAX,EAX
      LOOP ReceiveNum
      MOV AH,1
      INT 21h
      SUB AL,'0'
      CMP AL,0
      JB WrongInput
      CMP AL,9
      JA WrongInput
      XOR AH,AH
      ADD Z,EAX ;Receive last digit in number
      JMP Initialize
      WrongInput:
      MOV AH,9
      MOV DX,OFFSET WrongSTR
      INT 21h
      JMP TypeAgain
      SignSave:
      MOV NumSign,-1
      JMP ReceiveNum
      EnterKey:
      XOR EAX,EAX
      MOV EAX,Z
      DIV Ten
      MOV Z,EAX ;Z has number entered by user
      Initialize:
      MOV X,0
      MOV I,0
      MOV J,0
      JMP CheckAnswerX ;Z will have number from user, NumSign will have -1 if number is negative (remain 1 if positive)
      IncX:
      XOR EAX,EAX
      INC I ;To help with count of X
      MOV EAX,I
      MOV X,EAX
      MUL X
      MOV X,EAX ;X contains the value of X^2
      CheckAnswerX:
      XOR EAX,EAX
      MOV Y,0
      MOV J,0
      CheckAnswerY:
      XOR EAX,EAX
      MOV EAX,J
      MOV Y,EAX
      MUL Y
      MOV Y,EAX ;Y contains value of Y^2
      XOR EAX,EAX
      MOV EAX,X
      SUB EAX,Y ;EAX - Y, keep value in EAX
      CMP EAX,Z
      JNE ContinueCheck
      JMP Answer ;Meaning they're equal and we have the answer
      ContinueCheck:
      XOR EAX,EAX
      MOV EAX,I
      ADD EAX,J
      CMP EAX,2002 ;Check if X and Y made their 1001 loop separately (sum of both is 2002)
      JE NoAnswerStop
      XOR EAX,EAX
      MOV EAX,J
      CMP EAX,1001 ;Check if Y made it's 0-1000 run
      JE IncX ;Meaning Y needs to start from 0 again and add 1 to X
      INC J ;To help with count of Y
      JMP CheckAnswerY
      Answer:
      XOR EAX,EAX
      MOV EAX,I
      MOV X,EAX ;X contains it's original value of the answer (before the degree)
      XOR EAX,EAX
      MOV EAX,J
      MOV Y,EAX ;Y contains it's original value of the answer (before the degree)
      CMP NumSign,-1 ;If Z has a negative value
      JE ExchangeXY
      JMP Answer2 ;Else jump to Answer2 label
      ExchangeXY: ;Exchange Y and X values so we receive correct negative Z
      XOR EAX,EAX
      MOV EAX,X
      XCHG EAX,Y
      MOV X,EAX
      Answer2: ;Start inserting the values of Y, X and Z into the string
      XOR CX,CX
      MOV CX,4
      XOR SI,SI
      MOV SI,31
      MOV EAX,Y
      ReplaceAnswerY:
      DIV Ten
      ADD DL,'0' ;Convert from numeral value to Ascii value
      MOV AnswerSTR[SI],DL
      DEC SI
      XOR EDX,EDX
      LOOP ReplaceAnswerY
      XOR CX,CX
      MOV CX,4
      XOR SI,SI
      MOV SI,21
      MOV EAX,X
      ReplaceAnswerX:
      DIV Ten
      ADD DL,'0'
      MOV AnswerSTR[SI],DL
      DEC SI
      XOR EDX,EDX
      LOOP ReplaceAnswerX
      JMP ReplaceAnswerContinueX
      NoAnswerStop:
      JMP NoAnswer
      ReplaceAnswerContinueX:
      XOR CX,CX
      MOV CX,6
      XOR SI,SI
      MOV SI,11
      MOV EAX,Z
      ReplaceAnswerZ:
      DIV Ten
      ADD DL,'0'
      MOV AnswerSTR[SI],DL
      DEC SI
      XOR EDX,EDX
      LOOP ReplaceAnswerZ
      CMP NumSign,-1
      JE ChangeSignString
      MOV AH,9
      MOV DX,OFFSET AnswerSTR
      INT 21h
      JMP CodeEnd
      ChangeSignString:
      MOV AL,45
      MOV AnswerSTR[5],AL
      MOV AH,9
      MOV DX,OFFSET AnswerSTR
      INT 21h
      JMP CodeEnd
      NoAnswer: ;Insert value of Z into the string
      XOR CX,CX
      MOV CX,6
      XOR SI,SI
      MOV SI,7
      MOV EAX,Z
      ReplaceNoAnswerZ:
      DIV Ten
      ADD DL,'0'
      MOV NoAnswerSTR[SI],DL
      DEC SI
      XOR EDX,EDX
      LOOP ReplaceNoAnswerZ
      MOV AH,9
      MOV DX,OFFSET NoAnswerSTR
      INT 21h
      CodeEnd:
      MOV AH,4Ch
      INT 21h
      END









      share|improve this question















      Request input (Z) from user, -65535<=Z<=65535. Check if (X^2)-(Y^2)=Z (while 0<=X,Y<=1000).
      I wrote a code which will receive Z from user, if it's negative, store the negative value and continue as if Z is positive. Two loops, one which will check Y from 0-1000, after that add 1 to X and continue, until both X and Y are 1000 (meaning no answer) or until an answer is found. If Z contained a negative value, exchange X and Y after answer is found.
      Would love to see some reviews.



          .MODEL SMALL
      .STACK 100h
      .DATA
      EnterNum DB 13,10,'Please enter a number between (and including) -65535 and 65535: ',13,10,'$'
      AnswerSTR DB 13,10,'Z = , X = , Y = ',13,10,'$'
      WrongSTR DB 13,10,'Wrong input, please type a number again (-65535 <= X <= 65535): ',13,10,'$'
      NoAnswerSTR DB 13,10,' has no solution below 1000',13,10,'$'
      Z DD ?
      X DD ?
      Y DD ?
      I DD ?
      J DD ?
      NumSign DD 1
      Ten DD 10
      .CODE
      .386
      MOV AX,@DATA
      MOV DS,AX
      XOR EAX,EAX
      MOV CX,6 ;Initialize CX for the loop of receiving num
      MOV AH,9
      MOV DX,OFFSET EnterNum
      INT 21h ;Print request num from user
      TypeAgain:
      XOR DX,DX
      ReceiveNum:
      MOV AH,1
      INT 21h
      CMP AL,45 ;Ascii for minus
      JE SignSave
      CMP AL,13 ;Ascii for enter key
      JE EnterKey
      SUB AL,'0' ;Convert from Ascii value to numeral value (if reached this point then it's SUPPOSED to be a number)
      CMP AL,0
      JB WrongInput
      CMP AL,9
      JA WrongInput ;Check if input is correct (0-9)
      XOR AH,AH
      ADD Z,EAX ;Save digit in Z
      MOV EAX,Z
      MUL Ten
      MOV Z,EAX ;Save digit multiplied by 10 in order to make place for the new digit (if enter, will go to EnterKey label)
      XOR EAX,EAX
      LOOP ReceiveNum
      MOV AH,1
      INT 21h
      SUB AL,'0'
      CMP AL,0
      JB WrongInput
      CMP AL,9
      JA WrongInput
      XOR AH,AH
      ADD Z,EAX ;Receive last digit in number
      JMP Initialize
      WrongInput:
      MOV AH,9
      MOV DX,OFFSET WrongSTR
      INT 21h
      JMP TypeAgain
      SignSave:
      MOV NumSign,-1
      JMP ReceiveNum
      EnterKey:
      XOR EAX,EAX
      MOV EAX,Z
      DIV Ten
      MOV Z,EAX ;Z has number entered by user
      Initialize:
      MOV X,0
      MOV I,0
      MOV J,0
      JMP CheckAnswerX ;Z will have number from user, NumSign will have -1 if number is negative (remain 1 if positive)
      IncX:
      XOR EAX,EAX
      INC I ;To help with count of X
      MOV EAX,I
      MOV X,EAX
      MUL X
      MOV X,EAX ;X contains the value of X^2
      CheckAnswerX:
      XOR EAX,EAX
      MOV Y,0
      MOV J,0
      CheckAnswerY:
      XOR EAX,EAX
      MOV EAX,J
      MOV Y,EAX
      MUL Y
      MOV Y,EAX ;Y contains value of Y^2
      XOR EAX,EAX
      MOV EAX,X
      SUB EAX,Y ;EAX - Y, keep value in EAX
      CMP EAX,Z
      JNE ContinueCheck
      JMP Answer ;Meaning they're equal and we have the answer
      ContinueCheck:
      XOR EAX,EAX
      MOV EAX,I
      ADD EAX,J
      CMP EAX,2002 ;Check if X and Y made their 1001 loop separately (sum of both is 2002)
      JE NoAnswerStop
      XOR EAX,EAX
      MOV EAX,J
      CMP EAX,1001 ;Check if Y made it's 0-1000 run
      JE IncX ;Meaning Y needs to start from 0 again and add 1 to X
      INC J ;To help with count of Y
      JMP CheckAnswerY
      Answer:
      XOR EAX,EAX
      MOV EAX,I
      MOV X,EAX ;X contains it's original value of the answer (before the degree)
      XOR EAX,EAX
      MOV EAX,J
      MOV Y,EAX ;Y contains it's original value of the answer (before the degree)
      CMP NumSign,-1 ;If Z has a negative value
      JE ExchangeXY
      JMP Answer2 ;Else jump to Answer2 label
      ExchangeXY: ;Exchange Y and X values so we receive correct negative Z
      XOR EAX,EAX
      MOV EAX,X
      XCHG EAX,Y
      MOV X,EAX
      Answer2: ;Start inserting the values of Y, X and Z into the string
      XOR CX,CX
      MOV CX,4
      XOR SI,SI
      MOV SI,31
      MOV EAX,Y
      ReplaceAnswerY:
      DIV Ten
      ADD DL,'0' ;Convert from numeral value to Ascii value
      MOV AnswerSTR[SI],DL
      DEC SI
      XOR EDX,EDX
      LOOP ReplaceAnswerY
      XOR CX,CX
      MOV CX,4
      XOR SI,SI
      MOV SI,21
      MOV EAX,X
      ReplaceAnswerX:
      DIV Ten
      ADD DL,'0'
      MOV AnswerSTR[SI],DL
      DEC SI
      XOR EDX,EDX
      LOOP ReplaceAnswerX
      JMP ReplaceAnswerContinueX
      NoAnswerStop:
      JMP NoAnswer
      ReplaceAnswerContinueX:
      XOR CX,CX
      MOV CX,6
      XOR SI,SI
      MOV SI,11
      MOV EAX,Z
      ReplaceAnswerZ:
      DIV Ten
      ADD DL,'0'
      MOV AnswerSTR[SI],DL
      DEC SI
      XOR EDX,EDX
      LOOP ReplaceAnswerZ
      CMP NumSign,-1
      JE ChangeSignString
      MOV AH,9
      MOV DX,OFFSET AnswerSTR
      INT 21h
      JMP CodeEnd
      ChangeSignString:
      MOV AL,45
      MOV AnswerSTR[5],AL
      MOV AH,9
      MOV DX,OFFSET AnswerSTR
      INT 21h
      JMP CodeEnd
      NoAnswer: ;Insert value of Z into the string
      XOR CX,CX
      MOV CX,6
      XOR SI,SI
      MOV SI,7
      MOV EAX,Z
      ReplaceNoAnswerZ:
      DIV Ten
      ADD DL,'0'
      MOV NoAnswerSTR[SI],DL
      DEC SI
      XOR EDX,EDX
      LOOP ReplaceNoAnswerZ
      MOV AH,9
      MOV DX,OFFSET NoAnswerSTR
      INT 21h
      CodeEnd:
      MOV AH,4Ch
      INT 21h
      END






      assembly x86






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 9 mins ago









      200_success

      128k15149412




      128k15149412










      asked 7 hours ago









      S.Arkab

      264




      264



























          active

          oldest

          votes











          Your Answer





          StackExchange.ifUsing("editor", function () {
          return StackExchange.using("mathjaxEditing", function () {
          StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
          StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
          });
          });
          }, "mathjax-editing");

          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "196"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f210142%2ffind-some-x2-y2-equal-to-a-given-z%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Code Review Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          Use MathJax to format equations. MathJax reference.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f210142%2ffind-some-x2-y2-equal-to-a-given-z%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          404 Error Contact Form 7 ajax form submitting

          How to know if a Active Directory user can login interactively

          TypeError: fit_transform() missing 1 required positional argument: 'X'