From: admin@nospicedham.127.0.0.1   
      
   On Fri, 21 May 2021 07:53:38 +0200   
   Bonita Montero 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.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|