#: 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 .
|