(trick) CLI-oriented DOSBox for those who need to use DOS compilers/assemblers  - Page 1
Forum section: electronics / general

author: legacy
author_rank: Super Contributor
timestamp: March 05, 2017, 10:55:04 pm
content: Code:mydos_file_name_get(){#$1 = filedos_file_name=$(sed -e 's#^J:##' -e 's#/#\\#g' <<< "$1")}if [ "*$1" = "*" ]thenexitfiargc="$#" # how many arg from bash command line ?app_args="" # where to store arguments from bash command lineargs=("$@") # args[]={arg0..argC}argv=""for ((i=0;i<argc;i+=1))doargi="$i"mydos_file_name_get "${args[$i]}"argv="$argv $dos_file_name"doneecho "$argv > STDOUT0.TXT" > do.batecho "exit" >> do.battouch STDOUT0.TXTdosbox -conf /etc/dosbox/cli.conf > /dev/null 2> /dev/nullcat STDOUT0.TXTrm do.batrm STDOUT0.TXT/usr/bin/mydosbox-exec (bash script)Code:fullscreen=falsefulldouble=falsefullresolution=originalwindowresolution=originaloutput=surfaceautolock=truesensitivity=100waitonerror=truepriority=higher,normalmapperfile=mapper-SVN.mapusescancodes=falselanguage=machine=svga_s3captures=capturememsize=16frameskip=0aspect=falsescaler=normal2xcore=autocputype=autocycles=autocycleup=10cycledown=20serial1=dummyserial2=dummyserial3=disabledserial4=disabledxms=trueems=trueumb=truekeyboardlayout=auto# ipx: Enable ipx over UDP/IP emulation.ipx=falsemount C: .C:do.bat/etc/dosbox/cli.confDOSBox 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/workaroundit 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: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.cCode:Cube dos-hAllo # echo "hallo" > project.name.myprjCube dos-hAllo # mygcc-build-project-makefile-v6 --profile=dos16 -vblessing project filesproject.flagcc.myprj, COM executable C flagsproject.flagld.myprj, COM executable linker flagsproject.ml.myprj, machine layer, COM executable for MS-DOSproject.name.myprj, 'hallo.com' MS-DOS executableCode:Cube dos-hAllo # make- compiling hallo ... done- linking to hallo.comCode:Cube dos-hAllo # mydosbox-exec obj/dos/hallo.comhAllo, World!---Code:Cube script-exec # lsas11.exe test.asmCode:Cube script-exec # mydosbox-exec as11.exe6811 assembler version 2.1 10-Aug-91original program by Motorola.Usage: C:\AS11.EXE Code:Cube script-exec # mydosbox-exec as11.exe test.asm6811 assembler version 2.1 10-Aug-91original program by Motorola.Code:Cube script-exec # lsas11.exe test.asm TEST.S19The (ugly) trick seems working.Have fun

author: westfw
author_rank: Super Contributor
timestamp: March 06, 2017, 10:59:11 pm
content: 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)?

author: Zero999
author_rank: Super Contributor
timestamp: March 06, 2017, 11:15:45 pm
content: 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.

author: legacy
author_rank: Super Contributor
timestamp: March 06, 2017, 11:20:39 pm
content: 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

author: legacy
author_rank: Super Contributor
timestamp: March 06, 2017, 11:29:13 pm
content: Quote from: Hero999 on March 06, 2017, 11:15:45 pmYup, 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.

author: legacy
author_rank: Super Contributor
timestamp: March 06, 2017, 11:45:17 pm
content: Quote from: legacy on March 05, 2017, 10:55:04 pmAlso, keep in mind that it works ONLY if the dos-applicaiton calls int 0x21, as shown in the above example.

author: Zero999
author_rank: Super Contributor
timestamp: March 07, 2017, 09:31:57 am
content: Quote from: legacy on March 06, 2017, 11:29:13 pmInteresting. Is a desktop? I've not used a RISC desktop since I was at school, when the Acorn Archimedes were popular.

author: legacy
author_rank: Super Contributor
timestamp: March 07, 2017, 09:51:51 am
content: Quote from: Hero999 on March 07, 2017, 09:31:57 amIt'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 remotelythrough 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, ...? }Quote from: Hero999 on March 07, 2017, 09:31:57 amARM ? Yup, I have a RISCPC/600, StrongARM@200Mhz, RISCOS v4.39DOS-v6 and DOS-applications (e.g. Turbo Pascal, Turbo C, etc) are supported in hardwareby a guest PC card with a 486DX4@100Mhz on it.(!PC-v3.08 on RISCOS v4.39, running Norton Commander on MSDOS v6.22)

author: legacy
author_rank: Super Contributor
timestamp: April 04, 2018, 11:54:23 am
content: I have ported this to Power/PC linux, supporting an old dos-assembler for 68hc11

author: technix
author_rank: Super Contributor
timestamp: April 04, 2018, 07:01:01 pm
content: Quote from: legacy on March 07, 2017, 09:51:51 amIsn't PA-RISC out of any form of support now?Quote from: legacy on March 07, 2017, 09:51:51 amThis kind of trick is still kind of relevant given that ARM is running rampant in the mobile scene...