[旋風(fēng)][6502匯編][16位HEX轉(zhuǎn)DEC]

;[FC][16位HEX轉(zhuǎn)DEC][20190403][舊版]
;FlameCyclone
?.ORG $8000
?
Hex_L = $00
Hex_H = $01
Dec_Digit = $02
DIGIT_COUNT = 05
;零頁占用: 7字節(jié)
;? 程序段: 0x55字節(jié)
;$0xFFFF轉(zhuǎn)65535耗時(shí)898
;$0x270F轉(zhuǎn)9999耗時(shí)1191
;$0x3E7轉(zhuǎn)999耗時(shí)738
;$0x63轉(zhuǎn)99耗時(shí)332
;$0x09轉(zhuǎn)9耗時(shí)134
?LDX #$FF
?TXS
?LDA #$0F
?STA Hex_L
?LDA #$27
?STA Hex_H
?JSR Hex_To_Dec
?RTS
Hex_To_Dec:?
?LDY #$00
?LDX #DIGIT_COUNT - $02
Convert_Compare:
?LDA Hex_H
?CMP Dec_Data_H,X
?BCC Convert_Digit_End
?BNE Subtraction_16Bit
?LDA Hex_L
LowByte_Compare:
?CMP Dec_Data_L,X
?BCC Convert_Digit_End
?BEQ Subtraction_16Bit
Subtraction_8Bit:
?SBC Dec_Data_L,X
?STA Hex_L
?INY
?BNE LowByte_Compare
Subtraction_16Bit:
?LDA Hex_L
?SBC Dec_Data_L,X
?STA Hex_L
?BCS Subtraction_16Bit_NoBrrow
?DEC Hex_H
Subtraction_16Bit_NoBrrow:
?LDA Hex_H
?SEC
?SBC Dec_Data_H,X
?STA Hex_H
Set_Digit:
?INY
?BNE Convert_Compare
Convert_Digit_End:
?STY Dec_Digit + 1,X
?LDY #$00
?DEX
?BPL Convert_Compare
Convert_Finish:
?STA Dec_Digit
?RTS
Dec_Data_L:
?.DB $0A,$64,$E8,$10
Dec_Data_H:
?.DB $00,$00,$03,$27