[8080.CNV] [Harold V. McIntosh, 5 April 1984] [Assembler for Intel 8080 instruction set] [Instructions must be lower case; symbols may be upper or lower case or mixed, but must be consistent. The source file FILE.ASM will produce an unformatted hex file FILE.UFH, and an annotated list file, FILE.PRN. The program HEXEH.REC can be used to transform the unformatted hex file to a normal hex file, FILE.HEX.] [Assembler directives recognized include: org, end, equ, db, dc, dw and ds. They should only be written in lower case.] [Sums, differences, and negatives may form part of symbolic fields, but references must be complete and may not be circular. Don't use , then later, ! Undefined symbols are taken as 0000H.] [Exclude CTR DIR RST BIO] [[Intel 8080 Assembler]] [first pass] (()()(0)( (<>,); (<0>,(x,(R))): )) a (()()(1 2)( [quit at END] (end,); [quit at EOF] ((^Z),(, (%T,No END line) )); [skip comment] ((or,;,<>),(R)): [equ] (<:1:>equ<:2:>,(%W,MEM:ST,(%T,<1>:(r,<2>)::))(R)): [record labels] ((and,<:F:>:,<1>:)<2>,(%W,MEM:ST,(%T,<1>:<0>::))<2>): [left white] (<:H:><1>,<1>): [3-byte inst] (<:M:><:H:>,(#f,<0>+3)); [2-byte inst] (<:N:><:H:>,(#f,<0>+2)); [db] (db<:H:><1>,(#f,<0>+(y,<1>))); [dc] (dc<:H:><1>,(#f,<0>+(y,<1>))); [dw] (dw<:H:><1>,(#f,<0>+(z,<1>))); [ds] (ds<:2:>,(#+,<0>+(r,<2>))); [org] (org<:2:>,(r,<2>)); [1-byte inst] ((or,<:O:>,<:P:>,<:Q:>,<:U:>,<:V:>),(#f,<0>+1)); [other] (<1>,(, (%T,unknown <1>) )(#f,<0>+3)); )) x [count db] (()()(0 1)( (<'><'><'><1>,(#+,(y,<'><1>)+1)); (<'><'><:Y:><1>,<1>): (<'><0><'><1>,(#+,(&!,<0>)+(y,<'><'><1>))); ((or,<:F:>,<:E:>,<:C:>)<:Y:><1>,(#+,(y,<1>)+1)); (<>,0); (<1>,(, (%T,syntax error in db: <1>) )0); )) y [count dw] (()()(0)( ((or,<:F:>,<:E:>,<:C:>)<:Y:><0>,(#+,(z,<0>)+2)): (<>,0); (<0>,(, (%T,syntax error in dw: <0>) )0); )) z [second pass] (()()(0 4)( (<>,); (<0>,(if,(R),<4>,(u,<4>))): )) b (()()(1 2 3)( [END w/start] (end<:2:>,(if,%(&Dh,(c,<2>)),<3>,(X))); [quit at END] (end,(if,%0000,<3>,(X))); [quit at EOF] ((^Z),(, (%T,No END line) )); [skip comment] ((or,;,<>),(if, ,<3>,(X))<0>); [ignore equ] (<:1:>equ<:2:>,(if, ,<3>,(X))<0>); [discard label] (<:F:>:<2>,<2>): [left white] (<:H:><1>,<1>): [db] (db<:H:><1>,(if,(v,<1>),<3>,(X))(#f,<0>+(y,<1>))); [dc] (dc<:H:><1>,(if,(o,(v,<1>)),<3>,(X))(#f,<0>+(y,<1>))); [dw] (dw<:H:><1>,(if,(w,<1>),<3>,(X))(#f,<0>+(z,<1>))); [ds] (ds<:2:>,(if,(#+,<0>+(c,<2>)),<1>,(if,^(&Dh,<1>),<3>,(X))<1>)); [org] (org<:2:>,(if,(c,<2>),<1>,(if,^(&Dh,<1>),<3>,(X))<1>)); [lxi] (lxi<:H:><1><,><2><:Z:>,<< >>(if,(q,0+(i,<1>)+1)(s,<2>),<3>,(X))<< >>(#f,<0>+3)); [3-byte inst] ((and,<:M:>,<1>)<:H:><2><:Z:>,<< >>(if,(l,<1>)(s,<2>),<3>,(X))<< >>(#f,<0>+3)); [mvi] (mvi<:H:><1><,><2><:Z:>,<< >>(if,(q,0+(e,<1>)+6)(t,<2>),<3>,(X))<< >>(#f,<0>+2)); [2-byte inst] ((and,<:N:>,<1>)<:H:><2><:Z:>,<< >>(if,(m,<1>)(t,<2>),<3>,(X))<< >>(#f,<0>+2)); [moves] (mov<:H:><1><,><2><:Z:>,<< >>(if,(q,1+(e,<1>)+(e,<2>)),<3>,(X))<< >>(#f,<0>+1)); [arit-logic] ((and,<:P:>,<1>)<:H:><2><:Z:>,<< >>(if,(q,2+(f,<1>)+(e,<2>)),<3>,(X))<< >>(#f,<0>+1)); [1-byte w/reg] ((and,<:O:>,<1>)<:H:><2><:Z:>,<< >>(if,(n,<1>),<3>,(X))<< >>(#f,<0>+1)); [cndl ret] (r(and,<:L:>,<1>)<:H:>,<< >>(if,(q,3+(h,<1>)+0),<3>,(X))<< >>(#f,<0>+1)); [accumulator] ((and,<:U:>,<1>)<:H:>,<< >>(if,(q,0+(j,<1>)+7),<3>,(X))<< >>(#f,<0>+1)); [1-byte inst] ((and,<:Q:>,<1>)<:H:>,<< >>(if,(k,<1>),<3>,(X))<< >>(#f,<0>+1)); [other] (<1>,<< >>(if,000000,<3>,(X))<< >>(, (%T,unknown <1>) )<< >>(#f,<0>+3)); )) u [compile db] (()()(1 2)( (<'><'><'><1>,(&n,<'>)(v,<'><1>)); (<'><'><:Y:><1>,<1>): (<'><1><'><2>,(&n,<1>)(v,<'><'><2>)); ((and,(or,<:F:>,<:E:>,<:C:>),<1>)<:Y:><2>,(t,<1>)(v,<2>)); (<>,); (<1>,(, (%T,syntax error in db: <1>) )); )) v [compile dw] (()()(1 2)(((and,(or,<:F:>,<:E:>,<:C:>),<1>)<:Y:><2>,(s,<1>)(w,<2>));(,);)) w [get symbol value] (()()(0 1 2)( ((and,(or,<:E:>,<:C:>)<>,<0>),(r,<0>)); ((and,<:F:>,<0>)<1>,(T)(d,(S))<1>): (<1>+(and,<:F:>,<0>)<2>,<1>+(T)(d,(S))<2>): (<1>-(and,<:F:>,<0>)<2>,<1>-(T)(d,(S))<2>): (<0>,(#f,<0>)); )) c [search symbol table] (()()(1)(((^Z),(, (%T,Undefined <0>) )0);(<0>:<1>::,<1>);(,(S)):)) d [register equivalents] (()()()((b,0);(c,1);(d,2);(e,3);(h,4);(l,5);(m,6);(a,7);)) e [arith-logic equivalents] (()()()((add,0);(adc,1);(sub,2);(sbb,3);(ana,4);(xra,5);(ora,6);(cmp,7);)) f [immediate equivalents] (()()()((adi,0);(aci,1);(sui,2);(sbi,3);(ani,4);(xri,5);(ori,6);(cpi,7);)) g [condition equivalents] (()()()((nz,0);(z,1);(nc,2);(c,3);(po,4);(pe,5);(p,6);(m,7);)) h [register pair equivalents] (()()()((b,0);(d,2);(h,4);(sp,6);(psw,6);)) i [accumulator instructions] (()()()((rlc,0);(rrc,1);(ral,2);(rar,3);(daa,4);(cma,5);(stc,6);(cmc,7);)) j [sporadic instructions] (()()()((ret,C9);(xchg,EB);(xthl,E3);(pchl,E9); (sphl,F9);(di,F3);(ei,FB);(nop,00);(hlt,76);)) k [three-byte instructions except lxi] (()()(0)((jmp,C3);(call,CD);(shld,22);(lhld,2A);(sta,32);(lda,3A); (j(and,<:L:>,<0>),(q,3+(h,<0>)+2)); (c(and,<:L:>,<0>),(q,3+(h,<0>)+4));)) l [two-byte instructions exceqt mvi] (()()(0)((in,DB);(out,D3);(<0>,(q,3+(g,<0>)+6));)) m [one-byte instructions with register] (()()()((dad,(q,0+(i,<2>)+9)); (ldax,(q,0+(i,<2>)+10)); (stax,(q,0+(i,<2>)+2)); (inx,(q,0+(i,<2>)+3)); (dcx,(q,0+(i,<2>)+11)); (inr,(q,0+(e,<2>)+4)); (dcr,(q,0+(e,<2>)+5)); (pop,(q,3+(i,<2>)+1)); (push,(q,3+(i,<2>)+5)); (rst,(q,3+<2>+7));)) n [mark last byte] (()()(0 1)((<0>(and,<[1]>,<1>)<>,<0>(&s,<1>));)) o [.PRN file] (()()(1 2)( ((^I)(and,<[8]>,<1>)<2>,(%W,(W),(%T, <1>(^MJ)))(^I)<2>): ((and,<[8]>,<1>)<2>,(%W,(W),(%T, (&Dh,<0>) <1>(^I)<4>(^MJ)))(^I)<2>): ((^I)<1>,(%W,(W),(%T, <1>)(^MJ))); (<1>,(%W,(W),(%T, (&Dh,<0>) <1>(^I)<4>)(^MJ))); )) p [join code fields] (()()(0 1 2 3)( (<0>+<1>+<2>,(if,(&Dh,(#f,<0>*64+<1>*8+<2>)),00<3>,<3>)); )) q [uniformly decimal] (()()(0)( (<0>H,(&Hd,<0>)); )) r [addr fld] (()()(0 1 2)((<0>,(if,(&Dh,(c,<0>)),(and,<[2]>,<1>)<2>,<2><1>));)) s [one byte symbol] (()()(0 1)( (<'><'><'><'>,(&h,<'>)); (<'>(and,<[1]>,<0>)<'>,(&h,<0>)); ((and,(or,<:E:>,<:C:>),<0>),(if,(&Dh,(r,<0>)),00<1>,<1>)); ((and,<:F:>,<0>),(T)(d,(S))): (<0>,(, (%T,bad byte <0>) )00); )) t [main program] (( [alfa] ((and,<[1]>,(or,(IVL,A,Z,),(IVL,a,z,),$,.))) A [num] ((and,<[1]>,(IVL,0,9,))) B [numeral] (<:B:>(ITR,<:B:>)) C [hex] ((and,<[1]>,(or,(IVL,0,9,),(IVL,A,F,),(IVL,a,f,)))) D [hexmal] (<:B:>(ITR,<:D:>)H) E [alfanum] (<:A:>(ITR,(or,<:A:>,<:B:>))) F [white] ((or, ,(^I))) G [whitespace] ((or,<:G:>(ITR,<:G:>),;<-->,<>)) H [registers] ((or,b,c,d,e,h,l,m,a)) I [pairs] ((or,b,d,h,sp)) J [pairs] ((or,b,d,h,psw)) K [condition] ((or,nz,z,nc,c,po,pe,p,m)) L [3-byte] ((or,lhld,shld,lxi,lda,sta,jmp,call,j<:L:>,c<:L:>)) M [2-byte] ((or,mvi,adi,aci,sui,sbi,ani,xri,ori,cpi,in,out)) N [1-byte] ((or,dad,ldax,stax,inx,dcx,inr,dcr,pop,push,rst)) O [ar-logic] ((or,add,adc,sub,sbb,ana,xra,ora,cmp)) P [sporadic] ((or,ret,xchg,xthl,pchl,sphl,di,ei,nop,hlt)) Q [accumulator] ((or,rlc,rrc,ral,rar,daa,cma,stc,cmc)) U [1-byte] ((or,mov,r<:L:>)) V [separator] ((or,<,>,(ITR,<:G:>)(or,;<-->,<>))) Y [final] ((ITR,<:G:>)(or,;,<>)) Z [label] ((and,<:F:>,<1>)(or,:,<:G:>)(ITR,<:G:>)) 1 [constant] (<:H:>(and,(or,<:E:>,<:C:>),<2>)) 2 )( ((%R,<9>.ASM)) R ((%R,MEM:ST,<-->::)) S ((,(%Or,MEM:ST))) T (<9>.PRN) W ((%W,<9>.UFH,<3>)(p,<3>)) X )(9)( ((PWS)(or),); (<9>(or, ,.,<>),<< >>(%Ow,MEM:ST)<< >>(%Or,<9>.ASM)<< >>(a,0)<< >>(, (%T,First Pass concluded) )<< >>(%C,<9>.ASM)<< >>(%Or,<9>.ASM)<< >>(%Ow,<9>.PRN)<< >>(%Ow,<9>.UFH)<< >>(%Or,MEM:ST)<< >>(b,0)<< >>(, (%T,Second Pass concluded) )<< >>(%E)); )) [end]