範例:CPU0 組合語言 - 模擬 if 條件
        LD  R1, A     ; R1 = A;         //
        LD  R2, B     ; R2 = B;         //
        CMP R1, R2    ; If (R1 > R2)    // if (A > B)
        JGT LABEL1    ;   goto LABEL1;  //
        ST  R2, C     ; C = R2;         //    C = A
        JMP LABEL2    ; goto LABEL2     // else
LABEL1: ST  R1, C     ; C = R1          //    C = B
LABEL2:
        LD     R1, A            ; R1 = A;                    //
        LD     R2, B            ; R2 = B;                    //
        CMP R1, R2            ; If (R1 > R2)                // if (A > B)
        JGT LABEL1            ;   goto LABEL1;            //
        ST     R2, C            ; C = R2;                    //    C = A
        JMP LABEL2            ; goto LABEL2                // else
LABEL1:    ST     R1, C            ; C = R1                    //    C = B
LABEL2:
CPU0 組合語言 C語言 (對照版) C語言
        LD     R1, A
        LD     R2, B
        CMP R1, R2
        JGT LABEL1
        ST     R2, C
        JMP LABEL2
LABEL1:    ST     R1, C
LABEL2:
        R1 = A;
        R2 = B;
        If (R1 > R2)
            goto LABEL1;
        C = R2;
        goto LABEL2
LABEL1:    C = R1
LABEL2:
If (A>B)
  C = A;
else
  C = B;
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License