fmt.c.l (1478B)
1 # 30sep12abu 2 # (c) Software Lab. Alexander Burger 3 4 (de newSection (Sym) 5 (setq *Section Sym) ) 6 7 (de asmDataLength () 8 (+ 9 (or (cadar *AsmData) 0) 10 (sum '((X) (if (num? X) 1 8)) 11 (cddar *AsmData)) ) ) 12 13 # Directives 14 (de label (Lbl Flg) 15 (if (== 'data *Section) 16 (push '*AsmData 17 (list Lbl (asmDataLength)) ) 18 (if (and *AsmCode (not (caar @))) 19 (conc (car *AsmCode) (cons Lbl)) 20 (push '*AsmCode (list NIL Lbl)) ) 21 (idx '*Labels (def (name Lbl) *AsmPos) T) ) ) 22 23 (asm word (X) 24 (conc (cdar *AsmData) 25 (cons (if (sym? X) X (cons X))) ) ) 26 27 (asm byte (N) 28 (conc (cdar *AsmData) (cons N)) ) 29 30 (asm bytes (Lst) 31 (conc (cdar *AsmData) (copy Lst)) ) 32 33 (asm hx2 (Lst) 34 (conc (cdar *AsmData) 35 (mapcan 36 '((S) 37 (let (N (hex S) Hi (& (>> 8 N) 255) Lo (& N 255)) 38 (if *LittleEndian 39 (list Lo Hi) 40 (list Hi Lo) ) ) ) 41 Lst ) ) ) 42 43 (de escCstr (Str) 44 (make 45 (for (L (chop Str) L) 46 (let C (pop 'L) 47 (link 48 (char 49 (ifn (= "\\" C) 50 C 51 (case (pop 'L) 52 ("t" "^I") 53 ("n" "^J") 54 ("r" "^M") 55 (T @) ) ) ) ) ) ) ) ) 56 57 (asm ascii (Str) 58 (conc (cdar *AsmData) (escCstr Str)) ) 59 60 (asm asciz (Str) 61 (conc (cdar *AsmData) (escCstr Str) (cons 0)) ) 62 63 # vi:et:ts=3:sw=3