Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Our business is run on trust. We trust you will pay in advance.


devel / comp.lang.asm.x86 / Re: ITOA in 65 bytes

SubjectAuthor
* ITOA in 65 bytesRobert Prins
+* Re: ITOA in 65 bytesTerje Mathisen
|`* Re: ITOA in 65 bytesKerr-Mudd, John
| `* Re: ITOA in 65 bytesKerr-Mudd, John
|  `* Re: ITOA in 65 bytesTerje Mathisen
|   `- Re: ITOA in 65 bytesKerr-Mudd, John
`* Re: ITOA in 65 bytesR.Wieser
 +* Re: ITOA in 65 bytesRobert Prins
 |+- Re: ITOA in 65 bytesR.Wieser
 |`* Re: ITOA in 65 bytesTerje Mathisen
 | `* Re: ITOA in 65 bytesRobert Prins
 |  +* Re: ITOA in 65 bytesKerr-Mudd, John
 |  |`- Re: ITOA in 65 bytesRobert Prins
 |  `* Re: ITOA in 65 bytesR.Wieser
 |   `- Re: ITOA in 65 bytesKerr-Mudd, John
 `* Re: ITOA in 65 bytesBonita Montero
  +- Re: ITOA in 65 bytesR.Wieser
  `- Re: ITOA in 65 bytesKerr-Mudd, John

1
ITOA in 65 bytes

<s7m8nd$f4p$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=162&group=comp.lang.asm.x86#162

  copy link   Newsgroups: comp.lang.asm.x86
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: robert@nospicedham.prino.org (Robert Prins)
Newsgroups: comp.lang.asm.x86
Subject: ITOA in 65 bytes
Date: Fri, 14 May 2021 19:32:06 +0000
Organization: A noiseless patient Spider
Lines: 8
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <s7m8nd$f4p$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: reader02.eternal-september.org; posting-host="5ff05b3b6a451c6ef58dc63f9099b6c3";
logging-data="18353"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+ulpoDWDaUK+DIHmMkj9f9KB650e1YsSw="
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.10.1
Cancel-Lock: sha1:cP65jSiSSONWBaZEL8ndcXknByk=
 by: Robert Prins - Fri, 14 May 2021 19:32 UTC

Is it possible to fit the conversion of a 16 bit signed integer to left-aligned
ASCII without leading zeroes in just 65 bytes?
--
Robert AH Prins
robert(a)prino(d)org
The hitchhiking grandfather - https://prino.neocities.org/indez.html
Some REXX code for use on z/OS - https://prino.neocities.org/zOS/zOS-Tools.html

Re: ITOA in 65 bytes

<s7mkfs$196d$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=163&group=comp.lang.asm.x86#163

  copy link   Newsgroups: comp.lang.asm.x86
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: terje.mathisen@nospicedham.tmsw.no (Terje Mathisen)
Newsgroups: comp.lang.asm.x86
Subject: Re: ITOA in 65 bytes
Date: Fri, 14 May 2021 21:53:32 +0200
Organization: Aioe.org NNTP Server
Lines: 42
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <s7mkfs$196d$1@gioia.aioe.org>
References: <s7m8nd$f4p$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: reader02.eternal-september.org; posting-host="5ff05b3b6a451c6ef58dc63f9099b6c3";
logging-data="8378"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+CtOy3+GvLPO8DEUChcbHm4ICuJH2XpJQ="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:60.0) Gecko/20100101
Firefox/60.0 SeaMonkey/2.53.7
Cancel-Lock: sha1:t02BLLq5Ll880Iu/wtTNum6oKc4=
 by: Terje Mathisen - Fri, 14 May 2021 19:53 UTC

Robert Prins wrote:
> Is it possible to fit the conversion of a 16 bit signed integer to
> left-aligned ASCII without leading zeroes in just 65 bytes?

Naively I would say yes: I assume you don't care about speed here?

;; AX has the value to be converted to ascii
;; Store the string to the buffer pointed to by DI

xor cx,cx ; Count how many digits we find
test ax,ax ; Positive?
jge next

;; Negative input value, so print a '-' sign
mov byte ptr [di],'-'
neg ax
inc di

next:
xor dx,dx
mov bx,10
div bx
push dx ; Remainder is the digit
inc cx
test ax,ax ; Is it zero yet?
jnz next

dump_digits:
pop ax
add al,'0'
stosb
loop dump_digits

That looks like 17 instructions, most of them two-byte, 5 one-byte and a
couple that are longer, so 32-35 bytes?

Terje

--
- <Terje.Mathisen at tmsw.no>
"almost all programming can be viewed as an exercise in caching"

Re: ITOA in 65 bytes

<20210515112143.87a0d2ee4dbddbe64b5c4f22@127.0.0.1>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=164&group=comp.lang.asm.x86#164

  copy link   Newsgroups: comp.lang.asm.x86
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: admin@nospicedham.127.0.0.1 (Kerr-Mudd, John)
Newsgroups: comp.lang.asm.x86
Subject: Re: ITOA in 65 bytes
Date: Sat, 15 May 2021 11:21:43 +0100
Organization: Dis
Lines: 71
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <20210515112143.87a0d2ee4dbddbe64b5c4f22@127.0.0.1>
References: <s7m8nd$f4p$1@dont-email.me>
<s7mkfs$196d$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: reader02.eternal-september.org; posting-host="a37a3a9a139e5c413243dd5f8322d2bf";
logging-data="14890"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+cZXuBR6cMYj4/zOpojSIkwFtw1wBA2iM="
Cancel-Lock: sha1:pQbKO3dLwL/Vdp1wJyL3MFBRhho=
 by: Kerr-Mudd, John - Sat, 15 May 2021 10:21 UTC

