VolksForth/8086/msdos/f83asm.fb

1 line
34 KiB
Plaintext
Raw Normal View History

2017-04-23 22:25:49 +00:00
\ 8086 Assembler cas 10nov05 The 8086 Assembler was written by Mike Perry. To create and assembler language definition, use the defining word CODE. It must be terminated with either END-CODE or its synonym C;. How the assembler operates is a very interesting example of the power of CREATE DOES> Basically the instructions are categorized and a defining word is created for each category. When the nmemonic for the instruction is interpreted, it compiles itself. Adapted for volksFORTH by Klaus Schleisiek No really tested, but CODE TEST TOS PUSH 1 # TOS MOV NEXT END-CODE works! \ 8086 Assembler ks cas 10nov05Onlyforth Vocabulary Assembler : octal 8 Base ! ; decimal 1 14 +THRU clear Onlyforth : Code Create [ Assembler ] here dup 2- ! Assembler ; CR .( 8086 Assembler loaded ) Onlyforth \ 8086 Assembler ks 19 m<>r 88 : LABEL CREATE ASSEMBLER ; \ 232 CONSTANT DOES-OP \ 3 CONSTANT DOES-SIZE \ : DOES? ( IP -- IP' F ) \ DUP DOES-SIZE + SWAP C@ DOES-OP = ; ASSEMBLER ALSO DEFINITIONS : C; ( -- ) END-CODE ; OCTAL DEFER C, FORTH ' C, ASSEMBLER IS C, DEFER , FORTH ' , ASSEMBLER IS , DEFER HERE FORTH ' HERE ASSEMBLER IS HERE DEFER ?>MARK DEFER ?>RESOLVE DEFER ?<MARK DEFER ?<RESOLVE \ 8086 Assembler Register Definitions ks 19 m<>r 88 | : REG 11 * SWAP 1000 * OR CONSTANT ; | : REGS ( MODE N -- ) SWAP 0 DO DUP I REG LOOP DROP ; 10 0 REGS AL CL DL BL AH CH DH BH 10 1 REGS AX CX DX BX SP BP SI DI 10 2 REGS [BX+SI] [BX+DI] [BP+SI] [BP+DI] [SI] [DI] [BP] [BX] 4 2 REGS [SI+BX] [DI+BX] [SI+BP] [DI+BP] 4 3 REGS ES CS SS DS 3 4 REGS # #) S#) BP Constant UP [BP] Constant [UP] \ User Pointer SI CONSTANT IP [SI] CONSTANT [IP] ( INTERPRETER POINTER ) DI Constant W [DI] Constant [W] \ WORKING REGISTER BX Constant RP [BX] Constant [RP] \ Return Stack Pointer DX Constant TOS \ Top Of Stack im Registe