picolisp

Unnamed repository; edit this file to name it for gitweb.
git clone https://logand.com/git/picolisp.git/
Log | Files | Refs | README | LICENSE

asm (8469B)


      1 # 05jan13abu
      2 # (c) Software Lab. Alexander Burger
      3 
      4 
      5    CPU Registers:
      6 
      7       +---+---+---+---+---+---+---+---+
      8       |               A           | B |  \      [A]ccumulator
      9       +---+---+---+---+---+---+---+---+   D     [B]yte register
     10       |               C               |  /      [C]ount register
     11       +---+---+---+---+---+---+---+---+         [D]ouble register
     12       |               E               |         [E]xpression register
     13       +---+---+---+---+---+---+---+---+
     14 
     15 
     16       +---+---+---+---+---+---+---+---+
     17       |               X               |         [X] Index register
     18       +---+---+---+---+---+---+---+---+         [Y] Index register
     19       |               Y               |         [Z] Index register
     20       +---+---+---+---+---+---+---+---+
     21       |               Z               |
     22       +---+---+---+---+---+---+---+---+
     23 
     24 
     25       +---+---+---+---+---+---+---+---+
     26       |               L               |         [L]ink register
     27       +---+---+---+---+---+---+---+---+         [S]tack pointer
     28       |               S               |
     29       +---+---+---+---+---+---+---+---+
     30 
     31 
     32       +-------------------------------+
     33       |  [z]ero    [s]ign    [c]arry  |         [F]lags
     34       +-------------------------------+
     35 
     36 ========================================================================
     37 
     38    Source Addressing Modes:
     39       ld A 1234            # Immediate
     40       ld A "(a+b-c)"
     41       ld A R               # Register
     42       ld A Global          # Direct
     43       ld A (R)             # Indexed
     44       ld A (R 8)           # Indexed with offset
     45       ld A (R OFFS)
     46       ld A (R Global)
     47       ld A (Global)        # Indirect
     48       ld A (Global OFFS)   # Indirect with offset
     49       ld A ((R))           # Indexed indirect
     50       ld A ((R 8))         # Indexed with offset indirect
     51       ld A ((R 8) OFFS)
     52       ld A ((R Global) OFFS)
     53       ld A ((R OFFS) Global)
     54       ...
     55 
     56    Destination Addressing Modes:
     57       ld R A               # Register
     58       ld (R) A             # Indexed
     59       ld (R 8) A           # Indexed with offset
     60       ld (R OFFS) A
     61       ld (R Global) A
     62       ld (Global) A        # Indirect
     63       ld (Global OFFS) A   # Indirect with offset
     64       ld ((R)) A           # Indexed indirect
     65       ld ((R 8)) A         # Indexed with offset indirect
     66       ld ((R 8) OFFS) A
     67       ld ((R Global) OFFS) A
     68       ld ((R OFFS) Global) A
     69       ...
     70 
     71    Target Addressing Modes:
     72       jmp 1234             # Absolute
     73       jmp Label
     74       jmp (R)              # Indexed
     75       jmp (R T)            # Indexed SUBR
     76       jmp (Global)         # Indirect
     77 
     78 ========================================================================
     79 
     80    Instruction set:
     81       nop               # No operation
     82 
     83    Move Instructions:
     84       ld dst src        # Load 'dst' from 'src' [---]
     85       ld2 src           # Load 'A' from two bytes 'src' (unsigned) [---]
     86       ld4 src           # Load 'A' from four bytes 'src' (unsigned) [---]
     87       ldc reg src       # Load if Carry 'reg' from 'src' [---]
     88       ldnc reg src      # Load if not Carry 'reg' from 'src' [---]
     89       ldz reg src       # Load if Zero 'reg' from 'src' [---]
     90       ldnz reg src      # Load if not Zero 'reg' from 'src' [---]
     91       lea dst src       # Load 'dst' with effective address of 'src' [---]
     92       st2 dst           # Store two bytes from 'A' into 'dst' [---]
     93       st4 dst           # Store four bytes from 'A' into 'dst' [---]
     94       xchg dst dst      # Exchange 'dst's [---]
     95       movn dst src cnt  # Move 'cnt' bytes from 'src' to 'dst' (non-overlapping)
     96       mset dst cnt      # Set 'cnt' bytes of memory to B
     97       movm dst src end  # Move memory 'src'..'end' to 'dst' (aligned)
     98       save src end dst  # Save 'src'..'end' to 'dst' (aligned, non-overlapping)
     99       load dst end src  # Load 'dst'..'end' from 'src' (aligned, non-overlapping)
    100 
    101    Arithmetics:
    102       add dst src       # Add 'src' to 'dst' [zsc]
    103       addc dst src      # Add 'src' to 'dst' with Carry [zsc]
    104       sub dst src       # Subtract 'src' from 'dst' [zsc]
    105       subc dst src      # Subtract 'src' from 'dst' with Carry [zsc]
    106 
    107       inc dst           # Increment 'dst' [zs.]
    108       dec dst           # Increment 'dst' [zs.]
    109       not dst           # One's complement negation of 'dst' [z..]
    110       neg dst           # Two's complement negation of 'dst' [zs.]
    111 
    112       and dst src       # Bitwise AND 'dst' with 'src' [zs.]
    113       or dst src        # Bitwise OR 'dst' with 'src' [zs.]
    114       xor dst src       # Bitwise XOR 'dst' with 'src' [zs.]
    115       off dst src       # Clear 'src' bits in 'dst' [zs.]
    116       test dst src      # Bit-test 'dst' with 'src' [zs.]
    117 
    118       shl dst src       # Shift 'dst' left into Carry by 'src' bits [zsc]
    119       shr dst src       # Shift 'dst' right into Carry by 'src' bits [zsc]
    120       rol dst src       # Rotate 'dst' left by 'src' bits [...]
    121       ror dst src       # Rotate 'dst' right by 'src' bits [...]
    122       rcl dst src       # Rotate 'dst' with Carry left by 'src' bits [zsc]
    123       rcr dst src       # Rotate 'dst' with Carry right by 'src' bits [zsc]
    124 
    125       mul src           # Multiplication of 'A' and 'src' into 'D' [...]
    126       div src           # Division of 'D' by 'src' into 'A', 'C' [...]
    127 
    128       zxt               # Zero-extend 'B' to 'A' [...]
    129 
    130       setz              # Set Zero flag [z__]
    131       clrz              # Clear Zero flag [z..]
    132       setc              # Set Carry flag [--c]
    133       clrc              # Clear Carry flag [--c]
    134 
    135    Comparisons:
    136       cmp dst src       # Compare 'dst' with 'src' [zsc]
    137       cmpn dst src cnt  # Compare 'cnt' bytes 'dst' with 'src' [z..]
    138       slen dst src      # Set 'dst' to the string length of 'src' [...]
    139       memb src cnt      # Find B in 'cnt' bytes of 'src' memory [z..]
    140       null src          # Compare 'src' with 0 [zs_]
    141       nulp src          # Check 'src' for null-pointer [z..]
    142       nul4              # Compare four bytes in 'A' with 0 [zs_]
    143 
    144    Byte addressing:
    145       set dst src       # Set 'dst' byte to 'src' [---]
    146       nul src           # Compare byte 'src' with 0 [zs_]
    147 
    148    Types:
    149       cnt src           # Non-'z' if small number [z..]
    150       big src           # Non-'z' if bignum [z..]
    151       num src           # Non-'z' if number [z..]
    152       sym src           # Non-'z' if symbol [z..]
    153       atom src          # Non-'z' if atom [z..]
    154 
    155    Flow Control:
    156       jmp adr           # Jump to 'adr' [---]
    157       jz adr            # Jump to 'adr' if Zero [---]
    158       jnz adr           # Jump to 'adr' if not Zero [---]
    159       js adr            # Jump to 'adr' if Sign [---]
    160       jns adr           # Jump to 'adr' if not Sign [---]
    161       jc adr            # Jump to 'adr' if Carry [---]
    162       jnc adr           # Jump to 'adr' if not Carry [---]
    163 
    164       call adr          # Call 'adr'
    165       cc adr(src ..)    # C-Call to 'adr' with 'src' arguments
    166       cc adr reg        # C-Call to 'adr' with top of stacked args in 'reg'
    167       ldd               # Load double value pointed to by 'C'
    168       ldf               # Load float value pointed to by 'C'
    169       fixnum            # Convert double with scale 'E' to fixnum in 'E'
    170       float             # Convert fixnum with scale 'A' pointed to by 'X'
    171       std               # Store double value at address 'Z'
    172       stf               # Store float value at address 'Z'
    173 
    174       ret               # Return [---]
    175       func              # Convert 'E' to function pointer
    176       begin             # Called from foreign function
    177       return            # Return to foreign function
    178 
    179    Stack Manipulations:
    180       push src          # Push 'src' [---]
    181       pop dst           # Pop 'dst' [---]
    182       link              # Setup frame [---]
    183       tuck src          # Extend frame [---]
    184       drop              # Drop frame [---]
    185 
    186    Evaluation:
    187       eval              # Evaluate expression in 'E'
    188       eval+             # Evaluate expression in partial stack frame
    189       eval/ret          # Evaluate expression and return
    190       exec reg          # Execute lists in 'reg', ignore results
    191       prog reg          # Evaluate expressions in 'reg', return last result
    192 
    193    System:
    194       initData          # Init runtime data
    195       initCode          # Init runtime code
    196       initMain          # Command in X, arguments in Y, last pointer in Z
    197       initLib           # Library function pointer in A
    198 
    199 ========================================================================
    200 
    201    Naming conventions:
    202 
    203    Lisp level functions, which would be all of the form 'doXyzE_E', are written
    204    as 'doXyz' for brevity.