On Fri, 14 May 2021 21:53:32 +0200
Terje Mathisen <terje.mathisen@nospicedham.tmsw.no> wrote:

> Robert Prins wrote:
> > Is it possible to fit the conversion of a 16 bit signed integer to
> > left-aligned ASCII without leading zeroes in just 65 bytes?
>
> Naively I would say yes: I assume you don't care about speed here?
>
> ;; AX has the value to be converted to ascii
[code elided]
I took the liberty of moving the "mov bx,10" out of the loop!
NASM .lst file:

1 org 0x100
2 cpu 8086
3
4 ;; AX has the value to be converted to ascii
5 ;; Store the string to the buffer pointed to by DI
6 00000000 B80180 mov ax,0x8001
7 00000003 BF[3000] mov di,Ostr
8
9 putnum:
10 00000006 31C9 xor cx,cx ; Count how many digits we find
11 00000008 85C0 test ax,ax ; Positive?
12 0000000A 7D09 jge next
13
14 ;; Negative input value, so print a '-' sign
15 0000000C C6052D mov byte [di],'-'
16 0000000F F7D8 neg ax
17 00000011 47 inc di
18
19 00000012 BB0A00 mov bx,10
20
21 next:
22 00000015 31D2 xor dx,dx
23 00000017 F7F3 div bx
24 00000019 52 push dx ; Remainder is the digit
25 0000001A 41 inc cx
26 0000001B 85C0 test ax,ax ; Is it zero yet?
27 0000001D 75F6 jnz next
28
29 dump_digits:
30 0000001F 58 pop ax
31 00000020 0430 add al,'0'
32 00000022 AA stosb
33 00000023 E2FA loop dump_digits
34
35 convlth equ $-putnum
36
37 00000025 B82409 mov ax,0x100*9+'$'
38 00000028 AA stosb
39 00000029 BA[3000] mov dx,Ostr
40 0000002C CD21 int 0x21
41 0000002E C3 ret
42 0000002F 1F db convlth
43 Ostr equ $

> That looks like 17 instructions, most of them two-byte, 5 one-byte and a
> couple that are longer, so 32-35 bytes?

1F=31 bytes

--
Bah, and indeed Humbug.

Re: ITOA in 65 bytes

<20210515143800.e1de93a5aca4bbc883fd0a49@127.0.0.1>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=165&group=comp.lang.asm.x86#165

  copy link   Newsgroups: comp.lang.asm.x86
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: admin@nospicedham.127.0.0.1 (Kerr-Mudd, John)
Newsgroups: comp.lang.asm.x86
Subject: Re: ITOA in 65 bytes
Date: Sat, 15 May 2021 14:38:00 +0100
Organization: Dis
Lines: 80
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <20210515143800.e1de93a5aca4bbc883fd0a49@127.0.0.1>
References: <s7m8nd$f4p$1@dont-email.me>
<s7mkfs$196d$1@gioia.aioe.org>
<20210515112143.87a0d2ee4dbddbe64b5c4f22@127.0.0.1>
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: reader02.eternal-september.org; posting-host="a37a3a9a139e5c413243dd5f8322d2bf";
logging-data="21159"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/znwNv2Z9kHUrA2k0RzAKKRm34M/2JPVk="
Cancel-Lock: sha1:ip48wxVf+HL2mmtDjBGbwBer0ec=
 by: Kerr-Mudd, John - Sat, 15 May 2021 13:38 UTC

On Sat, 15 May 2021 11:21:43 +0100
"Kerr-Mudd, John" <admin@nospicedham.127.0.0.1> wrote:

> On Fri, 14 May 2021 21:53:32 +0200
> Terje Mathisen <terje.mathisen@nospicedham.tmsw.no> wrote:
>
> > Robert Prins wrote:
> > > Is it possible to fit the conversion of a 16 bit signed integer to
> > > left-aligned ASCII without leading zeroes in just 65 bytes?
> >
> > Naively I would say yes: I assume you don't care about speed here?
> >
> > ;; AX has the value to be converted to ascii
> [code elided]
> I took the liberty of moving the "mov bx,10" out of the loop!

How embarrassing; needs bx setting if +ve!
> NASM .lst file:
>
1 org 0x100
2 cpu 8086
3
4 ;; AX has the value to be converted to ascii
5 ;; Store the string to the buffer pointed to by DI
6 00000000 B8FF7F mov ax,0x7FFF
7 00000003 BF[2F00] mov di,Ostr
8
9 putnum:
10 00000006 31C9 xor cx,cx ; Count how many digits we find
11 00000008 85C0 test ax,ax ; Positive?
12 0000000A 7D06 jge notneg
13
14 ;; Negative input value, so print a '-' sign
15 0000000C C6052D mov byte [di],'-'
16 0000000F F7D8 neg ax
17 00000011 47 inc di
18 notneg:
19 00000012 BB0A00 mov bx,10
20
21 next:
22 ; xor dx,dx
23 00000015 99 cwd ; ok as hibit has been removed
24 00000016 F7F3 div bx
25 00000018 52 push dx ; Remainder is the digit
26 00000019 41 inc cx
27 0000001A 85C0 test ax,ax ; Is it zero yet?
28 0000001C 75F7 jnz next
29
30 dump_digits:
31 0000001E 58 pop ax
32 0000001F 0430 add al,'0'
33 00000021 AA stosb
34 00000022 E2FA loop dump_digits
35
36 convlth equ $-putnum
37
38 00000024 B82409 mov ax,0x100*9+'$'
39 00000027 AA stosb
40 00000028 BA[2F00] mov dx,Ostr
41 0000002B CD21 int 0x21
42 0000002D C3 ret
43 0000002E 1E db convlth
44 Ostr equ $

