Maximum line length and condensing machine code

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
mikefromca
Coder
Posts: 41
Joined: Wed Oct 16, 2019 11:28 am

Maximum line length and condensing machine code

Post by mikefromca »

For me to make my assembly code work fast with Qbasic code in a test-like environment without involving disk access, this is what I do.

1. I setup my environment. A Linux box with KDE and QuickBasic 4.0 running in DOSBOX

2. I use a linux text editor (its called kate) to create my code, and nasm assembler to assemble it. It creates the binary file. I'm well aware that I can simply load the binary file into my program every time I want to execute it but that's another file to worry about and the program can be easily corrupted if a byte in the file is modified since its a binary file instead of a configuration file.

3. So I take the binary file and thanks to a nice linux program, I can create hexadecimal code required for the program to execute. then I open my code in the same linux text editor and copy and paste.

4. Finally I launch DOSBOX with QuickBasic 4.0 loading the code.

The interpreter itself has no problem running the code when I do the usual run (shift+F5), but when it comes to compiling, BC not only becomes fussy about line lengths, it tells me the same error twice, prints some happy faces in a couple of random spots, and the DOS screen locks up (I habe to manually close it)

So I go back to my editor to reload the code and it seems that underscores are added where I set the data. After executing the program and closing DOSBOX, I notice in my source code that this:

Code: Select all

w$="XXYYZZ..."
has been changed to:

Code: Select all

w$=  _
"XXYYZZ..." _
I don't know if QuickBasic does this internally to long lines of code or not.

So anyways, I use the below code to load my assembly code into the program before executing it with call absolute. It converts the hex values into actual codes (of which some cant be typed on the screen directly).

Code: Select all

w$="XXYYZZ..."
cd$ = "": FOR z% = 1 TO LEN(w$) STEP 2: cd$ = cd$ + CHR$(VAL("&H" + MID$(w$, z%, 2))): NEXT
acode$ = cd$
Is there a way to embed a large chunk of assembly code into my program without having to do a bunch of manual formatting steps in QuickBasic itself and without the compiler (BC) complaining that a line is too long?

Maybe theres syntax in QuickBasic that someone could point out to me that allows me to use long lines when compiling. I wonder if thats what the underscore means?

I want to avoid having the program load the compiled assembly code in from a separate file.

Any ideas?

I attached pictures to show what I have done.
Attachments
task2.png
task2.png (79.8 KiB) Viewed 36025 times
task1.png
task1.png (74.05 KiB) Viewed 36025 times
Qbasic is too fussy to compile.
Qbasic is too fussy to compile.
toolong.png (195.65 KiB) Viewed 36025 times
Post Reply