diff options
| author | Xavier ASUS <xavi92psx@gmail.com> | 2019-10-18 00:31:54 +0200 |
|---|---|---|
| committer | Xavier ASUS <xavi92psx@gmail.com> | 2019-10-18 00:31:54 +0200 |
| commit | 268a53de823a6750d6256ee1fb1e7707b4b45740 (patch) | |
| tree | 42c1799a9a82b2f7d9790ee9fe181d72a7274751 /device/lib/stm8/_strncmp.asm | |
| download | sdcc-gas-268a53de823a6750d6256ee1fb1e7707b4b45740.tar.gz | |
sdcc-3.9.0 fork implementing GNU assembler syntax
This fork aims to provide better support for stm8-binutils
Diffstat (limited to 'device/lib/stm8/_strncmp.asm')
| -rw-r--r-- | device/lib/stm8/_strncmp.asm | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/device/lib/stm8/_strncmp.asm b/device/lib/stm8/_strncmp.asm new file mode 100644 index 0000000..faebada --- /dev/null +++ b/device/lib/stm8/_strncmp.asm @@ -0,0 +1,104 @@ +;-------------------------------------------------------- +; File Created by SDCC : free open source ANSI-C Compiler +; Version 3.9.3 #11345 (Linux) +;-------------------------------------------------------- + .module _strncmp + .optsdcc -mstm8 + +;-------------------------------------------------------- +; Public variables in this module +;-------------------------------------------------------- + .globl _strncmp +;-------------------------------------------------------- +; ram data +;-------------------------------------------------------- + .area DATA +;-------------------------------------------------------- +; ram data +;-------------------------------------------------------- + .area INITIALIZED +;-------------------------------------------------------- +; absolute external ram data +;-------------------------------------------------------- + .area DABS (ABS) + +; default segment ordering for linker + .area HOME + .area GSINIT + .area GSFINAL + .area CONST + .area INITIALIZER + .area CODE + +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area HOME + .area GSINIT + .area GSFINAL + .area GSINIT +;-------------------------------------------------------- +; Home +;-------------------------------------------------------- + .area HOME + .area HOME +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CODE +; ../_strncmp.c: 31: int strncmp ( const char * first, const char * last, size_t count ) +; ----------------------------------------- +; function strncmp +; ----------------------------------------- +_strncmp: + sub sp, #5 +; ../_strncmp.c: 33: if (!count) +; ../_strncmp.c: 34: return(0); + ldw x, (0x0c, sp) +; ../_strncmp.c: 36: while (--count && *first && *first == *last) { + jreq 00108$ + ldw y, (0x08, sp) + ldw (0x02, sp), y + ldw y, (0x0a, sp) + ldw (0x04, sp), y + ldw y, (0x0c, sp) +00105$: + decw y + ldw x, (0x02, sp) + ld a, (x) + ldw x, (0x04, sp) + push a + ld a, (x) + ld (0x02, sp), a + pop a + tnzw y + jreq 00107$ + tnz a + jreq 00107$ + cp a, (0x01, sp) + jrne 00107$ +; ../_strncmp.c: 37: first++; + ldw x, (0x02, sp) + incw x + ldw (0x02, sp), x +; ../_strncmp.c: 38: last++; + ldw x, (0x04, sp) + incw x + ldw (0x04, sp), x + jra 00105$ +00107$: +; ../_strncmp.c: 41: return( *first - *last ); + clrw x + ld xl, a + ld a, (0x01, sp) + ld (0x05, sp), a + clr (0x04, sp) + subw x, (0x04, sp) +00108$: +; ../_strncmp.c: 42: } + addw sp, #5 + ret + .area CODE + .area CONST + .area INITIALIZER + .area CABS (ABS) |