>
> > That looks like 17 instructions, most of them two-byte, 5 one-byte and a
> > couple that are longer, so 32-35 bytes?
>
> 1E=30 bytes
>
>
> --
> Bah, and indeed Humbug.
>

--
Bah, and indeed Humbug.

Re: ITOA in 65 bytes

<s7p1d9$p1r$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=166&group=comp.lang.asm.x86#166

  copy link   Newsgroups: comp.lang.asm.x86
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: terje.mathisen@nospicedham.tmsw.no (Terje Mathisen)
Newsgroups: comp.lang.asm.x86
Subject: Re: ITOA in 65 bytes
Date: Sat, 15 May 2021 19:46:21 +0200
Organization: Aioe.org NNTP Server
Lines: 121
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <s7p1d9$p1r$1@gioia.aioe.org>
References: <s7m8nd$f4p$1@dont-email.me> <s7mkfs$196d$1@gioia.aioe.org>
<20210515112143.87a0d2ee4dbddbe64b5c4f22@127.0.0.1>
<20210515143800.e1de93a5aca4bbc883fd0a49@127.0.0.1>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: reader02.eternal-september.org; posting-host="a37a3a9a139e5c413243dd5f8322d2bf";
logging-data="17086"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18uszVNdfgfAEkJpNQP6tD0p4oaECqQlgU="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:60.0) Gecko/20100101
Firefox/60.0 SeaMonkey/2.53.7
Cancel-Lock: sha1:MpAqjgffFD1Nw4FVLbRlOEUAJPY=
 by: Terje Mathisen - Sat, 15 May 2021 17:46 UTC

Kerr-Mudd, John wrote:
> On Sat, 15 May 2021 11:21:43 +0100
> "Kerr-Mudd, John" <admin@nospicedham.127.0.0.1> wrote:
>
>> On Fri, 14 May 2021 21:53:32 +0200
>> Terje Mathisen <terje.mathisen@nospicedham.tmsw.no> wrote:
>>
>>> Robert Prins wrote:
>>>> Is it possible to fit the conversion of a 16 bit signed integer to
>>>> left-aligned ASCII without leading zeroes in just 65 bytes?
>>>
>>> Naively I would say yes: I assume you don't care about speed here?
>>>
>>> ;; AX has the value to be converted to ascii
>> [code elided]
>> I took the liberty of moving the "mov bx,10" out of the loop!
>
> How embarrassing; needs bx setting if +ve!
>
>> NASM .lst file:
>>
> 1 org 0x100
> 2 cpu 8086
> 3
> 4 ;; AX has the value to be converted to ascii
> 5 ;; Store the string to the buffer pointed to by DI
> 6 00000000 B8FF7F mov ax,0x7FFF
> 7 00000003 BF[2F00] mov di,Ostr
> 8
> 9 putnum:
> 10 00000006 31C9 xor cx,cx ; Count how many digits we find
> 11 00000008 85C0 test ax,ax ; Positive?
> 12 0000000A 7D06 jge notneg
> 13
> 14 ;; Negative input value, so print a '-' sign
> 15 0000000C C6052D mov byte [di],'-'
> 16 0000000F F7D8 neg ax
> 17 00000011 47 inc di
> 18 notneg:
> 19 00000012 BB0A00 mov bx,10
> 20
> 21 next:
> 22 ; xor dx,dx
> 23 00000015 99 cwd ; ok as hibit has been removed
> 24 00000016 F7F3 div bx
> 25 00000018 52 push dx ; Remainder is the digit
> 26 00000019 41 inc cx
> 27 0000001A 85C0 test ax,ax ; Is it zero yet?
> 28 0000001C 75F7 jnz next
> 29
> 30 dump_digits:
> 31 0000001E 58 pop ax
> 32 0000001F 0430 add al,'0'
> 33 00000021 AA stosb
> 34 00000022 E2FA loop dump_digits
> 35
> 36 convlth equ $-putnum
> 37
> 38 00000024 B82409 mov ax,0x100*9+'$'
> 39 00000027 AA stosb
> 40 00000028 BA[2F00] mov dx,Ostr
> 41 0000002B CD21 int 0x21
> 42 0000002D C3 ret
> 43 0000002E 1E db convlth
> 44 Ostr equ $
>
>>
>>> That looks like 17 instructions, most of them two-byte, 5 one-byte and a
>>> couple that are longer, so 32-35 bytes?
>>
>> 1E=30 bytes

The CWD was a valid improvement, moving BX=10 out of the loop probably
doesn't matter that much since the DIV BX takes forever. :-(

The key idea here is of course that I abuse the stack as temporary
storage to reverse the digits to be printed, since the challenge was to
get below 65 bytes I think my code was pretty good for a simple
"programming while responding to clax post" exercise. :-)

I did consider printing each digit directly to the console, it probably
would not have added much to the code size for an unsigned value, but
getting the sign logic correct was much easier when using the STOSB buffer.

