[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/db/driver/mysqli.php on line 264: mysqli_fetch_assoc(): Couldn't fetch mysqli_result
[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/db/driver/mysqli.php on line 326: mysqli_free_result(): Couldn't fetch mysqli_result
Pete's QBASIC Site Discuss QBasic, Freebasic, QB64 and more 2021-01-04T22:54:34-05:00 http://petesqbsite.com/phpBB3/app.php/feed/topic/14849 2021-01-04T22:54:34-05:00 2021-01-04T22:54:34-05:00 http://petesqbsite.com/phpBB3/viewtopic.php?p=39026#p39026 <![CDATA[Re: Trouble getting extended memory version in Qbasic]]>
for my calls to the XMS code I needed to add the FAR keyword in asm.

This is my new assembly code that works:

Code:

segment code;XMS ACCESS;Call absolute(codeseg+ptr,dataseg+ptr,codeseg+ptr);Type xms...;int: func;int: install check;int: xms ver;dint: xmsaddrmain:PUSH BPMOV BP, SPPUSH ESPUSH DIPUSH DSPUSH SIMOV DI,[BP+08h] ;ES:DI=struct entry pointmov ES,[DI]MOV DI,[BP+06h]mov DI,[DI]mov AX,[ES:DI]cmp AX,00FEh;FEh=addr call testjne naddr  call getaddr  jmp endingnaddr:cmp AX,00FFh;FFh=XMS verjne nver  call getaddr  mov AX,0h  call far [xmscall]  mov [ES:DI+04h],AX ;XMS ver  jmp endingnver:cmp AX,00h;00h=XMS install checkjne ninit  mov AX,4300h  int 2Fh  cmp AL,80h  jne noxms  mov AX,1h  mov [ES:DI+02h],AX ;XMS install check  jmp endingninit:;XRAM address must be loaded beyond herecmp AX,01hjne nquery ;386 query  mov AX,8800h  call far [xmscall]  mov BH,0h  ;mov ES:[DI+0Ch],BX ;stat  ;mov ES:[DI+0Eh],EAX ;largest block  ;mov ES:[DI+12h],EDX ;total kb  ;mov ES:[DI+16h],ECX ;addr  jmp endingnquery:ending:POP SIPOP DSPOP DIPOP ESPOP BPRETF 4hxmscall:dd 0 ;This gets changed to the address of the XMS routinesnoxms:  mov AX,0h  mov [ES:DI+02h],AX ;XMS install checkjmp endinggetaddr:  push AX  push ES  push DI  mov AX,4310h  int 2Fh  mov word[xmscall+2],ES ;mem addr  mov word[xmscall],BX    pop DI  pop ES  pop AXret

Statistics: Posted by mikefromca — Mon Jan 04, 2021 10:54 pm


]]>
2021-01-04T20:07:54-05:00 2021-01-04T20:07:54-05:00 http://petesqbsite.com/phpBB3/viewtopic.php?p=39025#p39025 <![CDATA[Trouble getting extended memory version in Qbasic]]>
This is what I read:
http://www.petesqbsite.com/sections/tut ... 1-xms.html

So I then created assembly code and compiled it with NASM. This is my code:

Code:

main:;Save registersPUSH BPMOV BP, SPPUSH ESPUSH DIPUSH DSPUSH SI;We pass in a structure as last 2 CALL ABSOLUTE parameters.;ES:DI will have the pointer to that structure here.MOV DI,[BP+08h]mov ES,[DI]MOV DI,[BP+06h]mov DI,[DI];our Wanted Function is first integer in structuremov AX,[ES:DI]cmp AX,00h;00h=XMS install checkjne ninit  mov AX,4300h ;Call XMS checking routine  int 2Fh  cmp AL,80h ;AL must return 80h or XMS is not installed  jne noxms  mov AX,1h  ;XMS status is 2nd integer in structure.  ;Here it is 1 to let QB know XMS is installed  mov [ES:DI+02h],AX   mov AX,4310h  ;Save our structure address  ;so next call wont wreck it  push ES  push DI  ;Get the call address to most XMS functions  int 2Fh  ;ES:BX has call address but we will make it AX:BX  mov AX,ES  ;Restore our structure address  pop DI  pop ES  ;Store memory address into a long integer in our struct  ;Am I formatting the value wrong here?  mov [ES:DI+08h],AX   mov [ES:DI+06h],BX    jmp endingninit:cmp AX,01hjne nquery ;386 query (Haven't tried this yet)  mov AX,8800h  call dword[ES:DI+06h]  mov BH,0h  ;mov [ES:DI+0Ch],BX ;stat  ;mov [ES:DI+0Eh],EAX ;largest block  ;mov [ES:DI+12h],EDX ;total kb  ;mov [ES:DI+16h],ECX ;addr  jmp endingnquery:cmp AX,00FFhjne nver;FFh=XMS version  mov AX,0h  call dword[ES:DI+06h] ;Use our long integer as address  mov [ES:DI+04h],AX ;Store version into final integer in struct  jmp endingnver:ending:;restore registersPOP SIPOP DSPOP DIPOP ESPOP BP;exit to QBRETF 4hnoxms:  ;Set our installed status to 0  mov AX,0h  mov [ES:DI+02h],AX jmp ending
And this is my QBASIC code:

Code:

DECLARE FUNCTION acode$ ()'This is the structTYPE xmsfunc AS INTEGER 'The function we wantinst AS INTEGER  'value determining if XMS is installed.xver AS INTEGER 'version of XMS installedaddr AS LONG      'Address to use to call extended XMS routinesEND TYPEDIM x AS xms 'call this as x in herex.func = 0 'Start with function 0: Check for XMS existancex.inst = 0 'Assume nothing is installedx.xver = 0 'Assume no versionDIM cd AS STRING * 500 'Reserve 500 bytes for binary codecd = acode$ 'and fit the binary code in (code length is under 300 bytes)CLS 'clean screenDEF SEG = VARSEG(cd) 'use our code'Here we inject our structure into call absoluteCALL absolute(VARSEG(x), VARPTR(x), VARPTR(cd))PRINT x.inst, x.xver 'here x.inst returns 1 which is correct for just about every computerx.func = &HFF& 'Check for memory version'Program never goes past this point and DOSBOX locks upCALL absolute(VARSEG(x), VARPTR(x), VARPTR(cd)) PRINT "results"PRINT x.xverENDFUNCTION acode$'First value is hex values of the compiled code after running unix utilities nasm and xxd -p on it.'I used ndisasm on the binary and the code returned fine.w$ = "5589e506571e568b7e088e058b7e068b3d268b0583f8007525b80043cd2f3c807548b8010026894502b810430657cd2f8cc05f072689450826895d06eb2483f801750cb800882666ff5506b700eb133dff00750eb800002666ff550626894504eb005e1f5f075dca0400b8000026894502ebef"'here we manually convert hex values to binary and store it in memorycd$ = "": FOR n% = 1 TO LEN(w$) STEP 2: cd$ = cd$ + CHR$(VAL("&H" + MID$(w$, n%, 2))): NEXTacode$ = cd$END FUNCTION

Am I formatting my call address in assembly code correctly for NASM? because I think the problem comes down to that because everytime I execute the second call absolute to retrieve the XMS version it always locks up.

Statistics: Posted by mikefromca — Mon Jan 04, 2021 8:07 pm


]]>