📄 myclib.msa
字号:
strncat_0
ld a,(ix+0)
or a
inc ix
jr nz, strncat_0
dec ix
strncat_1
ld b,(iy+0)
ld (ix+0),b
inc b
dec b
inc ix
inc iy
jr z,strncat_2
ld hl,8
add hl,sp
ld c,(hl)
inc hl
ld b,(hl)
dec bc
ld (hl),b
dec hl
ld (hl),c
inc bc
ld a,c
or b
jr nz,strncat_1
ld (ix-1),a
strncat_2
ld hl,0
add hl,sp
ld b,(hl)
inc hl
ld h,(hl)
ld l,b
pop af
pop ix
pop iy
ret
/******************************************************************************/
strncpy: //----------------------//
call ?ENT_AUTO_DIRECT_L09
defw 0fffeh
push iy
ld e,(ix+8)
ld d,(ix+9)
ld l,(ix+2)
ld h,(ix+3)
push hl
pop iy
ld (ix-2),l
ld (ix-1),h
strncpy_0
ld a,e
ld h,d
dec de
or h
jr z,strncpy_2
ld l,(ix+4)
ld h,(ix+5)
inc hl
ld (ix+4),l
ld (ix+5),h
dec hl
ld b,(hl)
ld (iy+0),b
inc b
dec b
inc iy
jr nz,strncpy_0
strncpy_1
ld a,e
ld h,d
dec de
or h
jr z,strncpy_2
ld (iy+0),0
inc iy
jr strncpy_1
strncpy_2
ld l,(ix-2)
ld h,(ix-1)
pop iy
jp ?LEAVE_DIRECT_L09
/******************************************************************************/
strpbrk: //----------------------//
call ?ENT_AUTO_DIRECT_L09
defw 0000h
push iy
ld e,(ix+2)
ld d,(ix+3)
strpbrk_0
ld l,e
ld h,d
xor a
or (hl)
jr z,strpbrk_3
ld l,(ix+4)
ld h,(ix+5)
push hl
pop iy
strpbrk_1
xor a
or (iy+0)
jr z,strpbrk_2
ld l,e
ld h,d
ld a,(hl)
cp (iy+0)
inc iy
jr nz,strpbrk_1
jr strpbrk_4
strpbrk_2
inc de
jr strpbrk_0
strpbrk_3
ld l,a
ld h,a
strpbrk_4
pop iy
jp ?LEAVE_DIRECT_L09
/******************************************************************************/
strrchr: //----------------------//
call ?ENT_AUTO_DIRECT_L09
defw 0000h
push iy
ld e,(ix+2)
ld d,(ix+3)
ld iy,0
strrchr_0
ld l,e
ld h,d
xor a
or (hl)
jr z,strrchr_2
ld a,(hl)
cp (ix+4)
jr nz,strrchr_1
push hl
pop iy
strrchr_1
inc de
jr strrchr_0
strrchr_2
push iy
pop hl
pop iy
jp ?LEAVE_DIRECT_L09
/******************************************************************************/
strspn: //----------------------//
call ?ENT_AUTO_DIRECT_L09
defw 0000h
push iy
ld iy,0
strspn_0
ld l,(ix+2)
ld h,(ix+3)
xor a
or (hl)
jr z,strspn_2
ld e,(ix+4)
ld d,(ix+5)
strspn_1
ld l,e
ld h,d
xor a
or (hl)
jr z,strspn_2
ld l,(ix+2)
ld h,(ix+3)
push hl
ld l,e
ld h,d
inc de
ld a,(hl)
pop hl
cp (hl)
jr nz,strspn_1
inc (ix+2)
inc iy
jr nz,strspn_0
inc (ix+3)
jr strspn_0
strspn_2
push iy
pop hl
pop iy
jp ?LEAVE_DIRECT_L09
/******************************************************************************/
strstr: //----------------------//
call ?ENT_AUTO_DIRECT_L09
defw 0000h
push iy
ld e,(ix+2)
ld d,(ix+3)
ld l,c
ld h,b
xor a
or (hl)
jr z,strstr_4
strstr_0
ld l,e
ld h,d
xor a
or (hl)
jr z,strstr_3
ld iy,0
strstr_1
push iy
pop hl
add hl,bc
push hl
push iy
pop hl
add hl,de
ld a,(hl)
pop hl
cp (hl)
jr nz,strstr_2
push iy
pop hl
inc hl
add hl,bc
ld a,(hl)
or a
jr z,strstr_4
inc iy
jr strstr_1
strstr_2
inc de
jr strstr_0
strstr_3
ld l,a
ld h,a
jr strstr_5
strstr_4
ex de,hl
strstr_5
pop iy
jp ?LEAVE_DIRECT_L09
/******************************************************************************/
strcoll: //----------------------//
call ?ENT_PARM_DIRECT_L09
ld l,c
ld h,b
call ?STRCMP_L11
jp ?LEAVE_DIRECT_L09
/******************************************************************************/
strncmp: //----------------------//
push iy
push ix
push bc
pop ix
push de
pop iy
_strncmp_0:
ld hl,6
add hl,sp
ld a,(hl)
inc hl
or (hl)
jr z,_strncmp_1
ld a,(iy+0)
cp (ix+0)
inc ix
jr nz,_strncmp_1
ld a,(iy+0)
or a
inc iy
jr z,_strncmp_2
dec hl
ld c,(hl)
inc hl
ld b,(hl)
dec bc
ld (hl),b
dec hl
ld (hl),c
jr _strncmp_0
_strncmp_1:
dec hl
ld a,(hl)
inc hl
or (hl)
jr z,_strncmp_2
ld c,(ix-1)
ld b,0
ld h,b
ld l,(iy+0)
sbc hl,bc
jr _strncmp_3
_strncmp_2:
ld l,a
ld h,a
_strncmp_3:
pop ix
pop iy
ret
/******************************************************************************/
memchr: //----------------------//
call ?ENT_PARM_DIRECT_L09
_memchr_0:
ld l,(ix+8)
ld h,(ix+9)
dec hl
ld (ix+8),l
ld (ix+9),h
inc hl
ld a,l
or h
jr z,_memchr_1
ld l,(ix+2)
ld h,(ix+3)
ld a,(ix+4)
cp (hl)
jr z,_memchr_2
ld hl,2
add hl,sp
ld a,(hl)
add a,1
ld (hl),a
inc hl
ld a,(hl)
adc a,0
ld (hl),a
jr _memchr_0
_memchr_1:
ld l,a
ld h,a
_memchr_2:
jp ?LEAVE_DIRECT_L09
/******************************************************************************/
memcmp: //----------------------//
call ?ENT_PARM_DIRECT_L09
ld c,(ix+8)
ld b,(ix+9)
ld l,(ix+4)
ld h,(ix+5)
call ?MEMCMP_L11
jp ?LEAVE_DIRECT_L09
/******************************************************************************/
memcpy: //----------------------//
call ?ENT_PARM_DIRECT_L09
ld c,(ix+8)
ld a,c
ld b,(ix+9)
ld l,(ix+4)
ld h,(ix+5)
or b
jr z,_memcpy_0
push de
ldir
pop de
_memcpy_0:
ex de,hl
jp ?LEAVE_DIRECT_L09
/******************************************************************************/
memset: //----------------------//
call ?ENT_PARM_DIRECT_L09
ld c,(ix+8)
ld b,(ix+9)
ld l,(ix+4)
call ?MEMSET_L11
ex de,hl
jp ?LEAVE_DIRECT_L09
/******************************************************************************/
mychar: //----------------------//
defb 30h
defb 31h
defb 32h
defb 33h
defb 34h
defb 35h
defb 36h
defb 37h
defb 38h
defb 39h
//jr nc,2afh
//ld (3433h),a
//dec (hl)
//ld (hl),37h
//jr c,2bfh
//nop
/*
********************************************************************************
* Description : 数字转换成字符串
*
* Arguments : i, 数字
* buf, 输出字符串指针, 3 bytes
*
* Returns : 成功, 输出字符串指针
*
* Notes : 数字只能是 0~9
* C函数调用接口 char *itoa1(unsigned char i, char *buf)
*
********************************************************************************
*/
/******************************************************************************/
itoa1: //----------------------//
PUSH IX
PUSH BC
POP IX
LD B,10
LD A,E
CALL LWRD ?UC_MOD_L01
ADD A,48
LD (IX+0),A
LD (IX+1),0
PUSH IX
POP HL
POP IX
ret
/*
********************************************************************************
* Description : 数字转换成字符串
*
* Arguments : i, 数字
* buf, 输出字符串指针, 3 bytes
*
* Returns : 成功, 输出字符串指针
*
* Notes : 数字只能是 00~99
* C函数调用接口 char *itoa2(unsigned char i, char *buf)
*
********************************************************************************
*/
/******************************************************************************/
itoa2: //----------------------//
PUSH IX
PUSH BC
POP IX
LD D,E
LD B,100
LD A,E
CALL LWRD ?UC_MOD_L01
LD B,10
CALL LWRD ?UC_DIV_L01
ADD A,48
LD (IX+0),A
LD A,D
CALL LWRD ?UC_MOD_L01
ADD A,48
LD (IX+1),A
LD (IX+2),0
PUSH IX
POP HL
POP IX
ret
/*
********************************************************************************
* Description : 数字转换成字符串
*
* Arguments : i, 数字
* buf, 输出字符串指针,4 bytes
*
* Returns : 成功, 输出字符串指针
*
* Notes : 数字只能是 000~999
* C函数调用接口 char *itoa3(unsigned short i, char *buf)
*
********************************************************************************
*/
/******************************************************************************/
itoa3: //----------------------//
PUSH IY
PUSH IX
PUSH BC
POP IX
PUSH DE
POP IY
LD BC,1000
CALL LWRD ?US_MOD_L02
LD BC,100
// CALL LWRD ?0124
CALL LWRD ?US_DIV_L02
LD A,E
ADD A,48
LD (IX+0),A
PUSH IY
POP DE
CALL LWRD ?US_MOD_L02
LD C,10
CALL LWRD ?US_DIV_L02
LD A,E
ADD A,48
LD (IX+1),A
// CALL LWRD ?0125
PUSH IY
POP DE
CALL LWRD ?US_MOD_L02
LD A,E
ADD A,48
LD (IX+2),A
LD (IX+3),B
PUSH IX
POP HL
POP IX
POP IY
ret
/*
********************************************************************************
* Description : 数字转换成字符串
*
* Arguments : i, 数字
* buf, 输出字符串指针,5 bytes
*
* Returns : 成功, 输出字符串指针
*
* Notes : 数字只能是 0000~9999
* C函数调用接口 char *itoa4(unsigned short i, char *buf)
*
********************************************************************************
*/
/******************************************************************************/
itoa4: //----------------------//
PUSH IY
PUSH IX
PUSH BC
POP IX
PUSH DE
POP IY
LD BC,10000
CALL
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -