|
|
DEMO file: /home/cs255001/demo/asm/3-array/array-def.s
|
DEMO file: /home/cs255001/demo/asm/3-array/array-def.s
|
DEMO file: /home/cs255001/demo/asm/3-array/array-def.s
|
You can tell the data type of array from how the array elements are used:
|
High level programming construct:
char A[ ] = {11, 12, 13, 14, 15}; // initialized array |
is translated to the following assembler construct:
A: .byte 11, 12, 13, 14, 15 // initialized array
|
The .byte 11, 12, 13, 14, 15 directive will put the 8 bits 2s complement codes for 11, 12, 13, 14, 15 into 5 consecutive memory cells
High level programming construct:
short B[ ] = {111, 112, 113, 114, 115}; // init array |
is translated to the following assembler construct:
B: .2byte 111, 112, 113, 114, 115 // init array
|
The .2byte 111, 112, 113, 114, 115 directive will put the 16 bits 2s complement codes for 111, 112, 113, 114, 115 into 10 consecutive memory cells
High level programming construct:
int C[ ] = {1111, 1112, 1113, 1114, 1115}; |
is translated to the following assembler construct:
C: .4byte 1111, 1112, 1113, 1114, 1115
|
The .4byte 1111, 1112, 1113, 1114, 115 directive will put the 32 bits 2s complement codes for 1111, 1112, 1113, 1114, 1115 into 20 consecutive memory cells