Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Random number in 1991 Pascal

Tags:

pascal

karel

I am running a Fenuc Karel robot for a class assignment which uses a variation of Pascal however our robot is from 1991-1993 before they added random(). Does anyone know how to get a random number on an old dos implementation of Pascal? Please note because of the age variable names can't be more than 8 characters and numbers can't count past 255

like image 524
HDeffo Avatar asked Nov 09 '22 19:11

HDeffo


1 Answers

If it is a borland pascal version, you can use asm { … } blocks, which would allow you to get a value from the RTC, which is sufficiently random for many intents and purposes. Given a variable random:

asm {
  xor ax, ax;
  int 1ah;
  mv random, al;
}

This would give you the last 8 bit of the real time clock value.

Apart from that you could look for pseudorandom number generation on old machines, e.g. C64; though you'd have to port the code to pascal.

Update: It appears, Fanuc Karel (I hope this is it) has a GET_TIME routine, though I'm unsure about what that returns.

like image 52
llogiq Avatar answered Dec 18 '22 15:12

llogiq