xor cx,cx
test ax,ax
jge not_negative

xchg ax,bx
mov dl,'-' - '0'
call print_char
xchg ax,bx
neg ax

not_negative:
mov bx,10
next:
....
test ax,ax
jnz next

print_digits:
pop dx
call print_char
loop print_digits
ret

print_char:
add dl,'0'
mov ah,2
int 21h
ret

Terje

--
- <Terje.Mathisen at tmsw.no>
"almost all programming can be viewed as an exercise in caching"

Re: ITOA in 65 bytes

<s7qkto$131f$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=167&group=comp.lang.asm.x86#167

  copy link   Newsgroups: comp.lang.asm.x86
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: address@nospicedham.not.available (R.Wieser)
Newsgroups: comp.lang.asm.x86
Subject: Re: ITOA in 65 bytes
Date: Sun, 16 May 2021 10:25:23 +0200
Organization: Aioe.org NNTP Server
Lines: 14
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <s7qkto$131f$1@gioia.aioe.org>
References: <s7m8nd$f4p$1@dont-email.me>
Injection-Info: reader02.eternal-september.org; posting-host="5f09de62b9e9b4075ad423eeafde414a";
logging-data="26316"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/X/pbybLO022mz41mR2py7fZJlwIveJWk="
Cancel-Lock: sha1:p4oG48ln0rXgVH8CwFA6oUcdIXU=
 by: R.Wieser - Sun, 16 May 2021 08:25 UTC

> Is it possible to fit the conversion of a 16 bit signed integer to
> left-aligned
> ASCII without leading zeroes in just 65 bytes?

As no specifications have been posted, I do have some code that outputs a
signed number using just 25 bytes.

The trick ? Filling the buffer backwards (putting the sign at the end).

Regards,
Rudy Wieser

Re: ITOA in 65 bytes

<s7qqib$pav$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=168&group=comp.lang.asm.x86#168

  copy link   Newsgroups: comp.lang.asm.x86
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: robert@nospicedham.prino.org (Robert Prins)
Newsgroups: comp.lang.asm.x86
Subject: Re: ITOA in 65 bytes
Date: Sun, 16 May 2021 13:01:14 +0000
Organization: A noiseless patient Spider
Lines: 20
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <s7qqib$pav$1@dont-email.me>
References: <s7m8nd$f4p$1@dont-email.me> <s7qkto$131f$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: reader02.eternal-september.org; posting-host="5f09de62b9e9b4075ad423eeafde414a";
logging-data="29740"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Tv1Fo7j9m1AHCnQWRDVQmd8bMzds+vQE="
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.10.1
Cancel-Lock: sha1:71hqbUEGeaSFbVd/Hp5wAikHPR8=
 by: Robert Prins - Sun, 16 May 2021 13:01 UTC

On 2021-05-16 08:25, R.Wieser wrote:
>> Is it possible to fit the conversion of a 16 bit signed integer to
>> left-aligned
>> ASCII without leading zeroes in just 65 bytes?
>
> As no specifications have been posted, I do have some code that outputs a
> signed number using just 25 bytes.
>
> The trick ? Filling the buffer backwards (putting the sign at the end).

The code is replacement code for the itoa routine in the Borland TP3 compiler,
so it has to give the same result.

Robert
--
Robert AH Prins
robert(a)prino(d)org
The hitchhiking grandfather - https://prino.neocities.org/indez.html
Some REXX code for use on z/OS - https://prino.neocities.org/zOS/zOS-Tools.html

Re: ITOA in 65 bytes

<20210516121415.eee2b1810aeeb2ec022ea353@127.0.0.1>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=170&group=comp.lang.asm.x86#170

  copy link   Newsgroups: comp.lang.asm.x86
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: admin@nospicedham.127.0.0.1 (Kerr-Mudd, John)
Newsgroups: comp.lang.asm.x86
Subject: Re: ITOA in 65 bytes
Date: Sun, 16 May 2021 12:14:15 +0100
Organization: Dis
Lines: 88
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <20210516121415.eee2b1810aeeb2ec022ea353@127.0.0.1>
References: <s7m8nd$f4p$1@dont-email.me>
<s7mkfs$196d$1@gioia.aioe.org>
<20210515112143.87a0d2ee4dbddbe64b5c4f22@127.0.0.1>
<20210515143800.e1de93a5aca4bbc883fd0a49@127.0.0.1>
<s7p1d9$p1r$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: reader02.eternal-september.org; posting-host="5f09de62b9e9b4075ad423eeafde414a";
logging-data="27509"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+TSDHbn6XWIfNzNcQj1/JUgz0VQrio274="
Cancel-Lock: sha1:EWKnKtnasYmDfJiOvJwuSdWLAAU=
 by: Kerr-Mudd, John - Sun, 16 May 2021 11:14 UTC

On Sat, 15 May 2021 19:46:21 +0200
Terje Mathisen <terje.mathisen@nospicedham.tmsw.no> wrote:

> Kerr-Mudd, John wrote:
> > On Sat, 15 May 2021 11:21:43 +0100
> > "Kerr-Mudd, John" <admin@nospicedham.127.0.0.1> wrote:
> >
> >> On Fri, 14 May 2021 21:53:32 +0200
> >> Terje Mathisen <terje.mathisen@nospicedham.tmsw.no> wrote:
> >>
> >>> Robert Prins wrote:
> >>>> Is it possible to fit the conversion of a 16 bit signed integer to
> >>>> left-aligned ASCII without leading zeroes in just 65 bytes?
> >>>
> >>> Naively I would say yes: I assume you don't care about speed here?
> >>>
> >>> ;; AX has the value to be converted to ascii
> >> [code elided]
>

