mirror of
https://github.com/pkivolowitz/asm_book.git
synced 2026-06-22 22:06:48 +08:00
added 68K results
This commit is contained in:
parent
ad1ee3599c
commit
3337e122cc
3 changed files with 62 additions and 19 deletions
28
.vscode/settings.json
vendored
28
.vscode/settings.json
vendored
|
|
@ -33,19 +33,21 @@
|
||||||
"MD024":false
|
"MD024":false
|
||||||
},
|
},
|
||||||
"cSpell.ignoreWords": [
|
"cSpell.ignoreWords": [
|
||||||
"Rypo",
|
"Athanasios",
|
||||||
"dless",
|
"Pavlidis",
|
||||||
"dmore",
|
"Rypo",
|
||||||
"foov",
|
"dless",
|
||||||
"ndless",
|
"dmore",
|
||||||
"ndmore",
|
"foov",
|
||||||
"onditionally",
|
"ndless",
|
||||||
"onsole",
|
"ndmore",
|
||||||
"rotypo",
|
"onditionally",
|
||||||
"rwtypo",
|
"onsole",
|
||||||
"slen",
|
"rotypo",
|
||||||
"ssize"
|
"rwtypo",
|
||||||
],
|
"slen",
|
||||||
|
"ssize"
|
||||||
|
],
|
||||||
"files.associations": {
|
"files.associations": {
|
||||||
"ostream": "cpp"
|
"ostream": "cpp"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -156,8 +156,25 @@ on a little endian machine, it is the first byte in the long in memory.
|
||||||
|
|
||||||
## Output on a big endian machine
|
## Output on a big endian machine
|
||||||
|
|
||||||
We tried and tried but could not get anyone to run this code on a
|
We tried and tried to find a kind soul to run the above program on a
|
||||||
big-endian machine.
|
big-endian machine. Redditor Athanasios Pavlidis ran a C version of the
|
||||||
|
code on both an Amiga A4000/MC68040 and an Amiga A3000/MC68030. The
|
||||||
|
results were:
|
||||||
|
|
||||||
|
```text
|
||||||
|
Endianness of this computer:
|
||||||
|
i16: 0123
|
||||||
|
i32: 01234567
|
||||||
|
i64: 89abcdef01234567
|
||||||
|
```
|
||||||
|
|
||||||
|
Notice the values for `i16` and `i32` match the right hand column above.
|
||||||
|
The value for `i64` is borked in that we specified it in the C code as a
|
||||||
|
`long`. We then tried specifying the `long` as a `long long`. Apparently
|
||||||
|
there is little support for 64 bit numbers on this ancient but
|
||||||
|
venerable architecture.
|
||||||
|
|
||||||
|
Athanasios Pavlidis has our appreciation and thanks.
|
||||||
|
|
||||||
## Can't the ARM swing both ways?
|
## Can't the ARM swing both ways?
|
||||||
|
|
||||||
|
|
@ -169,7 +186,8 @@ install the big-endian version of the toolchain.
|
||||||
Here is a quote from Wikipedia:
|
Here is a quote from Wikipedia:
|
||||||
|
|
||||||
```text
|
```text
|
||||||
ARM, C-Sky, and RISC-V have no relevant big-endian deployments, and can be considered little-endian in practice.
|
ARM, C-Sky, and RISC-V have no relevant big-endian deployments, and can
|
||||||
|
be considered little-endian in practice.
|
||||||
```
|
```
|
||||||
|
|
||||||
## What is Intel?
|
## What is Intel?
|
||||||
|
|
@ -178,6 +196,4 @@ The common Intel processors are also little-endian.
|
||||||
|
|
||||||
## So what's big-endian?
|
## So what's big-endian?
|
||||||
|
|
||||||
The Motorola 68K family - we reached out to the Amiga user community in
|
IBM mainframes and the Motorola 68K family come to mind. See above.
|
||||||
the hopes that someone would run the code, but no one has and this makes
|
|
||||||
us sad. :(
|
|
||||||
|
|
|
||||||
25
section_3/endian/main.c
Normal file
25
section_3/endian/main.c
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
void Dump(void * i, int length) {
|
||||||
|
unsigned char * ptr = (unsigned char *) i;
|
||||||
|
|
||||||
|
for (int counter = 0; counter < length; counter++) {
|
||||||
|
printf("%02x", *(ptr++));
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
unsigned short i16 = 0x0123;
|
||||||
|
unsigned int i32 = 0x01234567;
|
||||||
|
unsigned long i64 = 0x0123456789ABCDEF;
|
||||||
|
|
||||||
|
printf("Endianness of this computer:\n");
|
||||||
|
printf("i16: ");
|
||||||
|
Dump((void *) &i16, 2);
|
||||||
|
printf("i32: ");
|
||||||
|
Dump((void *)&i32, 4);
|
||||||
|
printf("i64: ");
|
||||||
|
Dump((void *)&i64, 8);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue