Path: utzoo!attcan!telly!problem!compus!lethe!torsqnt!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!software.org!cox From: cox@software.org (Guy Cox) Newsgroups: comp.sources.wanted Subject: Re: What does this assembler code do? Keywords: VAX, VMS, backup Message-ID: <1881@software.software.org> Date: 7 Dec 90 14:25:49 GMT References: Sender: news@software.org Reply-To: cox@software.org (Guy Cox) Distribution: comp Organization: Software Productivity Consortium, Herndon, Virginia Lines: 51 In article ralph@laas.fr writes: > The following embedded assembler code belongs to some C language code > for reading VAX VMS Backup tapes under Unix. Maybe this would compile > under Ultrix. If someone can translate this into straight C, I would > sure appreciate that, also. Here's the function: > > vdatetosec() > { > asm("movl 4(ap),r0"); > asm("movl (r0)+,r2; movl (r0),r3; subl2 $2913970176,r2; sbwc $8164719,r3 "); > asm("ediv $10000000,r2,r0,r1"); > } > > Neither SPARCs nor 680x0s like this code! > > -- > Ralph P. Sobek Disclaimer: The above ruminations are my own. > ralph@laas.fr Addresses are ordered by importance. > ralph@laas.uucp, or ...!uunet!laas!ralph > If all else fails, try: sobek@eclair.Berkeley.EDU > =============================================================================== > Reliable software should kill people reliably! -Andy Mickel, Pascal News #13,78 The first instruction load the first argument into register 0. ( it looks like a pointer to me). the second is an autoincrement move from the location now contained in reg 0 to reg 2. The pointer in reg 0 is increment by 4 after the move. the contents pointed to by the new pointer in reg 0 are moved to reg 3. now a long subtraction of the hex value to the contents of reg 2. ( obviously some kind of "magic" number. now a subtract with carry of the hex value from reg 3. ( another magic number ?). and finally an extended divide of the $10000000 into the quadword r2-r3 with the quotient going into r0 and the remainder going into r1. It's pretty straight forward except for the magic numbers . -- // //Remember; Tuesday is Soylent green day! // Guy O. Cox, Jr. Software Productivity Consortium. 2214 RockHill Rd Herndon, VA 22090 703-742-7219 cox@software.org