jwhitson@wpi.wpi.edu (John C Whitson KB2GNC) (12/14/89)
Help! Very quick easy question!!! I have a DEC DECStation 3100 running Ultrix, and If I do the following: cc -S file.c I get the associated .s file, the assembly level code. In there, there are a large amount of symbols, etc, of the format $n, where n is a number. $sp is also referred to in the spirit of a stack pointer. Could someone help me out by pointing out what the $ symbol does here, and how one would recognize a register from a local symbol, because the .s file contains both in the same context. Why on Earth, do you ask, am I looking at .s files? Because I am a teaching assistant for a class here at WPI in VAX Assembly language, and I wish to illustrate the difference between a CISC machine and a RISC machine. I figured, not knowing MIPS Assembler, that all I had to do was throw a small C file into the compiler, and I could guess at the output. Alas, I was wrong. But thanks for helping me out!! -- --------------------------------------------------------------------------- John Whitson: Internet: jwhitson@wpi.wpi.edu Bitnet: jwhitson@wpi.bitnet UUCP: uunet!wpi.wpi.edu!jwhitson ---------- Anything with this tag on it is purely my own opinion ---------
rudy@mips.COM (Rudy Wang) (12/27/89)
In article <6269@wpi.wpi.edu> jwhitson@wpi.wpi.edu (John C Whitson KB2GNC) writes: > > Help! Very quick easy question!!! > > I have a DEC DECStation 3100 running Ultrix, and > If I do the following: > > cc -S file.c > > I get the associated .s file, the assembly level code. > In there, there are a large amount of symbols, etc, of > the format $n, where n is a number. $sp is also referred > to in the spirit of a stack pointer. > > Could someone help me out by pointing out what the $ symbol > does here, and how one would recognize a register from a > local symbol, because the .s file contains both in the same > context. > > Why on Earth, do you ask, am I looking at .s files? Because > I am a teaching assistant for a class here at WPI in VAX > Assembly language, and I wish to illustrate the difference > between a CISC machine and a RISC machine. I figured, not > knowing MIPS Assembler, that all I had to do was throw a small > C file into the compiler, and I could guess at the output. > Alas, I was wrong. But thanks for helping me out!! > >-- First of all, if you can get your hands on a manual called "MIPS Assembly Language Programmer's Guide" (order number 3201DOC from your local MIPS branch office), it will be the best place to look for answers for all your MIPS assembler question. There's another manual called "MIPS Languages Programmer's Guide" (order number 3200DOC) also offers good tips on the Mips compilers and debugger. I'm not sure if DEC has the equivalent manuals, but the MIPS manual should work just as well since DEC is using virtually the same compiler and assembler. If the manuals are not handy, you can always try to look at the header file: "/usr/include/regdef.h" for register definitions: #define zero $0 /* wired zero */ #define AT $at /* assembler temp */ #define v0 $2 /* return value */ #define v1 $3 #define a0 $4 /* argument registers */ #define a1 $5 #define a2 $6 #define a3 $7 #define t0 $8 /* caller saved */ #define t1 $9 #define t2 $10 #define t3 $11 #define t4 $12 #define t5 $13 #define t6 $14 #define t7 $15 #define s0 $16 /* callee saved */ #define s1 $17 #define s2 $18 #define s3 $19 #define s4 $20 #define s5 $21 #define s6 $22 #define s7 $23 #define t8 $24 /* code generator */ #define t9 $25 #define k0 $26 /* kernel temporary */ #define k1 $27 #define gp $28 /* global pointer */ #define sp $29 /* stack pointer */ #define s8 $30 /* one more callee saved */ #define ra $31 /* return address */ #define fp $30 /* obsolete name -- going away soon */ And in addition, there're $f0 through $f31 defined as the floating point registers. Any other symbols in the form of "$n" are just plain label definitions (addresses of text) and symbols in the form of "$$n" are variables (addresses of data). Hope this helps. >--------------------------------------------------------------------------- >John Whitson: Internet: jwhitson@wpi.wpi.edu Bitnet: jwhitson@wpi.bitnet > UUCP: uunet!wpi.wpi.edu!jwhitson >---------- Anything with this tag on it is purely my own opinion --------- -- UUCP: {ames,decwrl,prls,pyramid}!mips!rudy (or rudy@mips.com) DDD: 408-991-0247 Rudy Wang (or 408-720-1700, Ext. 247) USPS: MIPS Computer Systems, 930 Arques, Sunnyvale, CA 94086-3650 Quote: I think they're for 1 AM - Descartes, about his midnight snacks