Mirror of CollapseOS
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

28 lines
1.3KB

  1. This file describe tricks and conventions that are used throughout the code and
  2. might need explanation.
  3. or a: Equivalent to "cp 0", but results in a shorter opcode.
  4. xor a: sets A to 0 more efficiently than ld a, 0
  5. and 0xbf: Given a letter in the a-z range, changes it to its uppercase value
  6. if it's already uppercased, then it stays that way.
  7. Z if almost always used as a success indicator for routines. Set for success,
  8. Reset for failure. "xor a" (destroys A) and "cp a" (preserves A) are used to
  9. ensure Z is set. To ensure that it is reset, it's a bit more complicated and
  10. "unsetZ" routine exists for that, although that in certain circumstances,
  11. "inc a \ dec a" or "or a" can work.
  12. z80 is little endian in its 16-bit loading operations. For example, "ld hl, (0)"
  13. will load the contents of memory address 0 in L and memory address 1 in H. This
  14. little-endianess is followed by Collapse OS in most situations. When it's not,
  15. it's specified in comments.
  16. This get a bit awkward with regards to 32-bit. There are no "native" z80 32-bit
  17. operations, so z80 doesn't mandate an alignment. In Collapse OS, 32-bit numbers
  18. are stored as "big endian pair of little endian 16-bit numbers". For example,
  19. if "ld dehl, (0)" existed and if the first 4 bytes of memory were 0x01, 0x02,
  20. 0x03 and 0x04, then DE (being the "high" word) would be 0x0201 and HL would be
  21. 0x0403.