将以下代码翻译成汇编语言并显示最终的 Y 值。(2 分)
X = 1; Y = 2; WHILE(X <= 10 ){ IF((X%2) != 0) Y = Y * X; ELSE Y++; X++;} Output Y
请让我知道我做的一切是否正确,因为我不确定我的输出是否正确。结果是 3712
*-----------------------------------------------------------
* Title :
* Written by :
* Date :
* Description:
*-----------------------------------------------------------
ORG $1000
START: ; first instruction of program
* Put program code here
MOVE.W #1,D1 ;PUT 0 IN D1 (X)
MOVE.W #2,D2 ;PUT 1 IN D2 (Y)
LOOP CLR.W D3 ;Find the remainder
MOVE.W D1,D3
DIVU #2,D3
SWAP D3
CMP #0,D3 ;Compare remainder with 0
BNE NOTEQUAL ;If NOT equal, then go to NOT equal
ADD.W #1,D2 ;Y++
ADD.W #1,D1 ;X++
CMP #11,D1 ;Compare D1 with 11
BEQ DONE ;If D1 equals 11, break loop.
BRA LOOP
NOTEQUAL
MULU.W D1,D2 ;Multiply D1 and D2 and store it in D2
ADD.W #1,D1 ;X++
CMP #11,D1 ;Compare D1 with 11
BEQ DONE ;If D1 equals 11, break loop.
BRA LOOP
DONE LEA MESSAGE,A1
MOVE.W #14,D0
TRAP #15
MOVE.W D2,D1
MOVE.W #3,D0
TRAP #15
SIMHALT ; halt simulator
* Put variables and constants here
MESSAGE DC.W 'Y is: ',0
END START ; last line of source