Path: utzoo!mnetor!uunet!husc6!tut.cis.ohio-state.edu!erd From: erd@tut.cis.ohio-state.edu (Ethan R. Dicks) Newsgroups: comp.sys.amiga Subject: Short assembler program to determine CPU type (and a plea for help) Message-ID: <8271@tut.cis.ohio-state.edu> Date: 14 Mar 88 18:39:35 GMT Organization: Ohio State Computer & Info Science Lines: 153 Keywords: assembler tiny Followups-to: comp.sys.amiga.tech Here is a very small program to determine the type of CPU you are running. It is only 3Kb with source, so I am posting it here. I include the source because as the comments state, this is my first attempt at assembler and I know it is crude...efficient, but crude. I would apreciate e-mailed comments from those few assembler hacks out there (Bryce, are you listening?) to inprove my style. I know how to code 68000 efficiently, I need pointers on style regarding the Amiga include files - structures in C are easy to use, how do you use them (or their equvalents) assembler? #! /bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #! /bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create the files: # whatcpu.asm # whatcpu.uue # This archive created: Mon Mar 14 13:31:56 1988 export PATH; PATH=/bin:$PATH if test -f 'whatcpu.asm' then echo shar: will not over-write existing file "'whatcpu.asm'" else cat << \SHAR_EOF > 'whatcpu.asm' ; WhatCPU.asm ; ; Actually a hand conversion of WhatCPU.c by Dave Haynie ; done by Ethan Dicks 14-mar-88 ; ; I did this as my first project in assembler. Documentation is very ; scanty regarding the use of structures in assembler. I got the magic ; offset into the ExecBase structure for the AttnFlags word by compiling ; Dave Haynie's program with Lattice, on a friend's machine, then ; running omd on the .o file. ; ; To recompile: ; asm WhatCPU.asm ; blink WhatCPU.o ; ; This code is freely redistributable, although not pretty. ; section code _LVOCloseLibrary equ -$19e _LVOOpenLibrary equ -$228 _LVOWrite equ -$30 _LVOOutput equ -$3c execbase equ 4 start: movea.l execbase,a6 ;save pointer to Execbase in a6 lea dosname(pc),a1 ;point to library name moveq.l #0,d0 ;pick any version jsr _LVOOpenLibrary(a6) ;open dos.library movea.l d0,a5 ;save DosBase in A5 jsr _LVOOutput(a5) move.l d0,d5 ;save OutputHandle in D5 ; ; title message ; move.l #header,d2 ;print intro message move.l headerlength,d3 bsr.s print ; ; check bits ; btst #1,297(a6) ;check Afb_68020 beq.s not68020 ;nope... move.l #mc68020,d2 ;print "68020" moveq.l #6,d3 bsr.s print bra.s break ; not68020: btst #0,297(a6) ;check Afb_68010 beq.s not68010 ;nope... move.l #mc68010,d2 ;print "68010" moveq.l #6,d3 bsr.s print bra.s break ; not68010: move.l #mc68000,d2 ;must be 68000; print it moveq.l #6,d3 bsr.s print ; break: btst #4,297(a6) ;check Afb_68881 beq.s not68881 ;nope... move.l #mc68881,d2 ;print "68881" moveq.l #6,d3 bsr.s print not68881: ; ; at end of string ; move.l #cr,d2 ;finish off with move.l crlength,d3 bsr.s print ; ; clean up and exit ; movea.l a5,a1 ;get DosBase jsr _LVOCloseLibrary(a6) ;close dos.library moveq.l #0,d0 ;set return code rts ;go home ; ; subroutines ; print: move.l d5,d1 ;set output handle jsr _LVOWrite(a5) ;write string to console rts ;go back ; ; data section ; headerlength: dc.l 22 ;table of string lengths proclength: dc.l 6 ; for _LVOWrite crlength: dc.l 2 ; ; ; byte aligned data ; dosname: dc.b 'dos.library',0 header: dc.b 'System Configuration: ' mc68020: dc.b '68020 ' mc68010: dc.b '68010 ' mc68000: dc.b '68000 ' mc68881: dc.b '68881 ' cr: dc.b 13,10 end SHAR_EOF fi # end of overwriting check if test -f 'whatcpu.uue' then echo shar: will not over-write existing file "'whatcpu.uue'" else cat << \SHAR_EOF > 'whatcpu.uue' begin 777 whatcpu.uue M #\P ! U #Z0 #4L>0 1#^@".< !. MKOW8*D!.K?_$*@ D/ *(F.0 (IA7 @N $!*6<,)#P "X=@9A2F > M""X $I9PPD/ +YV!F$V8 HD/ ,1V!F$J""X ! $I9PHD/ ,IV M!F$8)#P #0)CD "280HB34ZN_F)P $YU(@5.K?_03G4 6 !@ M )D;W,N;&EB0!3>7-T96T@0V]N9FEG=7)A=&EO;CH@-C@P,C @-C@P M,3 @-C@P,# @-C@X.#$@#0H ^P ( '( !L 8@ : % !$ , " : _(( end SHAR_EOF fi # end of overwriting check # End of shell archive exit 0 -- Ethan R. Dicks | ###### This signifies that the poster is a member in Specialized Software| ## good sitting of Inertia House: Bodies at rest. 2101 Iuka Ave. | ## Columbus OH 43201 | ###### "You get it, you're closer."