shortening loading time for call absolute
Posted: Fri Jan 15, 2021 3:55 pm
I made a program in Qbasic that uses assembly code with call absolute. The crazy thing is loading the data into a variable takes a long time in itself. I guess that's the price I pay for convenience.
But this is how I do it. I make my assembly code in linux with nasm then I use xxd utility to extract the hex code I need in the right format, then I paste it into my program. the xxyyxxyy you see in my Qbasic code represents that assembly code in hexadecimal, but since my assembly code is over 1600 bytes long, I needed to put my code across a few lines and concatenate it together so the QuickBasic EXE compiler doesn't break when I make an EXE.
Anyways, here's my code so far:
I know the slowness lies within the for-next loop because I'm dealing with converting each individual byte to an actual machine character and then d$ equals all of the bytes as machine language.
I want to avoid loading the machine code as a file because I want it internal to my program.
I thought of using MKL$ but for that don't the hex codes have to be reversed for that to work?
Is there another way I can make that for-next loop execute faster?
But this is how I do it. I make my assembly code in linux with nasm then I use xxd utility to extract the hex code I need in the right format, then I paste it into my program. the xxyyxxyy you see in my Qbasic code represents that assembly code in hexadecimal, but since my assembly code is over 1600 bytes long, I needed to put my code across a few lines and concatenate it together so the QuickBasic EXE compiler doesn't break when I make an EXE.
Anyways, here's my code so far:
Code: Select all
asmcode$ = "xxyyxxyyxxyy"......
asmcode$ = asmcode$+ "xxyyxxyyxxyy"......
asmcode$ = asmcode$+ "xxyyxxyyxxyy"......
d$=""
for c% = 1 to len(asmcode$) step 2
d$=d$+chr$(val("&H"+mid$(asmcode$,c%,1)))
next c%
I want to avoid loading the machine code as a file because I want it internal to my program.
I thought of using MKL$ but for that don't the hex codes have to be reversed for that to work?
Is there another way I can make that for-next loop execute faster?