1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-12-25 16:58:05 +11:00

8086asm: add 8-bit JMP, MOVrI, INT,

Verified against nasm with equivalent code.
This commit is contained in:
Virgil Dupras 2020-06-12 11:29:00 -04:00
parent 405444d630
commit 749fdf1b18
6 changed files with 41 additions and 2 deletions

View File

@ -1,2 +1,9 @@
H@ ORG !
JMP8, L1 FWR8 ( start )
L2 BSET ( msg )
," Hello, World!" 0 A,
L1 FSET ( start )
AH 0x42 MOVri,
8 H@ 2 - DUMP
0x10 INT,
SI L2 @ ( msg ) MOVrI,
PC ORG @ DUMP

View File

@ -1 +1 @@
1 3 LOADR+
1 5 LOADR+

View File

@ -1,4 +1,5 @@
VARIABLE ORG
VARIABLE L1 VARIABLE L2 VARIABLE L3 VARIABLE L4
: AL 0 ; : CL 1 ; : DL 2 ; : BL 3 ;
: AH 4 ; : CH 5 ; : DH 6 ; : BH 7 ;
: AX 8 ; : CX 9 ; : DX 10 ; : BX 11 ;

View File

@ -1 +1,6 @@
: MOVri, SWAP 0xb0 OR A, A, ;
: MOVrI, SWAP 0xb0 OR A, 256 /MOD A, A, ;
: INT, 0xcd A, A, ;
( no argument, flow ops are special )
: JMP8, 0xeb A, ;
: JMP16, 0xe9 A, ;

17
blk/754 Normal file
View File

@ -0,0 +1,17 @@
( Place BEGIN, where you want to jump back and AGAIN after
a relative jump operator. Just like BSET and BWR. )
: BEGIN, PC ;
: BSET PC SWAP ! ;
( same as BSET, but we need to write a placeholder )
( : FJR, PC 0 A, ;
: IFZ, JRNZ, FJR, ;
: IFNZ, JRZ, FJR, ;
: IFC, JRNC, FJR, ;
: IFNC, JRC, FJR, ; )
: THEN,
DUP PC ( l l pc )
-^ ( l off )
( warning: l is a PC offset, not a mem addr! )
SWAP ORG @ + ( BIN( @ - ) ( off addr )
C! ;

9
blk/755 Normal file
View File

@ -0,0 +1,9 @@
: FWR8 BSET 0 A, ;
: FSET @ THEN, ;
( : BREAK, FJR, 0x8000 OR ;
: BREAK?, DUP 0x8000 AND IF
0x7fff AND 1 ALLOT THEN, -1 ALLOT
THEN ;
: AGAIN, BREAK?, PC - 1- A, ; )
( : BWR @ AGAIN, ; )