summaryrefslogtreecommitdiff
path: root/device/lib/stm8/_itoa.asm
diff options
context:
space:
mode:
authorXavier ASUS <xavi92psx@gmail.com>2019-10-18 00:31:54 +0200
committerXavier ASUS <xavi92psx@gmail.com>2019-10-18 00:31:54 +0200
commit268a53de823a6750d6256ee1fb1e7707b4b45740 (patch)
tree42c1799a9a82b2f7d9790ee9fe181d72a7274751 /device/lib/stm8/_itoa.asm
downloadsdcc-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/_itoa.asm')
-rw-r--r--device/lib/stm8/_itoa.asm185
1 files changed, 185 insertions, 0 deletions
diff --git a/device/lib/stm8/_itoa.asm b/device/lib/stm8/_itoa.asm
new file mode 100644
index 0000000..8469595
--- /dev/null
+++ b/device/lib/stm8/_itoa.asm
@@ -0,0 +1,185 @@
+;--------------------------------------------------------
+; File Created by SDCC : free open source ANSI-C Compiler
+; Version 3.9.3 #11345 (Linux)
+;--------------------------------------------------------
+ .module _itoa
+ .optsdcc -mstm8
+
+;--------------------------------------------------------
+; Public variables in this module
+;--------------------------------------------------------
+ .globl __itoa
+ .globl __uitoa
+;--------------------------------------------------------
+; 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
+; ../_itoa.c: 40: void _uitoa(unsigned int value, char* string, unsigned char radix)
+; -----------------------------------------
+; function _uitoa
+; -----------------------------------------
+__uitoa:
+ sub sp, #5
+; ../_itoa.c: 45: do {
+ clr (0x05, sp)
+00103$:
+; ../_itoa.c: 46: string[index] = '0' + (value % radix);
+ ld a, (0x05, sp)
+ ld xl, a
+ rlc a
+ clr a
+ sbc a, #0x00
+ ld xh, a
+ addw x, (0x0a, sp)
+ ldw (0x01, sp), x
+ ld a, (0x0c, sp)
+ ld (0x04, sp), a
+ clr (0x03, sp)
+ ldw x, (0x08, sp)
+ ldw y, (0x03, sp)
+ divw x, y
+ ld a, yl
+ add a, #0x30
+ ldw x, (0x01, sp)
+ ld (x), a
+; ../_itoa.c: 47: if (string[index] > '9')
+ ldw x, (0x01, sp)
+ ld a, (x)
+ cp a, #0x39
+ jrule 00102$
+; ../_itoa.c: 48: string[index] += 'A' - '9' - 1;
+ add a, #0x07
+ ldw x, (0x01, sp)
+ ld (x), a
+00102$:
+; ../_itoa.c: 49: value /= radix;
+ ldw x, (0x08, sp)
+ ldw y, (0x03, sp)
+ divw x, y
+ ldw (0x08, sp), x
+; ../_itoa.c: 50: ++index;
+ inc (0x05, sp)
+; ../_itoa.c: 51: } while (value != 0);
+ ldw x, (0x08, sp)
+ jrne 00103$
+; ../_itoa.c: 54: string[index--] = '\0';
+ ld a, (0x05, sp)
+ dec a
+ ld (0x04, sp), a
+ ld a, (0x05, sp)
+ ld xl, a
+ rlc a
+ clr a
+ sbc a, #0x00
+ ld xh, a
+ addw x, (0x0a, sp)
+ clr (x)
+; ../_itoa.c: 57: while (index > i) {
+ clr (0x05, sp)
+00106$:
+ ld a, (0x04, sp)
+ cp a, (0x05, sp)
+ jrsle 00109$
+; ../_itoa.c: 58: char tmp = string[i];
+ ld a, (0x05, sp)
+ ld xl, a
+ rlc a
+ clr a
+ sbc a, #0x00
+ ld xh, a
+ addw x, (0x0a, sp)
+ exgw x, y
+ ld a, (y)
+ ld (0x03, sp), a
+; ../_itoa.c: 59: string[i] = string[index];
+ ld a, (0x04, sp)
+ ld xl, a
+ rlc a
+ clr a
+ sbc a, #0x00
+ ld xh, a
+ addw x, (0x0a, sp)
+ ld a, (x)
+ ld (y), a
+; ../_itoa.c: 60: string[index] = tmp;
+ ld a, (0x03, sp)
+ ld (x), a
+; ../_itoa.c: 61: ++i;
+ inc (0x05, sp)
+; ../_itoa.c: 62: --index;
+ dec (0x04, sp)
+ jra 00106$
+00109$:
+; ../_itoa.c: 64: }
+ addw sp, #5
+ ret
+; ../_itoa.c: 66: void _itoa(int value, char* string, unsigned char radix)
+; -----------------------------------------
+; function _itoa
+; -----------------------------------------
+__itoa:
+; ../_itoa.c: 68: if (value < 0 && radix == 10) {
+ tnz (0x03, sp)
+ jrpl 00102$
+ ld a, (0x07, sp)
+ cp a, #0x0a
+ jrne 00102$
+; ../_itoa.c: 69: *string++ = '-';
+ ldw x, (0x05, sp)
+ ld a, #0x2d
+ ld (x), a
+ incw x
+ ldw (0x05, sp), x
+; ../_itoa.c: 70: value = -value;
+ ldw x, (0x03, sp)
+ negw x
+ ldw (0x03, sp), x
+00102$:
+; ../_itoa.c: 72: _uitoa(value, string, radix);
+ ld a, (0x07, sp)
+ push a
+ ldw x, (0x06, sp)
+ pushw x
+ ldw x, (0x06, sp)
+ pushw x
+ call __uitoa
+ addw sp, #5
+; ../_itoa.c: 73: }
+ ret
+ .area CODE
+ .area CONST
+ .area INITIALIZER
+ .area CABS (ABS)