4 ; cc65 - a freeware C compiler for 6502 based systems
6 ; https://github.com/cc65/cc65
8 ; See "LICENSE" file for legal information.
11 ; unsigned int __fastcall__ mul20(unsigned char value);
13 ; REMARKS: Function is defined to return with carry-flag cleared
19 .proc _mul20 ; = 30 bytes, 41/46 cycles
21 sta tmp4 ; remember value for later addition...
22 ldx #0 ; clear high-byte
24 bcc mul4 ; high-byte affected?
25 ldx #2 ; this will be the 1st high-bit soon...
28 bcc mul5 ; high-byte affected?
29 inx ; => yes, apply to 0 high-bit
30 clc ; prepare addition
33 bcc mul10 ; high-byte affected?
36 mul10: stx tmp4 ; continue with classic shifting...
44 ldx tmp4 ; deliver high-byte in X