>
> I did consider printing each digit directly to the console, it probably
> would not have added much to the code size for an unsigned value, but
> getting the sign logic correct was much easier when using the STOSB buffer.
>
> xor cx,cx
> test ax,ax
> jge not_negative
>
> xchg ax,bx
> mov dl,'-' - '0'
> call print_char
> xchg ax,bx
> neg ax
>
> not_negative:
> mov bx,10
> next:
> ...
> test ax,ax
> jnz next
>
> print_digits:
> pop dx
> call print_char
> loop print_digits
> ret
>
> print_char:
> add dl,'0'
> mov ah,2
> int 21h
> ret

Dirty trick, saves a call/ret:

xor cx,cx
test ax,ax
jge not_negative
xchg ax,bx
mov dl,'-'
inc cx ; print once!
call print_char
xchg ax,bx
neg ax
not_negative:
mov bx,10
next:
...
test ax,ax
jnz next
print_digits:
pop dx
; print_*num*:
add dl,'0'
print_char:
mov ah,2
int 21h
loop print_digits
ret

--
Bah, and indeed Humbug.

Re: ITOA in 65 bytes

<s7r3io$1fo0$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=172&group=comp.lang.asm.x86#172

  copy link   Newsgroups: comp.lang.asm.x86
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: address@nospicedham.not.available (R.Wieser)
Newsgroups: comp.lang.asm.x86
Subject: Re: ITOA in 65 bytes
Date: Sun, 16 May 2021 14:35:29 +0200
Organization: Aioe.org NNTP Server
Lines: 25
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <s7r3io$1fo0$1@gioia.aioe.org>
References: <s7m8nd$f4p$1@dont-email.me> <s7qkto$131f$1@gioia.aioe.org> <s7qqib$pav$1@dont-email.me>
Injection-Info: reader02.eternal-september.org; posting-host="5f09de62b9e9b4075ad423eeafde414a";
logging-data="26842"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+YPcBwo+OlwPAz/01o/FwQBWAT+qMEkQc="
Cancel-Lock: sha1:USi/2POd7wXp7ulySeKPtZS4V0w=
 by: R.Wieser - Sun, 16 May 2021 12:35 UTC

Robert,

> The code is replacement code for the itoa routine in the Borland TP3
> compiler, so it has to give the same result.

I took my clues from the code Terje posted, which seemed to indicate that
anything goes (not actually outputting anything, non-terminated string,
inline). :-)

And alas, as I'm using an assembler that doesn't tell me anything ...

Should the sign be on the left
Should only the negative sign be displayed or both.
Should the positive sign be replaced by a space
Should the string be put into a buffer
Should it than be either zero or "$' terminated
Should the string-end position be returned and if so in which register
Should it be send to STDOUT
Should it be a function or in-line
.... any other relevant specs I've not mentioned

Regards,
Rudy Wieser

Re: ITOA in 65 bytes

<s7r5i8$ah1$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=173&group=comp.lang.asm.x86#173

  copy link   Newsgroups: comp.lang.asm.x86
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: terje.mathisen@nospicedham.tmsw.no (Terje Mathisen)
Newsgroups: comp.lang.asm.x86
Subject: Re: ITOA in 65 bytes
Date: Sun, 16 May 2021 15:09:31 +0200
Organization: Aioe.org NNTP Server
Lines: 29
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <s7r5i8$ah1$1@gioia.aioe.org>
References: <s7m8nd$f4p$1@dont-email.me> <s7qkto$131f$1@gioia.aioe.org>
<s7qqib$pav$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: reader02.eternal-september.org; posting-host="5f09de62b9e9b4075ad423eeafde414a";
logging-data="14139"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+SwzN7Hs1JyJwmjsOQcKfJS2BNbpaWTWs="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:60.0) Gecko/20100101
Firefox/60.0 SeaMonkey/2.53.7
Cancel-Lock: sha1:4SXJY4HZsnAM7NkqxSX6MQ8ASBA=
 by: Terje Mathisen - Sun, 16 May 2021 13:09 UTC

Robert Prins wrote:
> On 2021-05-16 08:25, R.Wieser wrote:
>>> Is it possible to fit the conversion of a 16 bit signed integer to
>>> left-aligned
>>> ASCII without leading zeroes in just 65 bytes?
>>
>> As no specifications have been posted, I do have some code that outputs a
>> signed number using just 25 bytes.
>>
>> The trick ?    Filling the buffer backwards (putting the sign at the
>> end).
>
> The code is replacement code for the itoa routine in the Borland TP3
> compiler, so it has to give the same result.

Why didn't you state so?

The key here is that this function returns a TP string, right?

This means that the space for it has to be allocated, but I don't
remember anymore if that is done by the caller or callee in that
environment?

Terje

--
- <Terje.Mathisen at tmsw.no>
"almost all programming can be viewed as an exercise in caching"

Re: ITOA in 65 bytes

