欢迎光临散文网 会员登陆 & 注册

[旋风][6502汇编][16位HEX转DEC]

2019-04-05 00:24 作者:FlameCyclone  | 我要投稿

;[FC][16位HEX转DEC][20190403][旧版]

;FlameCyclone


 .ORG $8000

 

Hex_L = $00

Hex_H = $01

Dec_Digit = $02


DIGIT_COUNT = 05


;零页占用: 7字节

;  程序段: 0x55字节

;$0xFFFF转65535耗时898

;$0x270F转9999耗时1191

;$0x3E7转999耗时738

;$0x63转99耗时332

;$0x09转9耗时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


[旋风][6502汇编][16位HEX转DEC]的评论 (共 条)

分享到微博请遵守国家法律