From: admin@nospicedham.127.0.0.1   
      
   On Fri, 30 Jul 2021 13:52:44 +0100   
   "Kerr-Mudd, John" wrote:   
      
   > On Thu, 29 Jul 2021 22:11:00 -0700 (PDT)   
   > "luser...@nospicedham.gmail.com" wrote:   
   >   
   > > I wrote this machine code to trace the LIT word in my forth interpreter.   
   > > Is it possible to tighten up this code? It's trying to print a 16bit signed   
   > > integer (ignoring INT_MIN) left to right with no leading zeros.   
   > >   
   >   
   []   
   > >   
   > I think I got the jist of it;   
   >   
   > here's some std asm code from earlier, rejigged for int 0x10 - it requires 5   
   free stack positions.   
   > uses ax,bx,cx,dx - 36 bytes   
      
   corrected version - 37   
      
   >   
   > PrtNum: ; ax to con using int10 fn 0E: no leading spaces or zeros but show   
   '-'   
   > test ax,ax ; Is it positive?   
   > jge NotNeg   
   > push ax   
   > mov ax,0x0E00+'-'   
   > int 0x10 ; bios prtc   
   > pop ax   
   > neg ax ; show as positive: hibit set only for 0x8000!#   
   > NotNeg:   
   > mov bx,10 ; decimal   
   > xor cx,cx ; Digit count (5 max)   
   > NextDigit:   
   > inc cx ; prt at least 1 digit (i.e. '0')   
   > xor dx,dx ; clear prev, cant cwd for #8000   
   > div bx   
   > push dx ; Remainder is the digit   
   > test ax,ax ; Is it zero yet?   
   > jnz NextDigit   
   > PutDigit:   
   > pop ax ; get digit (000x)   
      
   > add ax,0x0E+'0' ; digit to display value, prtfn in ah   
   I didn't test! Make that line:   
    add ax,0x0E00+'0' ; digit to display value, prtfn in ah   
      
    int 0x10 ; bios prtc   
   > loop PutDigit   
   >   
   >   
   >   
   >   
   >   
   >   
   >   
   > --   
   > Bah, and indeed Humbug.   
   >   
      
      
   --   
   Bah, and indeed Humbug.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|