<s7rjoj$ro2$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=175&group=comp.lang.asm.x86#175

  copy link   Newsgroups: comp.lang.asm.x86
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: robert@nospicedham.prino.org (Robert Prins)
Newsgroups: comp.lang.asm.x86
Subject: Re: ITOA in 65 bytes
Date: Sun, 16 May 2021 20:11:15 +0000
Organization: A noiseless patient Spider
Lines: 42
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <s7rjoj$ro2$1@dont-email.me>
References: <s7m8nd$f4p$1@dont-email.me> <s7qkto$131f$1@gioia.aioe.org>
<s7qqib$pav$1@dont-email.me> <s7r5i8$ah1$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: reader02.eternal-september.org; posting-host="5f09de62b9e9b4075ad423eeafde414a";
logging-data="11037"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18w3U7/ciBcq2JN2N0JpNV9RxYKeZFumck="
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.10.1
Cancel-Lock: sha1:lNF6LxJWE087Gy4bKiTLzjr8zMY=
 by: Robert Prins - Sun, 16 May 2021 20:11 UTC

On 2021-05-16 13:09, Terje Mathisen wrote:
> Robert Prins wrote:
>> On 2021-05-16 08:25, R.Wieser wrote:
>>>> Is it possible to fit the conversion of a 16 bit signed integer to
>>>> left-aligned
>>>> ASCII without leading zeroes in just 65 bytes?
>>>
>>> As no specifications have been posted, I do have some code that outputs a
>>> signed number using just 25 bytes.
>>>
>>> The trick ?    Filling the buffer backwards (putting the sign at the end).
>>
>> The code is replacement code for the itoa routine in the Borland TP3 compiler,
>> so it has to give the same result.
>
> Why didn't you state so?

I should have done earlier, rather than in that follow-up, apologies.

> The key here is that this function returns a TP string, right?

No, see the code of the current routine I also posted. It puts the result into a
22-byte fixed buffer @ DS:00B6 and from there it's processed further.

> This means that the space for it has to be allocated, but I don't remember
> anymore if that is done by the caller or callee in that environment?

The TP3 manual is silent about this for strings, but looking at the only
procedure that actually returns a string, it looks like the caller sets up the
space for the string to be returned.

For what it's worth, -32768 is problematic for all routines posted, it doesn't
change sign when negated! TP3 also doesn't accept it as valid integer, unless
coded as $8000.

Robert
--
Robert AH Prins
robert(a)prino(d)org
The hitchhiking grandfather - https://prino.neocities.org/indez.html
Some REXX code for use on z/OS - https://prino.neocities.org/zOS/zOS-Tools.html

Re: ITOA in 65 bytes

<20210516175827.7596a4989cd5f1b9e3cbb840@127.0.0.1>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=176&group=comp.lang.asm.x86#176

  copy link   Newsgroups: comp.lang.asm.x86
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: admin@nospicedham.127.0.0.1 (Kerr-Mudd, John)
Newsgroups: comp.lang.asm.x86
Subject: Re: ITOA in 65 bytes
Date: Sun, 16 May 2021 17:58:27 +0100
Organization: Dis
Lines: 50
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <20210516175827.7596a4989cd5f1b9e3cbb840@127.0.0.1>
References: <s7m8nd$f4p$1@dont-email.me>
<s7qkto$131f$1@gioia.aioe.org>
<s7qqib$pav$1@dont-email.me>
<s7r5i8$ah1$1@gioia.aioe.org>
<s7rjoj$ro2$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Injection-Info: reader02.eternal-september.org; posting-host="5f09de62b9e9b4075ad423eeafde414a";
logging-data="30138"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/hPVDUZthI0y18r/RR8r4HBZ8Q2qoFUZE="
Cancel-Lock: sha1:vZHyJQrsYjDSaTCnMdnv0LulO8U=
 by: Kerr-Mudd, John - Sun, 16 May 2021 16:58 UTC

On Sun, 16 May 2021 20:11:15 +0000
Robert Prins <robert@nospicedham.prino.org> wrote:

> On 2021-05-16 13:09, Terje Mathisen wrote:
> > Robert Prins wrote:
> >> On 2021-05-16 08:25, R.Wieser wrote:
> >>>> Is it possible to fit the conversion of a 16 bit signed integer to
> >>>> left-aligned
> >>>> ASCII without leading zeroes in just 65 bytes?
> >>>
> >>> As no specifications have been posted, I do have some code that outputs a
> >>> signed number using just 25 bytes.
> >>>
> >>> The trick ?    Filling the buffer backwards (putting the sign at the end).
> >>
> >> The code is replacement code for the itoa routine in the Borland TP3 compiler,
> >> so it has to give the same result.
> >
> > Why didn't you state so?
>
> I should have done earlier, rather than in that follow-up, apologies.
>
> > The key here is that this function returns a TP string, right?
>
> No, see the code of the current routine I also posted.

Not that I've seen on this NG.

> For what it's worth, -32768 is problematic for all routines posted, it doesn't
> change sign when negated! TP3 also doesn't accept it as valid integer, unless
> coded as $8000.
>
> Robert
> --
> Robert AH Prins
> robert(a)prino(d)org
> The hitchhiking grandfather - https://prino.neocities.org/indez.html
> Some REXX code for use on z/OS - https://prino.neocities.org/zOS/zOS-Tools.html
>

--
Bah, and indeed Humbug.

Re: ITOA in 65 bytes

