home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.asm.x86      Ahh, the lost art of x86 assembly      4,675 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 4,381 of 4,675   
   Kerr-Mudd, John to R.Wieser   
   Re: shorter code to print a 16bit number   
   30 Jul 21 19:55:09   
   
   From: admin@nospicedham.127.0.0.1   
      
   On Fri, 30 Jul 2021 17:26:59 +0200   
   "R.Wieser"  wrote:   
      
   > luser,   
   >   
   > > It's trying to print a 16bit signed integer (ignoring INT_MIN)   
   > > left to right with no leading zeros.   
   > ...   
   > > It tests each digit for zero where it jumps over the int 10h call   
   > > except the last digit.   
   >   
   > Those two do not match.   And as your code seem to be written according to   
   > the second ...   
   > Try printing the value 3002 (or something else with embedded zeroes) to see   
   > what I mean.   
   >   
   > > Is it possible to tighten up this code?   
   >   
   > I'm not sure what "tighten up" is ment to be read as.   Smaller ?   Faster ?   
   > In the first case, how many bytes is it now ?   
   >   
   > My own, erstwhile "trick" was, while doing the same as you (dividing by the   
   > largest divisor first), to load a register with the divisor and than call a   
   > small routine doing the division and printing.   
   >   
   > But in the light of your "skip leading zeroes" you could do worse than to   
   > look at what John posted, as that method automatically discards leading   
   > zeroes - it simply stops as soon as the remainder becomes zero.  I'm not so   
   > sure about if that "loop" at the end will work though, as the INT 0x10 could   
   > easily trash cx..   
   >   
   Seems to be OK on this "DOS" VDM under XP - but yes, the int 10 was put in for   
   the OP - originally the code put to a buffer at di, with a single print (ah=9,   
   Int 21) at the end.   
      
   > > It occurs to me that the DIV instruction has a mod field. So that   
   > > means the divisor could be register indirect, right? like through SI   
   > > or BX, maybe?   
   >   
   > Yes, would work.  And that same list can than also be used to skip leading   
   > zeroes.   
   >   
   > > Sorry if I'm jumping the gun asking for help before exerting the   
   > > requisite effort.   
   >   
   > I can imagine that you ask, but I do not quite understand why you did not   
   > test your own code first ...   
   >   
   > Regards,   
   > Rudy Wieser   
   >   
   >   
   >   
      
      
   --   
   Bah, and indeed Humbug.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca