www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/03/06/17:46:50

From: battle DOT axe AT PEGASUZ DOT COM
Date: Wed, 6 Mar 1996 17:44:16 -0500
Message-ID: <TCPSMTP.16.3.6.-15.44.16.2983759767.73238@PEGASUZ.COM>
Subject: ASM code & Random
To: djgpp AT delorie DOT com

A9>This is the code:

asm("
  pusha
  movl $0xa0000,%edi
  movl _virt,%esi       # virt declared somewhere
  movl $32000,%ecx
  movw _dos_seg,%es
  cld
  rep movsw
  popa
")

       How's this for more speed?  The REP command will repeat the
string command immediately following it (MOVSW).  I also shortened all
those push/pop operations into one pusha/popa command.. like 6 less
operations plus the loop should be a bit faster..


A9>Wait! One more thing (*stupid thing*) How can i get a random int from zero
A9>to a fixed value???  I don't know how to use the random functions in DJGPP!
A9>They talk about MAXINT, but i do not know what is that!


       my_random_number = rand() % 100;

       This gives me a number between 0 and 99.  (Just add parenthesis
and add one to the value..  works ok for me...  You may have to do a
randomize(); somewhere in the begining once to initialize the seed for
the random number.. I don't remember to clearly.. it's been a while)


Jonathan Tarbox
-----------------
battle DOT axe AT pegasuz DOT com


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019