<s7rmdb$1prb$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=177&group=comp.lang.asm.x86#177

  copy link   Newsgroups: comp.lang.asm.x86
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: address@nospicedham.not.available (R.Wieser)
Newsgroups: comp.lang.asm.x86
Subject: Re: ITOA in 65 bytes
Date: Sun, 16 May 2021 19:56:56 +0200
Organization: Aioe.org NNTP Server
Lines: 20
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <s7rmdb$1prb$1@gioia.aioe.org>
References: <s7m8nd$f4p$1@dont-email.me> <s7qkto$131f$1@gioia.aioe.org> <s7qqib$pav$1@dont-email.me> <s7r5i8$ah1$1@gioia.aioe.org> <s7rjoj$ro2$1@dont-email.me>
Injection-Info: reader02.eternal-september.org; posting-host="5f09de62b9e9b4075ad423eeafde414a";
logging-data="30194"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18a20KANzB+MhY7+xPMWgzP1lolWEqTQYo="
Cancel-Lock: sha1:eIRwIzNDFR9ak4mJjbxaTaPdE7Q=
 by: R.Wieser - Sun, 16 May 2021 17:56 UTC

Robert,

> No, see the code of the current routine I also posted.

Missing : the current routine.

> For what it's worth, -32768 is problematic for all routines posted, it
> doesn't change sign when negated!

:-) You forgot that after the sign change part you have an unsigned value.
And in that mode 0x8000 is decimally represented as 32768. The initial code
Terje posted, with its "xor dx,dx" (instead of the later, shorter "cwd"),
does the job as expected.

Still also missing : a description of what the TP6 output should look like.

Regards,
Rudy Wieser

Re: ITOA in 65 bytes

<s7roth$rv8$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=178&group=comp.lang.asm.x86#178

  copy link   Newsgroups: comp.lang.asm.x86
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: robert@nospicedham.prino.org (Robert Prins)
Newsgroups: comp.lang.asm.x86
Subject: Re: ITOA in 65 bytes
Date: Sun, 16 May 2021 21:39:13 +0000
Organization: A noiseless patient Spider
Lines: 39
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <s7roth$rv8$1@dont-email.me>
References: <s7m8nd$f4p$1@dont-email.me> <s7qkto$131f$1@gioia.aioe.org>
<s7qqib$pav$1@dont-email.me> <s7r5i8$ah1$1@gioia.aioe.org>
<s7rjoj$ro2$1@dont-email.me>
<20210516175827.7596a4989cd5f1b9e3cbb840@127.0.0.1>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: reader02.eternal-september.org; posting-host="5f09de62b9e9b4075ad423eeafde414a";
logging-data="32198"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/vHISuK6GhasOigYZn/IhP87afzgkf8Mk="
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.10.1
Cancel-Lock: sha1:Vhs1vpHpxDvnVWNyGzqfzMeqF2s=
 by: Robert Prins - Sun, 16 May 2021 21:39 UTC

On 2021-05-16 16:58, Kerr-Mudd, John wrote:
> On Sun, 16 May 2021 20:11:15 +0000
> Robert Prins <robert@nospicedham.prino.org> wrote:
>
>> On 2021-05-16 13:09, Terje Mathisen wrote:
>>> Robert Prins wrote:
>>>> On 2021-05-16 08:25, R.Wieser wrote:
>>>>>> Is it possible to fit the conversion of a 16 bit signed integer to
>>>>>> left-aligned
>>>>>> ASCII without leading zeroes in just 65 bytes?
>>>>>
>>>>> As no specifications have been posted, I do have some code that outputs a
>>>>> signed number using just 25 bytes.
>>>>>
>>>>> The trick ?    Filling the buffer backwards (putting the sign at the end).
>>>>
>>>> The code is replacement code for the itoa routine in the Borland TP3 compiler,
>>>> so it has to give the same result.
>>>
>>> Why didn't you state so?
>>
>> I should have done earlier, rather than in that follow-up, apologies.
>>
>>> The key here is that this function returns a TP string, right?
>>
>> No, see the code of the current routine I also posted.
>
> Not that I've seen on this NG.

Then once again it has not gone through. I'll repost it to the direct moderator
address.

Robert
--
Robert AH Prins
robert(a)prino(d)org
The hitchhiking grandfather - https://prino.neocities.org/indez.html
Some REXX code for use on z/OS - https://prino.neocities.org/zOS/zOS-Tools.html

Re: ITOA in 65 bytes

<20210516205636.c7eadf68edc0bbb69db396cb@127.0.0.1>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=180&group=comp.lang.asm.x86#180

  copy link   Newsgroups: comp.lang.asm.x86
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: admin@nospicedham.127.0.0.1 (Kerr-Mudd, John)
Newsgroups: comp.lang.asm.x86
Subject: Re: ITOA in 65 bytes
Date: Sun, 16 May 2021 20:56:36 +0100
Organization: Dis
Lines: 24
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <20210516205636.c7eadf68edc0bbb69db396cb@127.0.0.1>
References: <s7m8nd$f4p$1@dont-email.me>
<s7qkto$131f$1@gioia.aioe.org>
<s7qqib$pav$1@dont-email.me>
<s7r5i8$ah1$1@gioia.aioe.org>
<s7rjoj$ro2$1@dont-email.me>
<s7rmdb$1prb$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: reader02.eternal-september.org; posting-host="5f09de62b9e9b4075ad423eeafde414a";
logging-data="4636"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/ATTmyCHgbwIufS7/wrQacjyw/j8+051k="
Cancel-Lock: sha1:XnhSQgx2Jm2eydH3VVJBOCFREmM=
 by: Kerr-Mudd, John - Sun, 16 May 2021 19:56 UTC

On Sun, 16 May 2021 19:56:56 +0200
"R.Wieser" <address@nospicedham.not.available> wrote:

> Robert,
>
> > No, see the code of the current routine I also posted.
>
> Missing : the current routine.
>
> > For what it's worth, -32768 is problematic for all routines posted, it
> > doesn't change sign when negated!
>
> :-) You forgot that after the sign change part you have an unsigned value.
> And in that mode 0x8000 is decimally represented as 32768. The initial code
> Terje posted, with its "xor dx,dx" (instead of the later, shorter "cwd"),
> does the job as expected.

Sorry. I blame the tester (me).

--
Bah, and indeed Humbug.

Re: ITOA in 65 bytes

<s87ht2$lra$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=184&group=comp.lang.asm.x86#184

  copy link   Newsgroups: comp.lang.asm.x86
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@nospicedham.gmail.com (Bonita Montero)
Newsgroups: comp.lang.asm.x86
Subject: Re: ITOA in 65 bytes
Date: Fri, 21 May 2021 07:53:38 +0200
Organization: A noiseless patient Spider
Lines: 6
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <s87ht2$lra$1@dont-email.me>
References: <s7m8nd$f4p$1@dont-email.me> <s7qkto$131f$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: reader02.eternal-september.org; posting-host="a422121c121ec968aba3ef1d56a9c58f";
logging-data="23066"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/JJa8zq7nF3X9DkMGWssacCDQq/n0/knk="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.10.2
Cancel-Lock: sha1:+h6gwrWc2PI63LZpIloAxg+BYqo=
 by: Bonita Montero - Fri, 21 May 2021 05:53 UTC

> As no specifications have been posted, I do have some code that outputs a
> signed number using just 25 bytes.
> The trick ? Filling the buffer backwards (putting the sign at the end).

Show the code !

Re: ITOA in 65 bytes

<s87ql4$17p$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=185&group=comp.lang.asm.x86#185

  copy link   Newsgroups: comp.lang.asm.x86
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: address@nospicedham.not.available (R.Wieser)
Newsgroups: comp.lang.asm.x86
Subject: Re: ITOA in 65 bytes
Date: Fri, 21 May 2021 10:22:47 +0200
Organization: Aioe.org NNTP Server
Lines: 20
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <s87ql4$17p$1@gioia.aioe.org>
References: <s7m8nd$f4p$1@dont-email.me> <s7qkto$131f$1@gioia.aioe.org> <s87ht2$lra$1@dont-email.me>
Injection-Info: reader02.eternal-september.org; posting-host="9579d1271bbcab8c5bed05c82397b521";
logging-data="4442"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19bIYJV4zHgmZlFnv4u/kd3FmjRhGz2aCk="
Cancel-Lock: sha1:vPVgsJ9LyWECXq3CRnRna114jgg=
 by: R.Wieser - Fri, 21 May 2021 08:22 UTC

Bonita,

>> As no specifications have been posted, I do have some code that outputs a
>> signed number using just 25 bytes.
>> The trick ? Filling the buffer backwards (putting the sign at the
>> end).
>
> Show the code !

Alas, when it was made clear it had to work "just as in TP3" I threw the
code away. :-|

There was nothing special to it though. Pretty-much the same as the first
code Terje posted, just without the pushing and popping (instead directly
storing it into the buffer).

Regards,
Rudy Wieser

Re: ITOA in 65 bytes

<20210521105014.caedbace1ceece2cd3c9b012@127.0.0.1>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=186&group=comp.lang.asm.x86#186

  copy link   Newsgroups: comp.lang.asm.x86
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: admin@nospicedham.127.0.0.1 (Kerr-Mudd, John)
Newsgroups: comp.lang.asm.x86
Subject: Re: ITOA in 65 bytes
Date: Fri, 21 May 2021 10:50:14 +0100
Organization: Dis
Lines: 39
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <20210521105014.caedbace1ceece2cd3c9b012@127.0.0.1>
References: <s7m8nd$f4p$1@dont-email.me>
<s7qkto$131f$1@gioia.aioe.org>
<s87ht2$lra$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: reader02.eternal-september.org; posting-host="9579d1271bbcab8c5bed05c82397b521";
logging-data="4473"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/FVJiUaWd4Fmy93OsSvXlfTUdWlfBeMUI="
Cancel-Lock: sha1:/mzL5UdChLz0cKN9EaeAW4whL5M=
 by: Kerr-Mudd, John - Fri, 21 May 2021 09:50 UTC

On Fri, 21 May 2021 07:53:38 +0200
Bonita Montero <Bonita.Montero@nospicedham.gmail.com> wrote:

> > As no specifications have been posted, I do have some code that outputs a
> > signed number using just 25 bytes.
> > The trick ? Filling the buffer backwards (putting the sign at the end).
>
> Show the code !
>

Simple enough to re-invent I'd have thought.
Something like this? (untested)

;; 16bit num in ax (max +/-32k), di is output area. uses bx,dx

add di,6 ; end of display area (possibly 5 digits & sign)
test ax,ax ; Is it positive?
jge NotNeg
mov byte [di],'-' ; put minus sign
neg ax ; show as positive
NotNeg:
mov bx,10 ; decimal
NextDigit:
xor dx,dx ; clear for div
div bx ; get digit in dl
add dl,'0'
dec di ; backward
mov [di],dl ; putc
test ax,ax ; finished?
jnz NextDigit

;;di now points to output string with '-' at the end if negative

--
Bah, and indeed Humbug.

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor