The assembler, "qas" - retrotruestory/M1DEV GitHub Wiki

6/03/2003 by Bill Buzbee

The assembler, "qas", is now functional at roughly the same level as it was for my previous revision of Magic-1. It's quite a hack, but works. At the moment, it's a one-pass assembler with backpatching to fix up forward references. Also, it's absolute. The listing is generated in the first pass, so forward references show up as "--" in the listing, but the patched values are displayed in the "fixup" section. Here's the listing from assembling the fibonacci generator:

     :          |     ; Fibonacci test program
     :          |     ; fib(10) => 0x59 (89) in A
     :          | 
     :          | _start:
0000 : 7c 4444  |     ld.16 a,0x4444
0003 : cb       |     ld sp,a
     :          | 
     :          | main:
     :          | 
0004 : e5 fd    |     enter 2
0006 : 7a 0a    |     ld.16 a,10
0008 : d9 04    |     st.16 4(sp),a
000a : 83 ----  |     call fib 
000d : 19 02    |     ld.16 a,2(sp)
000f : d9 06    |     st.16 6(sp),a
0011 : 0d       |     pop sp
0012 : 00       |     halt
     :          | 
     :          | fib:
     :          |     ;
0013 : e5 fc    |     enter 3
0015 : 19 10    |     ld.16 a,16(sp)
0017 : ad 02 -- |     cmpb.lt.16 a,2,done 
001a : 2d 01    |     sub.16 a,1
001c : d9 04    |     st.16 4(sp),a
001e : 83 fff2  |     call fib 
0021 : 19 02    |     ld.16 a,2(sp)
0023 : d9 06    |     st.16 6(sp),a
0025 : 19 10    |     ld.16 a,16(sp)
0027 : 2d 02    |     sub.16 a,2
0029 : d9 04    |     st.16 4(sp),a
002b : 83 ffe5  |     call fib 
002e : 19 02    |     ld.16 a,2(sp)
0030 : d9 08    |     st.16 8(sp),a
0032 : 19 06    |     ld.16 a,6(sp)
0034 : 39 08    |     add.16 a,8(sp)
0036 : 81 --    |     sbr exit
     :          | done:
0038 : 7a 01    |     ld.16 a,1
     :          | exit:
003a : d9 0e    |     st.16 14(sp),a
003c : 0d       |     pop sp
003d : 0b       |    pop pc
     :          | 
=========================== Fixups =================================
Fixup applied, 1-byte store of 0x0002 to 0x0037
Fixup applied, 1-byte store of 0x001e to 0x0019
Fixup applied, 2-byte store of 0x0006 to 0x000b
=========================== Symbols =================================
exit     -> 0x003a
done     -> 0x0038
fib      -> 0x0013
main     -> 0x0004
_start   -> 0x0000

See also: fibonacci program.

⚠️ **GitHub.com Fallback** ⚠️