From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f7344,2afd440a210c7fb0 X-Google-Attributes: gidf7344,public X-Google-Thread: 1014db,6bdc5c27a0dec527 X-Google-Attributes: gid1014db,public X-Google-Thread: 1164f8,df8a3dc583bf1f5f X-Google-Attributes: gid1164f8,public From: Dan.Pop@cern.ch (Dan Pop) Subject: Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * Date: 1998/09/09 Message-ID: #1/1 X-Deja-AN: 389422848 References: <0095000017115526000002L062*@MHS> <6t24vj$kep$1@Starbase.NeoSoft.COM> <6t4dca$k0h$1@nntp.ucs.ubc.ca> <6t4cui$hfu@espresso.cafe.net> <6t4h4d$mo4$1@nntp.ucs.ubc.ca> X-Complaints-To: news@sunnews.cern.ch X-Trace: sunnews.cern.ch 905354676 18453 (None) 137.138.32.79 Organization: CERN European Lab for Particle Physics Newsgroups: comp.os.vms,comp.sys.dec,comp.lang.c In <6t4h4d$mo4$1@nntp.ucs.ubc.ca> shoppa@alph02.triumf.ca (Tim Shoppa) writes: >Are you sure you want to say that? I'd call them a feature of the >PDP-11 instruction set before I called them a feature of MACRO-11, but ... >For example, if in PDP-11 assembler I want to move a string >pointed to by R2 to an area pointed to by R3, I just say: > >LOOP: MOVB (R2)+,(R3)+ > BNE LOOP In other words, the PDP-11 instruction set does NOT contain *any* instruction for C string manipulation, you have to do that with programmed loops, just as you'd do it on any other processor. Using your logic, this is a feature of any processor's instruction set. >If I tried to do this any other way - say by prepending the string length, >or by appending a FF or a '$' - the code gets longer Again, testing against zero takes fewer bytes on many instruction sets. >(though not necessarily slower...) If the operation is not copying the string but something needing the length of the string (e.g. strlen() or strcat()), prepending the string length is provably faster. Try to implement strlen() for Pascal-style strings in PDP-11 assembler and you'll discover that Pascal-style strings are a feature of the PDP-11 instruction set :-) It takes exactly one instruction, besides the RET (RTS R6). The same thing for C strings (optimized for instruction count) would be something like: MOV -1,R0 LOOP: INC R0 TSTB (R2)+ BNE LOOP Dan -- Dan Pop CERN, IT Division Email: Dan.Pop@cern.ch Mail: CERN - EP, Bat. 31 1-014, CH-1211 Geneve 23, Switzerland