From 749fdf1b18cff025b0f1aa347bd76525983a2853 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Fri, 12 Jun 2020 11:29:00 -0400 Subject: [PATCH] 8086asm: add 8-bit JMP, MOVrI, INT, Verified against nasm with equivalent code. --- blk/731 | 9 ++++++++- blk/750 | 2 +- blk/751 | 1 + blk/753 | 5 +++++ blk/754 | 17 +++++++++++++++++ blk/755 | 9 +++++++++ 6 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 blk/754 create mode 100644 blk/755 diff --git a/blk/731 b/blk/731 index ae1b9e7..118cab3 100644 --- a/blk/731 +++ b/blk/731 @@ -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 diff --git a/blk/750 b/blk/750 index 2a492bf..a127da9 100644 --- a/blk/750 +++ b/blk/750 @@ -1 +1 @@ -1 3 LOADR+ +1 5 LOADR+ diff --git a/blk/751 b/blk/751 index 398e07d..a2abf5e 100644 --- a/blk/751 +++ b/blk/751 @@ -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 ; diff --git a/blk/753 b/blk/753 index d13ca69..4890729 100644 --- a/blk/753 +++ b/blk/753 @@ -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, ; diff --git a/blk/754 b/blk/754 new file mode 100644 index 0000000..f3b5237 --- /dev/null +++ b/blk/754 @@ -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! ; + diff --git a/blk/755 b/blk/755 new file mode 100644 index 0000000..64c47ed --- /dev/null +++ b/blk/755 @@ -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, ; ) +