好的,这是伙计们。在你之前,我有一个执行这个算法的程序: "如果X> 12那么X = 2 * X + 4 ELSE X = X + Y,输出X."
问题是,我需要它来执行这个: "如果X> 12那么X = 2 * X + 4 ELSE X = X - 13,输出X。"
我如何减去而不是添加?
ORG $1000
START: LEA PROMPT, A1
MOVE.B #14, D0 ; display string
TRAP #15
MOVE.B #4, D0 ; read from keyboard
TRAP #15
MOVE D1, D3 ; copy X
LEA STTY, A1
MOVE.B #14, D0 ; display string
TRAP #15
CMP #12, D3 ; X > 12 ?
BGT MULTADD ; branch if yes
CMP #12, D3 ; why compare again??
BRA ADDY
MULTADD
LEA XGT, A1
MOVE.B #14, D0 ; display string
TRAP #15
LEA TWOXP4, A1
MOVE.B #14, D0 ; display string
TRAP #15
MULU #2, D3 ; 2*X
ADD #4, D3 ; +4
MOVE D3, D1 ; copy to D1
MOVE.B #3, D0 ; Display decimal signed D1.L in smallest field
TRAP #15
BRA FIN
ADDY LEA XLT, A1
MOVE.B #14, D0 ; display string
TRAP #15
LEA XPY, A1
MOVE.B #14, D0 ; display string
TRAP #15
ADD Y, D3 ; X = X+Y
MOVE D3, D1
MOVE.B #3, D0 ; Display decimal signed D1.L in smallest field
TRAP #15
BRA FIN ; not needed
FIN MOVE.B #9,D0 ; terminate program
TRAP #15
* Variables and Strings
PROMPT DC.B ';Enter X: ';, 0
STTY DC.B ';Y = 4';, CR, LF, 0
XGT DC.B 'X > 12';, CR, LF, 0
XLT DC.B 'X != 12';, CR, LF, 0
TWOXP4 DC.B 2 * X + 4 = ';, CR, LF, 0
XPY DC.B 'X + Y = ';, 0
Y DC.W 4
CR EQU $0D
LF EQU $0A
END START
答案 0 :(得分:1)
提示:
ORG $1000
START: LEA PROMPT, A1
MOVEQ #14, D0 ; display string
TRAP #15
MOVEQ #4, D0 ; read number from keyboard
TRAP #15
MOVE.L D1,D3 ; save X
LEA STTY, A1
MOVEQ #14, D0 ; display string
TRAP #15
CMP.L #12, D3 ; X > 12 ?
BGT MULTADD ; branch if yes
ADDY LEA XLT, A1
MOVEQ #14, D0 ; display string
TRAP #15
LEA XPY, A1
MOVEQ #14, D0 ; display string
TRAP #15
ADD.L Y, D3 ; X = X+Y, change to SUB.L Y,D3
MOVE.L D3, D1
MOVEQ #3, D0 ; Display decimal signed D1.L in smallest field
TRAP #15
BRA FIN ; not needed
MULTADD
LEA XGT, A1
MOVEQ #14, D0 ; display string
TRAP #15
LEA TWOXP4, A1
MOVEQ #14, D0 ; display string
TRAP #15
ASL.L #1, D3 ; 2*X by shifting
ADDQ.L #4, D3 ; +4
MOVE.L D3, D1 ; copy to D1
MOVEQ #3, D0 ; Display decimal signed D1.L in smallest field
TRAP #15
FIN MOVEQ #9,D0 ; terminate program
TRAP #15
* Variables and Strings
CR EQU $0D
LF EQU $0A
PROMPT DC.B ';Enter X: ';, 0
STTY DC.B ';Y = 4';, CR, LF, 0
XGT DC.B 'X > 12';, CR, LF, 0
XLT DC.B 'X != 12';, CR, LF, 0
TWOXP4 DC.B 2 * X + 4 = ';, CR, LF, 0
XPY DC.B 'X + Y = ';, 0
Y DC.L 13
END START
答案 1 :(得分:0)
无法测试,但尝试更换
SELECT *
FROM Product p
JOIN Orders o ON o.ProductID = p.ProductID
WHERE
p.ProductID = '657768' AND
Discount = 0.06;
使用
ADD Y, D3