Author Topic: (trick) CLI-oriented DOSBox for those who need to use DOS compilers/assemblers  (Read 3790 times)

0 Members and 1 Guest are viewing this topic.

Offline legacyTopic starter

  • Super Contributor
  • ***
  • !
  • Posts: 4415
  • Country: ch
Code: [Select]
mydos_file_name_get()
   {
   #$1 = file
   dos_file_name=$(sed -e 's#^J:##' -e 's#/#\\#g' <<< "$1")
   }

if [ "*$1" = "*" ]
   then
       exit
   fi

argc="$#"     # how many arg from bash command line ?
app_args=""   # where to store arguments from bash command line
args=("$@")   # args[]={arg0..argC}

argv=""
for ((i=0;i<argc;i+=1))
    do
        argi="$i"
        mydos_file_name_get "${args[$i]}"
        argv="$argv $dos_file_name"
    done

echo "$argv > STDOUT0.TXT" >  do.bat
echo "exit"                >> do.bat

touch STDOUT0.TXT
dosbox -conf /etc/dosbox/cli.conf > /dev/null 2> /dev/null
cat STDOUT0.TXT

rm do.bat
rm STDOUT0.TXT
/usr/bin/mydosbox-exec (bash script)


Code: [Select]
[sdl]
fullscreen=false
fulldouble=false
fullresolution=original
windowresolution=original
output=surface
autolock=true
sensitivity=100
waitonerror=true
priority=higher,normal
mapperfile=mapper-SVN.map
usescancodes=false

[dosbox]
language=
machine=svga_s3
captures=capture
memsize=16

[render]
frameskip=0
aspect=false
scaler=normal2x

[cpu]
core=auto
cputype=auto
cycles=auto
cycleup=10
cycledown=20

[serial]
serial1=dummy
serial2=dummy
serial3=disabled
serial4=disabled

[dos]
xms=true
ems=true
umb=true
keyboardlayout=auto

[ipx]
# ipx: Enable ipx over UDP/IP emulation.
ipx=false

[autoexec]
mount C: .
C:
do.bat
/etc/dosbox/cli.conf


DOSBox is focused on running old DOS-games, so you'd think would be MUCH harder than running old command-line compilers: the above trick shows how you can fool it, turning it into something that ends up with a Wine-like interface "Dosbox asm11 -blablabla hAllo.asm" 

---

the return status (success, failure) is not yet supported.
I have to think about a trick/patch/workaround  :-// :-// :-//

