z8000_as.1 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. .TH Z8000_AS 1
  2. .ad
  3. .SH NAME
  4. z8000_as \- assembler for Zilog z8000 (segmented version)
  5. .SH SYNOPSIS
  6. /usr/em/lib/z8000_as [options] argument ...
  7. .SH DESCRIPTION
  8. This assembler is made with the general framework
  9. described in \fIuni_ass\fP(6).
  10. .SH SYNTAX
  11. .IP instructions
  12. Instruction mnemonics are implemented exactly as described in
  13. \fIZ8000 PLZ/ASM Assembly Language Programming Manual\fP and
  14. \fIAmZ8001/2 Processor Instruction Set\fP.
  15. .IP registers
  16. The z8000 has sixteen 16-bit general purpose registers specified
  17. as R0 through R15. All sixteen registers can be used as accumulators.
  18. In addition to this, fifteen of the sixteen registers may be used
  19. in addressing mode calculations as either indirect, index or
  20. base-address registers. Because the instruction format encoding
  21. uses the value zero to differentiate between various addressing
  22. modes, register R0 (or the register pair RR0) cannot be used as an
  23. indirect, index or base-address register.
  24. It is also possible to address registers as groups of 8, 32 or 64 bits.
  25. These registers are specified as follows.
  26. .nf
  27. .ta 8n 16n 24n 32n 40n 48n
  28. - RH0, RL0, RH1, RL1, ..., RH7, RL7 for 8-bit regis-
  29. ters. (\fIH\fP stands for high-order byte, and \fIL\fP stands
  30. for low-order byte within a word register). These
  31. registers overlap 16-bit registers R0 through R7.
  32. - RR0, RR2, ..., RR14 for 32-bit register pairs.
  33. - RQ0, RQ4, RQ8 and RQ12 for 64-bit register quadruples.
  34. .fi
  35. Besides register pair RR14 is used as stackpointer.
  36. .IP "addressing modes"
  37. .nf
  38. .ta 8n 16n 24n 32n 40n 48n
  39. syntax meaning (name-mnemonic)
  40. $expr the value of expr is the operand.
  41. (immediate-IM)
  42. reg contents of register reg is operand. Any
  43. register as described above is allowed.
  44. (register-R)
  45. *reg32 contents of register pair reg32 is add-
  46. ress of operand. Any register pair can
  47. be used except RR0.
  48. (indirect register-IR)
  49. expr expr is address of operand.
  50. (direct address-DA)
  51. expr(reg16) value of expr + contents of word regis-
  52. ter reg16 yields address of operand.
  53. Any word register can be used except R0.
  54. (indexed address-X)
  55. expr expr is address of operand. This mode
  56. is implied by its instruction. It is
  57. only used by CALR, DJNZ, JR, LDAR and
  58. LDR and is the only mode available to
  59. these instructions. In fact this mode
  60. differs not from the mode DA.
  61. (relative address-RA)
  62. reg32($expr) contents of register pair reg32 + value
  63. of expr yields address of operand. Any
  64. register pair can be used except RR0.
  65. (based address-BA)
  66. reg32(reg16) contents of register pair reg32 + con-
  67. tents of word register reg16 yields
  68. address of operand. Any register pair/
  69. word register can be used except RR0/R0.
  70. (based indexed address-BX)
  71. .fi
  72. .IP "segmented addresses"
  73. Segmented addresses require 23 bits, 7 bits for the segment number
  74. and 16 bits for the offset within a segment.
  75. So segment 0 contains addresses 0-FFFF, segment 1 contains addresses
  76. 10000-1FFFF, and so on.
  77. .br
  78. Assembler syntax of addresses and immediate data is as described above
  79. (modes IM, DA and X).
  80. Thus the assembler treats e.g. address 2BC0F as an address in segment 2
  81. with offset BC0F within the segment.
  82. There is also an explicit way to express this using the, more unusual,
  83. syntax <<segment>>offset.
  84. .br
  85. There are two internal representations of segmented addresses
  86. depending on the size of the offset. If the offset fits into 8 bits
  87. the address is stored in one word (the low-order byte containing
  88. the offset, bits 8 to 14 containing the segment number and
  89. bit 15 containing a zero) otherwise the address is stored in two
  90. words (the lower word containing the offset, the upper word as
  91. before but bit 15 containing 1 indicating that the offset is in
  92. the next word).
  93. This is important for instructions which has an operand of mode DA
  94. or X.
  95. .IP "extended branches"
  96. When the target address in a relative jump/call (JR/CALR)
  97. does not fit into the instruction format, the assembler generates
  98. a corresponding `normal' jump/call (JP/CALL).
  99. .SH EXAMPLE
  100. An example of z8000 assembly code.
  101. .nf
  102. .ta 8n 16n 24n 32n 40n 48n
  103. ! This z8000 assembly routine converts a positive number
  104. !(in R1) to a string representing the number and puts this
  105. !string into a buffer (R3 contains the starting address of
  106. !this buffer. The base is in R4 determining %x, %d or %o.
  107. convert:
  108. exts RR0 !sign-extend R1
  109. div RR0, R4 !divide by the base
  110. test R1 !R1 contains the quotient
  111. jr EQ, 5f
  112. !if quotient is 0 convert is ready
  113. !else push remainder onto the stack
  114. push *RR14, R0
  115. calr convert !and again...
  116. pop R0, *RR14
  117. 5: add R0, $060 !add `0'
  118. cp R0, $071 !compare to `9'
  119. jr LE, 8f
  120. add R0, $7 !in case of %x `A'-`F'
  121. 8: ldb 0(R3), RL0 !put character into buffer
  122. inc R3
  123. ret
  124. .fi
  125. .SH "SEE ALSO"
  126. uni_ass(6).
  127. .br
  128. ack(1).
  129. .br
  130. Z8000 PLZ/ASM Assembly Language Programming Manual, april 1979.
  131. .br
  132. AmZ8001/2 Processor Instruction Set, 1979.
  133. .SH BUGS
  134. You cannot use (reg16) instead of 0(reg16).
  135. .br
  136. Condition codes \fIZ\fP (meaning zero), \fIC\fP (meaning carry) and <nothing>
  137. (meaning always false) are not implemented.
  138. The first two because they also represent flags and the third one
  139. because it's useless.
  140. So for \fIZ\fP/\fIC\fP use \fIEQ\fP/\fIULT\fP.
  141. .br
  142. The z8000 assembly instruction set as described in the book
  143. \fIAmZ8001/2 Processor Instruction Set\fP differs from the one
  144. described in the manual \fIZ8000 PLZ/ASM Assembly Language Programming
  145. Manual\fP in that the book includes CLRL, LDL (format F5.1) and
  146. PUSHL (format F5.1) which all in fact do not (!) work.
  147. .br
  148. On the other side the book excludes SIN, SIND, SINDR, SINI, SINIR,
  149. SOUT, SOUTD, SOTDR, SOUTI and SOTIR.
  150. Whether these instructions do work as described in the manual has not
  151. been tested yet.