rr
Berlin, Germany, 26.12.2020, 01:01 |
(My) fork of 8086 Assembler for DOS (Announce) |
Hi!
Because we don't have enough "toolchains" available already, I found another one to create DOS software.
Its very creative name is "8086 Assembler for DOS". It was written by Stephen Duffy in 2001. He first released the source code on SF.net in January 2017. Now I kindly asked him to clarify the license and as he does no longer have access to this SF.net account, he released the assembler on GitHub.com again and put it under GNU GPL v2.
Although this is a self-hosting assembler, it still lacks features and has bugs. I started squashing at https://github.com/bttrx/8086-assembler and also wrote a small Readme.
I know, there are many other assemblers available, many with nice documentation and well-commented source code, but I see this as a chance to me to recap my knowledge about assembly language programming, learn a little about "compiler" design and using GitHub. I also wish to keep the assembler that small. So, don't ask for Pentium instructions support.
Feel free to try it!
Cheers,
Robert --- Forum admin |
DosWorld
26.12.2020, 16:01 (edited by DosWorld, 26.12.2020, 16:34)
@ rr
|
(My) fork of 8086 Assembler for DOS |
> Its very creative name is "8086 Assembler for DOS". It was written by
> Stephen Duffy in 2001. He first released the source code
IMHO, all of assemblers have one big problem ("big problem" - this is from my point of view) - they does not generate obj/omf. What about obj in this assembler? Second "problem" - they all limited to .com file.
PS: I am make fork - msa2, add missed opcodes, made code "compilable" by modern GCC (you can use msa2 in linux/windows) and made code-refactoring, but stop at obj generatation. This is a reason, why i don't anonce msa2. FIXUP record explode my already-damaged-brain :( (Hope, with time, i am win this challenge and complete this work) --- Make DOS great again!
Make Russia small again! |
rr
Berlin, Germany, 26.12.2020, 16:31
@ DosWorld
|
(My) fork of 8086 Assembler for DOS |
> > Its very creative name is "8086 Assembler for DOS". It was written by
> > Stephen Duffy in 2001. He first released the source code
>
> IMHO, all of assemblers have one big problem ("big problem" - this is from
> my point of view) - they does not generate obj/omf. What about obj in this
> assembler? Second "problem" - they all limited to .com file.
https://github.com/bttrx/8086-assembler#limitations clearly says "No support for .EXE or .OBJ files."
> PS: I am make fork - msa2, add missed opcodes, made code "compilable" by
> modern GCC (you can use msa2 in linux/windows) and made code-refactoring,
> but stop at obj generatation. This is a reason, why i don't anonce msa2.
> FIXUP record explode my already-damaged-brain :( (Hope, with time, i am win
> this challenge and complete this work)
That might be the reason, why other "hobby" assemblers also do not support .OBJ files. --- Forum admin |
Japheth
Germany (South), 26.12.2020, 17:18
@ rr
|
(My) fork of 8086 Assembler for DOS |
> but I see this as a chance to
> me to recap my knowledge about assembly language programming, learn a
> little about "compiler" design
Good.
> So, don't ask for Pentium instructions support.
So are we just allowed to report bugs?
> Feel free to try it!
I couldn't resist to try a potential wasm/jwasm/uasm/asmc competitor:
missing features (so far):
- no ORG directive (so no device driver development possible?)
- SEGMENTs missing ( apparently ASM.COM is a "flat"-only assembler )
- no support for listings
- EQU exists, but no math possible ( "xxx EQU 1+1" is rejected )
- no END directive (important, since it allows "self-compiling" .BAT files)
bugs:
- LDS opcode rejects any type of operands that I was able to imagine
- math accepted for direct operands, but ignored ("mov ax,1+2" is assembled to "mov ax,0000") --- MS-DOS forever! |
Japheth
Germany (South), 26.12.2020, 17:25
@ DosWorld
|
(My) fork of 8086 Assembler for DOS |
> IMHO, all of assemblers have one big problem ("big problem" - this is from
> my point of view) - they does not generate obj/omf.
The "all" is surely NOT true - there are quite a few who understand OMF format quite well (nasm, jwasm, ...). OMF looks pretty "legacy" these days, of course, but it's actually the only sufficiently standardized segmented object format that exists AFAIK. --- MS-DOS forever! |
rr
Berlin, Germany, 26.12.2020, 17:33
@ Japheth
|
(My) fork of 8086 Assembler for DOS |
> > So, don't ask for Pentium instructions support.
>
> So are we just allowed to report bugs?
I'm not in the position to allow or disallow anything to you or others. But I will kindly ignore requests for adding Pentium instructions.
Bug reports are welcome, of course.
> > Feel free to try it!
>
> I couldn't resist to try a potential wasm/jwasm/uasm/asmc competitor:
8086 Assembler is in no way meant as wasm/jwasm/uasm/asmc competitor. Maybe if you squeeze jwasm down to 10k.
> missing features (so far):
> - no ORG directive (so no device driver development possible?)
That's what the docs say.
> - SEGMENTs missing ( apparently ASM.COM is a "flat"-only assembler )
Would SEGMENTs make sense for a .COM-only assembler?
> - no support for listings
I added this to the docs now.
> - EQU exists, but no math possible ( "xxx EQU 1+1" is rejected )
The docs say: "Very limited support for expressions, i.e., only something like mov al,[bx+di] and mov ax,word ptr[codestore+2] works."
> - no END directive (important, since it allows "self-compiling" .BAT
> files)
What do you mean?
> bugs:
> - LDS opcode rejects any type of operands that I was able to imagine
That's interesting. Didn't try that.
Also applies to LES.
> - math accepted for direct operands, but ignored ("mov ax,1+2" is assembled
> to "mov ax,0000")
See EQU above.
You missed this bug: "dec r/m8, dec r/m16, and inc r/m8 instructions are encoded incorrectly. This also applies to the byte ptr or word ptr variants of div, idiv, imul, mul, neg, not, and push." --- Forum admin |
Japheth
Germany (South), 26.12.2020, 18:14 (edited by Japheth, 26.12.2020, 18:31)
@ rr
|
(My) fork of 8086 Assembler for DOS |
> > - no END directive (important, since it allows "self-compiling" .BAT
> > files)
>
> What do you mean?
Here's an example, named TEST.BAT:
;echo off
;goto start
_CODE segment
org 100h
mov dx,offset string1
mov ah,9
int 21h
mov ax,4c00h
int 21h
string1 db "hello",13,10,'$'
_CODE ends
END
:start
jwasm -q -bin -Fotest.com test.bat
test.com
No problem with jwasm - to work with ASM.COM it needs a working END directive.
EDIT: it actually works with ASM.COM as well, although not perfectly:
;echo off
;asm.com test.bat
;test.com
;exit
mov dx,string1
mov ah,9
int 21h
mov ax,4c00h
int 21h
string1: db "hello",13,10,'$'
A :END label to skip the assemble code would be better, since the "exit" terminates batch processing. And one problem that remains is that the assembler cannot be told to be silent. --- MS-DOS forever! |
Japheth
Germany (South), 26.12.2020, 19:18
@ rr
|
ASM's symbol handling needs work |
There are problems with symbols. The following code snippets are accepted without errors:
mov dx,string2
mov ah,9
int 21h
ret
string1: db "hello",13,10,'$'
string1: db "another hello",13,10,'$'
and, worse:
mov dx,string2
mov ah,9
int 21h
ret
string1: db "hello",13,10,'$'
Neither duplicate symbols nor non-existant symbols are recognized currently. --- MS-DOS forever! |
rr
Berlin, Germany, 26.12.2020, 19:23
@ Japheth
|
ASM's symbol handling needs work |
> Neither duplicate symbols nor non-existant symbols are recognized
> currently.
Oops!
Looks like this assembler is only for the pros.
Something more to work on. --- Forum admin |
RayeR
CZ, 26.12.2020, 22:48
@ DosWorld
|
(My) fork of 8086 Assembler for DOS |
> IMHO, all of assemblers have one big problem ("big problem" - this is from
> my point of view) - they does not generate obj/omf. What about obj in this
> assembler? Second "problem" - they all limited to .com file.
BTW just for a curiosity why are you needing that OMF? I could see here ..ehm.. a bit obsession with OMF in many threads in the past but I missed any real usage - who needs it for compiling what projects? --- DOS gives me freedom to unlimited HW access. |
rr
Berlin, Germany, 26.12.2020, 23:22
@ Japheth
|
(My) fork of 8086 Assembler for DOS |
> bugs:
> - LDS opcode rejects any type of operands that I was able to imagine
Added to the "Known Bugs" section. --- Forum admin |
rr
Berlin, Germany, 26.12.2020, 23:22
@ Japheth
|
ASM's symbol handling needs work |
> Neither duplicate symbols nor non-existant symbols are recognized
> currently.
Added to the "Known Bugs" section. Thanks for reporting. --- Forum admin |
rr
Berlin, Germany, 26.12.2020, 23:26
@ Japheth
|
(My) fork of 8086 Assembler for DOS |
> A :END label to skip the assemble code would be better, since the "exit"
> terminates batch processing. And one problem that remains is that the
> assembler cannot be told to be silent.
While trying to implement the END pseudo-op, I was unsatisfied with the screen output, so I reworked it completely and released a new version. Nothing else has changed. --- Forum admin |
DosWorld
27.12.2020, 00:03 (edited by DosWorld, 27.12.2020, 00:22)
@ RayeR
|
(My) fork of 8086 Assembler for DOS |
> BTW just for a curiosity why are you needing that OMF? I could see here
> ..ehm.. a bit obsession with OMF in many threads in the past but I missed
> any real usage - who needs it for compiling what projects?
I want consume obj produced with SPHNIX C-- (imho, best for small and highspeed libraries) and i want produce output files could be used with TP (etc). So, it need not for compiling project, it need for compiler developers.
Known alternatives - TPU is not well-described, a.out/coff good for no-segments memory models (16/32 bit). ( --- Make DOS great again!
Make Russia small again! |
rr
Berlin, Germany, 27.12.2020, 01:05
@ rr
|
(My) fork of 8086 Assembler for DOS |
I released an updated version, which adds support for missing Jcc, LOOPcc, and REPcc aliases. Just because it was easy to do so.
Maybe it also helps to try existing asm code w/o much rework. Calling a DOS function and using JB after instead of JC seemed strange to me. --- Forum admin |
RayeR
CZ, 27.12.2020, 03:57
@ DosWorld
|
(My) fork of 8086 Assembler for DOS |
Aha, I wouldn't imagine possibility of mixing TP and C-- code (no problems with call conventions?). Can you describe it a bit more detailed? So you have some low level C routine, compile it to OMF with C-- and then how it is integrted to TP? I know only TPU (TP units). So you need to make TP produce also OMF and then link together with some OMF linker to target EXE? --- DOS gives me freedom to unlimited HW access. |
rr
Berlin, Germany, 27.12.2020, 08:49
@ DosWorld
|
(My) fork of 8086 Assembler for DOS |
> I want consume obj produced with SPHNIX C-- (imho, best for small and
> highspeed libraries) and i want produce output files could be used with TP
> (etc). So, it need not for compiling project, it need for compiler
> developers.
If SPHiNX C-- produces OMF .OBJ files, you can link them directly with TP. You just need to declare functions/procedures as external to TP and use the {$L file.obj} syntax.
http://www.retroarchive.org/swag/MISC/0109.PAS.html
http://swag.outpostbbs.net/FAQ/0007.PAS.html
TP comes with a sample too. I think, it's called BGILINK. --- Forum admin |
rr
Berlin, Germany, 27.12.2020, 13:22
@ Japheth
|
(My) fork of 8086 Assembler for DOS |
> missing features (so far):
> - no ORG directive (so no device driver development possible?)
With some "handcrafting" I was able to rebuild my little PAUSE.SYS using ASM.COM . Just rename generated PAUSE.COM to PAUSE.SYS. Of course, it's no fun to recalc offsets, e.g., for pausemsg , if you make changes to the code.
; ****************************************************************************
; `PAUSE' - Source code for `pause' object
; Written by Robert Riebisch
; Converted to 8086 Assembler syntax by Robert Riebisch
;
; Copyright (c) 1997-2020 BTTR Software. All rights reserved.
;
; This program is free software; you can redistribute it and/or modify it
; under the terms of the `MODIFIED' BSD LICENSE. Please see `legal.txt'
; for details.
; ****************************************************************************
; device driver header
devdrvrhdr:
dw 0ffffh,0ffffh
dw 0 ; device attributes (block device)
dw 22 ; strategy routine offset _@strat
dw 33 ; interrupt routine offset _@intr
db 1 ; # of units
db 0,0,0,0,0,0,0 ; (reserved)
reqhdrptr: dw 0,0 ; pointer to request header
; strategy routine
_@strat:
cs:
mov [reqhdrptr-100h],bx ; save pointer to request header
cs: ; `-100h' = workaround unsupported `org'
mov [reqhdrptr+2-100h],es
retf
; interrupt routine
_@intr:
push ax ; save affected registers
push bx
push dx
push ds
pushf
; clear keyboard buffer
_@nextkey:
mov ah,1 ; check for keystroke
int 16h
jz _@empty
xor ah,ah ; get keystroke
int 16h
jmp _@nextkey
_@empty:
push cs ; make local data (`pausemsg')
pop ds ; addressable by setting DS = CS
mov dx,90 ; print pause message
; or use:
; mov dx,pausemsg ; print pause message
; sub dx,100h ; workaround unsupported `org' pseudo-op
mov ah,9
int 21h
xor ah,ah ; wait for keystroke
int 16h
; get removed from RAM by signaling an error
; `lds bx, [reqhdrptr]' encoded
db 0c5h,1eh,12h,0 ; point DS:BX to request header
mov word ptr [bx+3],8103h ; status = `Error', `Done', `Unknown command'
; above line might not be enough
mov byte ptr [bx+13],0 ; # of units
mov word ptr [bx+14],0 ; break address = CS:0 (for max. compatibility
mov [bx+16],cs ; with, e.g., old FreeDOS kernels, PTS-DOS 2000 or
; PTS-DOS 32)
popf ; restore affected registers
pop ds
pop dx
pop bx
pop ax
retf
pausemsg: db 'Press any key to continue...',13,10,'$'
; (end of `pause.asm') --- Forum admin |
DosWorld
27.12.2020, 22:11 (edited by DosWorld, 27.12.2020, 23:28)
@ RayeR
|
(My) fork of 8086 Assembler for DOS |
> Aha, I wouldn't imagine possibility of mixing TP and C-- code (no problems
> with call conventions?).
No problems.
> Can you describe it a bit more detailed?
Here is Michael Schreker C--.
this function return length of string k:
("d" parameter is not need, i just put it for proof params order)
int pascal cmm_length(int d, dword k) {
// k = pascal string
// d - something other
$push ds;
$lds si,k;
$cld;
$lodsb;
AH = 0;
$pop ds;
}
also, you can define length as far
int pascal far length(int d, dword k) {
compile it with
c-- /x /sobj len.c--
(/sobj mean slave obj, /obj produce obj with entry point in our case we not need entry point)
and use into TP - it must work for TP 5.0 ang great (ver 3.0 had alternative way without obj, 4.0 - i never try and use):
function cmm_length(d:integer;k:string):integer;near;external;
{$L LEN.OBJ}
or far:
function cmm_length(i:integer;k:string):integer;far;external;
and call it:
writeln(cmm_length(0, 'hello world!'));
If i am not wrong (i don't remember preciously now), i am check and compare original C-- source code and Michael's source: original C-- does not produce FIXUP record for obj (i love this [censored] record!) - just put code without relocation info, so you can't use static/global variables into C-- obj's. Michael fix and add it. (This is IMHO, need check it again).
> produce also OMF and then link together with some OMF linker to target EXE?
without linker - TP can consume obj/omf.
Also, no problem linking C-- and Watcom C (i do it for real mode).
Possible easy linking with TP3, but i think it is non-actual.
C-- can do a real magic for you. I have problems only linking with Small C - Small C does not use Borland/Microsoft name convention for segments (TEXT/DATA/BSS etc). It think root cause is - because this convention is created later then Small C. I have idea - rewrite std-library for Small C in C-- (i think it must be a rocket-speed).
PS: Scheker's C-- have a bug - add unwanted byte to driver header (when produce ms-dos .sys file). I send bugreport to Michael, but Michael stop respond on any mail. --- Make DOS great again!
Make Russia small again! |
RayeR
CZ, 28.12.2020, 01:09
@ DosWorld
|
(My) fork of 8086 Assembler for DOS |
OK, thanks for example.
So only the object file in OMF format can be linked directly by TP without external tools and C-- supports this format. And how about OBJ files produced by TurboC and TurboAssembler? Those are also OMF or different format that cannot be used this way? --- DOS gives me freedom to unlimited HW access. |
DosWorld
28.12.2020, 14:00 (edited by DosWorld, 28.12.2020, 14:47)
@ RayeR
|
(My) fork of 8086 Assembler for DOS |
> OK, thanks for example.
> So only the object file in OMF format can be linked directly by TP without
> external tools and C-- supports this format. And how about OBJ files
> produced by TurboC and TurboAssembler? Those are also OMF or different
> format that cannot be used this way?
Yes, this is the same obj/omf. In DOS was available only one obj format - omf. All 99% of commercial compilers and linkers in 80x and 90x understand obj in omf format. It was a industrial standart - the same as coff (for obj) now.
Yes, TC and TASM produce same obj/omf format and for linking uses TLINK - this is obj/omf linker. Microsoft has the same toolchain - MASM + LINK and they also work with obj/omf. Yes, if i am not wrong Turbo C had "pascal" (and "far") keywords - so they could be linked with TP. TASM could be linked with TP/TC with zero problem - this is native case.
Dinosaurs Small C + Small Assembler also uses obj/omf. Also, imho, many OS/2 compilers also work with obj/omf (omf have extensions for 32bit segments, but this is not the same as coff).
So, if you want create near to professional grade compiler - you must work with obj/omf. If you want deliver libraries - you must do it with obj/lib in omf format.
Only DJGPP can don't understand OFM format (not sure, IMHO), but this is for me "alien" technology (came to microcomputers from mainframes in later times). (May be "alien" is wrong word?) --- Make DOS great again!
Make Russia small again! |
rr
Berlin, Germany, 29.12.2020, 01:55
@ rr
|
(My) fork of 8086 Assembler for DOS |
> I released an updated version, which adds support for missing Jcc, LOOPcc,
> and REPcc aliases. Just because it was easy to do so.
>
> Maybe it also helps to try existing asm code w/o much rework. Calling a DOS
> function and using JB after instead of JC seemed strange to me.
Another update: ASM.COM will now return to DOS with errorlevel. --- Forum admin |
marcov
29.12.2020, 19:14
@ DosWorld
|
(My) fork of 8086 Assembler for DOS |
> I want consume obj produced with SPHNIX C-- (imho, best for small and
> highspeed libraries) and i want produce output files could be used with TP
> (etc).
16-bit Free Pascal? |
RayeR
CZ, 30.12.2020, 05:18
@ DosWorld
|
(My) fork of 8086 Assembler for DOS |
OK, now I understand. But I never needed to do anything special with object files in DOS, I just used TASM + TLINK in the past then rather used NASM. Also in DJGPP that use COFF I don't remember I would need do other magic than standard linking. But good to know there are such mixing/linking possibilities... --- DOS gives me freedom to unlimited HW access. |
rr
Berlin, Germany, 02.03.2022, 21:54
@ rr
|
(My) fork of 8086 Assembler for DOS |
> Although this is a self-hosting assembler, it still lacks features and has
> bugs. I started squashing at
> https://github.com/bttrx/8086-assembler and also wrote a small
> Readme.
I killed this project a few days ago. Too many bugs, too little outcome. --- Forum admin |