it works in a text shell, it doesn't show the Window
(it's automatically closed when the invoked dos-app ends)
but it requires a X11 client, otherwise it SDL_VIDEO_INIT fails.

---

Code: [Select]
asm (".code16gcc\n"
     "call  dosmain\n"
     "mov   $0x4C,%ah\n"
     "int   $0x21\n");

static void print(char *string)
{
    asm volatile ("mov   $0x09, %%ah\n"
                  "int   $0x21\n"
                  : /* no output */
                  : "d"(string)
                  : "ah");
}

int dosmain(void)
{
    print("hAllo, World!\n$");
    return 0;
}
hallo.c

Code: [Select]
Cube dos-hAllo # echo "hallo" > project.name.myprj
Cube dos-hAllo # mygcc-build-project-makefile-v6 --profile=dos16 -v
blessing project files
project.flagcc.myprj, COM executable C flags
project.flagld.myprj, COM executable linker flags
project.ml.myprj, machine layer, COM executable for MS-DOS
project.name.myprj,  'hallo.com' MS-DOS executable

Code: [Select]
Cube dos-hAllo # make
- compiling hallo ... done
- linking to hallo.com

Code: [Select]
Cube dos-hAllo # mydosbox-exec obj/dos/hallo.com
hAllo, World!

---

Code: [Select]
Cube script-exec # ls
as11.exe  test.asm


Code: [Select]
Cube script-exec # mydosbox-exec as11.exe                                                                                                                                     
6811 assembler version 2.1  10-Aug-91
  original program by Motorola.
Usage: C:\AS11.EXE [files]

Code: [Select]
Cube script-exec # mydosbox-exec as11.exe test.asm
6811 assembler version 2.1  10-Aug-91
  original program by Motorola.

Code: [Select]
Cube script-exec # ls
as11.exe  test.asm  TEST.S19 


The (ugly) trick seems working.
Have fun  :popcorn:
« Last Edit: March 06, 2017, 11:38:51 am by legacy »
 
The following users thanked this post: Naguissa

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4199
  • Country: us
Thanks!  Looks useful.
Does DOSBox have particular advantages over WINE for this sort of thing (other than potentially being able to run pre-W32 tools)?
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19482
  • Country: gb
  • 0999
DOSBox is an emulator. WINE Is Not an Emulator. It has better compatibility for DOS than WINE does.

Personally I prefer DOSEmu over DOSBox but haven't used either for years. If I remember rightly DOSEmu is much easier to work with under the command line, than DOSBox.
 

Offline legacyTopic starter

  • Super Contributor
  • ***
  • !
  • Posts: 4415
  • Country: ch
Wine initially checks if the binary is DOS(typically 16bit) or WIN32.
In the first case it launches DOSBox, in the second case it goes on and directly handles the emulation.

Therefore it's all matter about how Wine calls DOSBox: with/out passing through my trick  :-//
« Last Edit: March 06, 2017, 11:42:35 pm by legacy »
 

Offline legacyTopic starter

  • Super Contributor
  • ***
  • !
  • Posts: 4415
  • Country: ch
DOSBox is an emulator. WINE Is Not an Emulator

Yup, in my case I am not on x86 machine, so I must use DOSBox (under the hood I have a RISC CPU).
He is probably on a PC, so no problem about what is behind the hood.

We are speaking about "compilers and assemblers", programs that don't need to have a video card emulation or whatever.

The real problem is: Wine doesn't handle DOS applications directly! Instead it calls DOSBox (see source, it does that way)
if you invoke DOSBox without a trick, you get inside a boring and annoying DOS-Windows, and you need to manually exit.
Also the STDOUT is lost because the DOS-program's output goes inside the DOS-Windows.

The point of my trick is: having a CLI-oriented way to call and launch a DOS16 assembler (e.g. m68HC11 assembler, or z80 assembler).
with the STDOUT redirected to a file, so you can have and use it from the linux shell.

Exactly as it was a native linux application.
« Last Edit: March 06, 2017, 11:30:59 pm by legacy »
 

Offline legacyTopic starter

  • Super Contributor
  • ***
  • !
  • Posts: 4415
  • Country: ch
Code: [Select]
mov   $0x09, %ah
int     $0x21
...

Also, keep in mind that it works ONLY if the dos-applicaiton calls int 0x21, as shown in the above example.
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19482
  • Country: gb
  • 0999
DOSBox is an emulator. WINE Is Not an Emulator

Yup, in my case I am not on x86 machine, so I must use DOSBox (under the hood I have a RISC CPU).
Interesting. Is a desktop? I've not used a RISC desktop since I was at school, when the Acorn Archimedes were popular.
 

Offline legacyTopic starter

  • Super Contributor
  • ***
  • !
  • Posts: 4415
  • Country: ch
Is a desktop?

It's a RISC server, HPPA, PA-RISC by HP, in my case the CPU is a PA8600@550Mhz.
I don't need a desktop (therefore I don't have a graphic card installed) since I use all of those machines remotely
through an X11 terminal. Typically a linux laptop, or a Windows notebook, used as X11 terminal.

The RISC family contains { POWER, PowerPC, POWER64, MIPS, MIPS64, ARM, SH, SPARC, HPPA, ...? }

I've not used a RISC desktop since I was at school, when the Acorn Archimedes were popular.

ARM ? Yup, I have a RISCPC/600, StrongARM@200Mhz, RISCOS v4.39
DOS-v6 and DOS-applications (e.g. Turbo Pascal, Turbo C, etc) are supported in hardware
by a guest PC card with a 486DX4@100Mhz on it.


(!PC-v3.08 on RISCOS v4.39, running Norton Commander on MSDOS v6.22)
« Last Edit: March 07, 2017, 09:53:27 am by legacy »
 

Offline legacyTopic starter

  • Super Contributor
  • ***
  • !
  • Posts: 4415
  • Country: ch
I have ported this to Power/PC linux, supporting an old dos-assembler for 68hc11 :D
 

Offline technix

  • Super Contributor
  • ***
  • Posts: 3507
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
Is a desktop?

It's a RISC server, HPPA, PA-RISC by HP, in my case the CPU is a PA8600@550Mhz.
I don't need a desktop (therefore I don't have a graphic card installed) since I use all of those machines remotely
through an X11 terminal. Typically a linux laptop, or a Windows notebook, used as X11 terminal.

Isn't PA-RISC out of any form of support now?

The RISC family contains { POWER, PowerPC, POWER64, MIPS, MIPS64, ARM, SH, SPARC, HPPA, ...? }

I've not used a RISC desktop since I was at school, when the Acorn Archimedes were popular.

ARM ? Yup, I have a RISCPC/600, StrongARM@200Mhz, RISCOS v4.39
DOS-v6 and DOS-applications (e.g. Turbo Pascal, Turbo C, etc) are supported in hardware
by a guest PC card with a 486DX4@100Mhz on it.


(!PC-v3.08 on RISCOS v4.39, running Norton Commander on MSDOS v6.22)


This kind of trick is still kind of relevant given that ARM is running rampant in the mobile scene...
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf