; ORG 0000H MOV 38H, #77H MOV 39H, #03H MOV 3AH, #45H MOV 3BH, #39H MOV 3CH, #0AH MOV 3DH, #4BH MOV 3EH, #91H MOV 3FH, #21H MOV 40H, #64H MOV 41H, #62H MOV 42H, #66H MOV 43H, #69H MOV 44H, #6AH MOV 45H, #6BH MOV 46H, #60H MOV 47H, #54H MOV 48H, #34H MOV 49H, #94H MOV 4AH, #14H MOV 4BH, #54H MOV 4CH, #24H MOV 4DH, #64H MOV 4EH, #84H MOV 4FH, #74H MOV 50H, #24H MOV 51H, #88H CALL SORT NOP NOP ;將50h至39h的資料從大到小排列 SORT: MOV 30H, #50H S1: MOV R0, #39H S2: MOV A, @R0 INC R0 MOV B, @R0 CJNE A, B, $ + 3 JC S3 MOV @R0, A DEC R0 MOV @R0, B INC R0 S3: MOV A, R0 CJNE A, 30H, S2 DEC 30H MOV A, 30H CJNE A, #3AH, S1 RET END 已經測試透過,符合題目要求。
; ORG 0000H MOV 38H, #77H MOV 39H, #03H MOV 3AH, #45H MOV 3BH, #39H MOV 3CH, #0AH MOV 3DH, #4BH MOV 3EH, #91H MOV 3FH, #21H MOV 40H, #64H MOV 41H, #62H MOV 42H, #66H MOV 43H, #69H MOV 44H, #6AH MOV 45H, #6BH MOV 46H, #60H MOV 47H, #54H MOV 48H, #34H MOV 49H, #94H MOV 4AH, #14H MOV 4BH, #54H MOV 4CH, #24H MOV 4DH, #64H MOV 4EH, #84H MOV 4FH, #74H MOV 50H, #24H MOV 51H, #88H CALL SORT NOP NOP ;將50h至39h的資料從大到小排列 SORT: MOV 30H, #50H S1: MOV R0, #39H S2: MOV A, @R0 INC R0 MOV B, @R0 CJNE A, B, $ + 3 JC S3 MOV @R0, A DEC R0 MOV @R0, B INC R0 S3: MOV A, R0 CJNE A, 30H, S2 DEC 30H MOV A, 30H CJNE A, #3AH, S1 RET END 已經測試透過,符合題目要求。