TIP: Click on subject to list as thread! ANSI
echo: cis.tandy.coco
to: Bob van der Poel 76510,2203
from: Kevin Darling (UG Pres) 76703,4227
date: 1990-05-11 01:48:40
subject: #3414-C arrays

#: 3416 S10/Tandy CoCo
    11-May-90  01:48:40
Sb: #3414-C arrays
Fm: Kevin Darling (UG Pres) 76703,4227
To: Bob van der Poel 76510,2203

Bob - it sure looks wrong to me. Here is a program and a function, and
their resulting asm code outputs compared.

main()                  foo(stuff)
{ char array[4][80];      char stuff[][80];
  array[0][0] = 10;     { stuff[0][0] = 10;
  array[1][5] = 20;       stuff[1][5] = 20;
  array[2][50]= 30;       stuff[2][50] = 30;
  foo(array);    }      }

* main()                 * foo(stuff)
*   char array[4][80];   *   char stuff[][80];
 leas -320,s              pshs u
*   array[0][0] = 10;    *   stuff[0][0] = 10;
 ldd #10                  ldd #10
 stb 0,s                  stb [4,s]             <== OK
*   array[1][5] = 20;    *   stuff[1][5] = 20;
 ldd #20                  ldd #20
*                         ldx 4,s
 stb 85,s                 stb 5,x               <== ??!
*   array[2][50]= 30;    *   stuff[2][50] = 30;
 ldd #30                  ldd #30
*                         ldx 4,s
 stb 210,s                stb 50,x              <== ??!
*   foo(array);          * }
 leax 0,s                 puls u,pc
 pshs x
 lbsr foo

**********
OTOH, many C people have told me that this is not a common method of
working with stuff, and to simply use other ways. Okay, I guess .

SOURCE: compuserve via textfiles.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.