File: asm

package info (click to toggle)
picolisp 3.1.0.7-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 4,100 kB
  • sloc: ansic: 14,205; lisp: 795; makefile: 290; sh: 13
file content (202 lines) | stat: -rw-r--r-- 8,007 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# 30apr12abu
# (c) Software Lab. Alexander Burger


   CPU Registers:

      +---+---+---+---+---+---+---+---+
      |               A           | B |  \      [A]ccumulator
      +---+---+---+---+---+---+---+---+   D     [B]yte register
      |               C               |  /      [C]ount register
      +---+---+---+---+---+---+---+---+         [D]ouble register
      |               E               |         [E]xpression register
      +---+---+---+---+---+---+---+---+


      +---+---+---+---+---+---+---+---+
      |               X               |         [X] Index register
      +---+---+---+---+---+---+---+---+         [Y] Index register
      |               Y               |         [Z] Index register
      +---+---+---+---+---+---+---+---+
      |               Z               |
      +---+---+---+---+---+---+---+---+


      +---+---+---+---+---+---+---+---+
      |               L               |         [L]ink register
      +---+---+---+---+---+---+---+---+         [S]tack pointer
      |               S               |
      +---+---+---+---+---+---+---+---+


      +-------------------------------+
      |  [z]ero    [s]ign    [c]arry  |         [F]lags
      +-------------------------------+

========================================================================

   Source Addressing Modes:
      ld A 1234            # Immediate
      ld A "(a+b-c)"
      ld A R               # Register
      ld A Global          # Direct
      ld A (R)             # Indexed
      ld A (R 8)           # Indexed with offset
      ld A (R OFFS)
      ld A (R Global)
      ld A (Global)        # Indirect
      ld A (Global OFFS)   # Indirect with offset
      ld A ((R))           # Indexed indirect
      ld A ((R 8))         # Indexed with offset indirect
      ld A ((R 8) OFFS)
      ld A ((R Global) OFFS)
      ld A ((R OFFS) Global)
      ...

   Destination Addressing Modes:
      ld R A               # Register
      ld (R) A             # Indexed
      ld (R 8) A           # Indexed with offset
      ld (R OFFS) A
      ld (R Global) A
      ld (Global) A        # Indirect
      ld (Global OFFS) A   # Indirect with offset
      ld ((R)) A           # Indexed indirect
      ld ((R 8)) A         # Indexed with offset indirect
      ld ((R 8) OFFS) A
      ld ((R Global) OFFS) A
      ld ((R OFFS) Global) A
      ...

   Target Addressing Modes:
      jmp 1234             # Absolute
      jmp Label
      jmp (R)              # Indexed
      jmp (R T)            # Indexed SUBR
      jmp (Global)         # Indirect

========================================================================

   Instruction set:
      nop               # No operation

   Move Instructions:
      ld dst src        # Load 'dst' from 'src' [---]
      ld2 src           # Load 'A' from two bytes 'src' (unsigned)
      ld4 src           # Load 'A' from four bytes 'src' (unsigned)
      ldc reg src       # Load if Carry 'reg' from 'src'
      ldnc reg src      # Load if not Carry 'reg' from 'src'
      ldz reg src       # Load if Zero 'reg' from 'src'
      ldnz reg src      # Load if not Zero 'reg' from 'src'
      lea dst src       # Load 'dst' with effective address of 'src' [---]
      st2 dst           # Store two bytes from 'A' into 'dst'
      st4 dst           # Store four bytes from 'A' into 'dst'
      xchg dst dst      # Exchange 'dst's
      movn dst src cnt  # Move 'cnt' bytes from 'src' to 'dst' (non-overlapping)
      mset dst cnt      # Set 'cnt' bytes of memory to B
      movm dst src end  # Move memory 'src'..'end' to 'dst' (aligned)
      save src end dst  # Save 'src'..'end' to 'dst' (non-overlapping)
      load dst end src  # Load 'dst'..'end' from 'src' (non-overlapping)

   Arithmetics:
      add dst src       # Add 'src' to 'dst' [zsc]
      addc dst src      # Add 'src' to 'dst' with Carry [zsc]
      sub dst src       # Subtract 'src' from 'dst' [zsc]
      subc dst src      # Subtract 'src' from 'dst' with Carry [zsc]

      inc dst           # Increment 'dst' [zs.]
      dec dst           # Increment 'dst' [zs.]
      not dst           # One's complement negation of 'dst'
      neg dst           # Two's complement negation of 'dst'

      and dst src       # Bitwise AND 'dst' with 'src'
      or dst src        # Bitwise OR 'dst' with 'src'
      xor dst src       # Bitwise XOR 'dst' with 'src'
      off dst src       # Clear 'src' bits in 'dst'
      test dst src      # Bit-test 'dst' with 'src' [z._]

      shl dst src       # Shift 'dst' left into Carry by 'src' bits
      shr dst src       # Shift 'dst' right into Carry by 'src' bits
      rol dst src       # Rotate 'dst' left by 'src' bits
      ror dst src       # Rotate 'dst' right by 'src' bits
      rcl dst src       # Rotate 'dst' with Carry left by 'src' bits
      rcr dst src       # Rotate 'dst' with Carry right by 'src' bits

      mul src           # Multiplication of 'A' and 'src' into 'D' [...]
      div src           # Division of 'D' by 'src' into 'A', 'C' [...]

      zxt               # Zero-extend 'B' to 'A'

      setz              # Set Zero flag [z__]
      clrz              # Clear Zero flag [z..]
      setc              # Set Carry flag [--c]
      clrc              # Clear Carry flag [--c]

   Comparisons:
      cmp dst src       # Compare 'dst' with 'src' [z.c]
      cmp4 src          # Compare four bytes in 'A' with 'src'
      cmpn dst src cnt  # Compare 'cnt' bytes 'dst' with 'src'
      slen dst src      # Set 'dst' to the string length of 'src'
      memb src cnt      # Find B in 'cnt' bytes of memory [z..]
      null src          # Compare 'src' with 0 [zs_]
      nul4              # Compare four bytes in 'A' with 0 [zs_]

   Byte addressing:
      set dst src       # Set 'dst' byte to 'src'
      nul src           # Compare byte 'src' with 0 [zs_]

   Types:
      cnt src           # Non-'z' if small number
      big src           # Non-'z' if bignum
      num src           # Non-'z' if number
      sym src           # Non-'z' if symbol
      atom src          # Non-'z' if atom

   Flow Control:
      jmp adr           # Jump to 'adr'
      jz adr            # Jump to 'adr' if Zero
      jnz adr           # Jump to 'adr' if not Zero
      js adr            # Jump to 'adr' if Sign
      jns adr           # Jump to 'adr' if not Sign
      jc adr            # Jump to 'adr' if Carry
      jnc adr           # Jump to 'adr' if not Carry

      call adr          # Call 'adr'
      cc adr(src ..)    # C-Call to 'adr' with 'src' arguments
      cc adr reg        # C-Call to 'adr' with top of stacked args in 'reg'
      ldd               # Load double value pointed to by 'C'
      ldf               # Load float value pointed to by 'C'
      fixnum            # Convert double with scale 'E' to fixnum in 'E'
      float             # Convert fixnum with scale 'A' pointed to by 'X'
      std               # Store double value at address 'Z'
      stf               # Store float value at address 'Z'

      ret               # Return
      begin             # Called from foreign function
      return            # Return to foreign function

   Stack Manipulations:
      push src          # Push 'src' [---]
      pop dst           # Pop 'dst' [---]
      link              # Setup frame
      tuck src          # Extend frame
      drop              # Drop frame [---]

   Evaluation:
      eval              # Evaluate expression in 'E'
      eval+             # Evaluate expression in partial stack frame
      eval/ret          # Evaluate expression and return
      exec reg          # Execute lists in 'reg', ignore results
      prog reg          # Evaluate expressions in 'reg', return last result

   System:
      initData          # Init runtime system
      initCode
      initMain

========================================================================

   Naming conventions:

   Lisp level functions, which would be all of the form 'doXyzE_E', are written
   as 'doXyz' for brevity.