flat assembler
Message board for the users of flat assembler.

Index > DOS > problem with unREAL mode fasm

Goto page Previous  1, 2, 3, 4, 5  Next
Author
Thread Post new topic Reply to topic
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 09 Jan 2008, 23:40
DOS386, yes, horrible hack and I'm not convinced it could work (at least with what I have in mind), because I was not counting hardware interruptions at all. I though that the problem was that the CPU only increments IP at every instruction instead of EIP, so when such thing occurs then the handler would do some magic to set the high part of EIP. But again, the problem was another (or was it too?).
Post 09 Jan 2008, 23:40
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 10 Jan 2008, 00:09
DOS386 wrote:
vid wrote:
edfed: do you actually USE fasmd in pure dos, or do you just want it?

I DO USE it in DOS

in pure dos? eg. without extender?


Last edited by vid on 10 Jan 2008, 00:28; edited 1 time in total
Post 10 Jan 2008, 00:09
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4330
Location: Now
edfed 10 Jan 2008, 00:26
erf, evidentlly with extender now, because there isn't possibility to use it in PURE DOS mode..
playing with words don't help anybody, or it's humoristic... Laughing

now, with the extender, it works very well.
but, the extender is just a msdos program, installable and uninstallable. os yes, i use it in pure dos mode, now, with extender, before, with bugss.
the command line version is the one who works everywhere...but not under visthhhhaaa
Post 10 Jan 2008, 00:26
View user's profile Send private message Visit poster's website Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1900
DOS386 10 Jan 2008, 01:26
> in pure dos? eg. without extender?

YES, in pure DOS without Windaube Laughing and with a DPMI host Idea

> because there isn't possibility to use it in PURE DOS mode..

I have pure DOS mode - but FASMD and many other useful apps run using DPMI rather than in real mode Idea

> extender is just a msdos program

And "msdos" is dead Laughing

> with extender, before, with bugss.
> is the one who works everywhere...but not under visthhhhaaa

Very true Laughing
Post 10 Jan 2008, 01:26
View user's profile Send private message Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo 25 Jan 2008, 05:27
I don't see the huge issue with dropping unreal mode if necessary, but it's indeed a cool hack. (I normally have JEMM386 loaded, which provides UMBs, so actually I'd suggest lh cwsdpmi -p or lh hdpmi32 -r instead).

Maybe we all need to optimize FASM for size (sort of a coding competition, heh). Very Happy

BTW, the latest testing r6 of CWSDPMI is recommended over r5 if you want access to huge amounts of RAM:

Charles W. Sandmann wrote:

You will want to use the r6 test release if you plan to use more than
500MB.


download: csdpmi6t.zip

notes collected by me from Google Groups: csdpmi6t.txt

But yeah, HDPMI32 is probably equally preferable due to various reasons (more recently updated, smaller? memory footprint, automagically enables SSE for you, etc.). Wink

EDIT:

DOS386 wrote:

Also it reportedly doesn't work on Cyrix


According to Tomasz, that (no unreal) was only true on early Cyrix since I think he claimed to have tested newer versions from friends.
Post 25 Jan 2008, 05:27
View user's profile Send private message Visit poster's website Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo 02 Feb 2008, 16:42
Tomasz wrote:

I also did play with DOS interface a bit, I fixed some bugs and also managed to free some space under the 64k code limit, so that I still don't have to get rid of the unREAL mode from the DOS interface.


Just FYI, I wrote a silly little .BAT that shaves approximately 37 bytes from FASM (but feel free to ignore). It seems to assemble (and reassemble) correctly, so I think it works. Wink (I did try doing it via macro but failed miserably, heh. Oh well.)

Code:
@echo off
:: Using GNU/DJGPP sed 4.1.5 to shave a few bytes from FASM 1.67.26   Smile

:: 1). show only these lines before and after
:: sed -n "/add[ \t][ \t]*\(e\?[a-z][a-z]\)[ \t]*,[ \t]*2$/{p;s//rept 2 { inc \1 }/p}" .../*.*
:: 2). show affected line numbers only
:: sed -n "/add[ \t][ \t]*\(e\?[a-z][a-z]\)[ \t]*,[ \t]*2$/=" .../*.*
:: 3). count total affected lines
:: sed -n "/add[ \t][ \t]*\(e\?[a-z][a-z]\)[ \t]*,[ \t]*2$/=" .../*.* | sed -n $=
:: 4). edit "in place" the files (i.e. make the optimizations!)
sed -i "/add[ \t][ \t]*\(e\?[a-z][a-z]\)[ \t]*,[ \t]*2$/s//rept 2 { inc \1 }/" .../*.*
    


http://gd.tuwien.ac.at/pc/dos/djgpp/beta/v2gnu/sed415b.zip (212k)
http://gd.tuwien.ac.at/pc/dos/djgpp/current/v2gnu/sed415s.zip (1214k)
Post 02 Feb 2008, 16:42
View user's profile Send private message Visit poster's website Reply with quote
Goplat



Joined: 15 Sep 2006
Posts: 181
Goplat 03 Feb 2008, 01:30
Another possibility for making the code smaller: Make the instruction assembling routines be called instead of jmped, so the hundreds of 5-byte "jmp instruction_assembled"s all become little 1-byte "ret"s. This could save over a kilobyte.
Post 03 Feb 2008, 01:30
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4330
Location: Now
edfed 03 Feb 2008, 02:16
and that's why calls exists (at the origins), to make code clean, structured and little.
Very Happy
Post 03 Feb 2008, 02:16
View user's profile Send private message Visit poster's website Reply with quote
Polygon



Joined: 08 Feb 2008
Posts: 13
Location: Fire Island, NY
Polygon 08 Feb 2008, 13:56
Hello! I'm trying to switch to unreal mode in a BIOS Option ROM. I need to address 4gig memory space, but haven't been able to get it to play properly. I read thru the Kelvar example and maybe I'm never switching to 32 bit is the issue. I'm a little new to assembly, so go easy on me Very Happy

Can someone spot what is wrong with the "Flatmode" code or is this the FASM bug this very thread is about? Thanks in advance!:

Code:
use16
       pushfd  ; Push Flags Register onto the Stack (use 32)
       push    eax
 push    ebx
 push    edx
 call    flatmode                ; first, set up FS to access all 4G 
        
    mov eax,080000048h              ; (G)MCH Base Address Register
      mov dx,0CF8h                    ; set port address
  out dx,eax                      ; send address through the port
     mov dx,0CFCh                    ; set port data
     in eax,dx                       ; fetch data
        mov ebx,eax                     ; save the old value
        or eax,1                        ; increase data by new setting
      out dx,eax                      ; send data through port data

   and ebx,0FFFFC000h              ; mask off bits 31:14 inclusive
 add ebx,250h                    ; point to the relevant part
        mov ax,[fs:ebx]             ; fetch data at 250h address
        and ax,07FFh                    ; set Tras data bit to zero
 or ax,9000h                     ; copy data for Tras 18T
    mov [fs:ebx],ax             ; send data with 18T change

     pop     edx
 pop     ebx
 pop     eax
 popfd                           ; Pop Stack into  Eflags Register
   retf                            ; Return Far from Procedure

;----------------------------------------------------------------------
flatmode:
 ; first, calculate the linear address of GDT
        xor     edx,edx                 ; clear edx
 xor     eax,eax                 ; clear edx
 mov     dx,ds                   ; get the data segment
      shl     edx,4                   ; shift it over a bit
       cli                             ; turn off interrupts
       add     [cs:dword GDT+2],edx        ; store as GDT linear base addr
                                     ; now load the GDT into the GDTR
       lgdt    fword ptr cs:GDT         ; load GDT base (286-style 24-bit load)
     mov     bx,8                    ;1 * size DESC386 ; point to first descriptor
       mov     eax,cr0                 ; prepare to enter protected mode
   or      al,1                    ; flip the PE bit
   mov     cr0,eax                 ; we're now in protected mode
      mov     fs,bx                   ; load the FS segment register
      mov     ds,bx                   ;
   mov     es,bx                   ;
   mov     gs,bx                   ;
   mov     ss,bx                   ; load the SS segment register
      and     al,0FEh                 ; clear the PE bit again
    mov     cr0,eax                 ; back to real mode
 sti                             ; resume handling interrupts
        ret                             ;
;----------------------------------------------------------------------
GDT:
    dw  000fh                       ; limit low
 dw  GDT                         ; base lo
   db  0                           ; base mid
  db  0                           ; dpltype
   db  0                           ; lim hi
    db  0                           ; base hi

       ; this is the setup for the 4G segment
      dw  0ffffh                      ; limit low
 dw  0                           ; base lo
   db  0                           ; base mid
  db  092h                        ; dpltype
   db  0cfh                        ; lim hi
    db  0                           ; base hi
GDT_END:
    
Post 08 Feb 2008, 13:56
View user's profile Send private message Reply with quote
DJ Mauretto



Joined: 14 Mar 2007
Posts: 464
Location: Rome,Italy
DJ Mauretto 08 Feb 2008, 14:04
Quote:
I'm trying to switch to unreal mode in a BIOS Option ROM. I need to address 4gig memory space


Enable A20 Wink
Post 08 Feb 2008, 14:04
View user's profile Send private message Reply with quote
Polygon



Joined: 08 Feb 2008
Posts: 13
Location: Fire Island, NY
Polygon 08 Feb 2008, 14:07
Thanks, but I don't know how to do that...
Post 08 Feb 2008, 14:07
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4330
Location: Now
edfed 08 Feb 2008, 14:16
enable A20 via keyboard controller.
there are many, many, many, many, and more example on this board, and on internet too.

but the best is not to switch in unreal mode, but in protected mode.
unreal is a sort of bad trick, that need to switch in pm, load segment registers with 4G limit selector, and return to real mode, without reloading real mode selectors.

in the dex4u's package for the fasm browser project, there is a A20 switch function.
Post 08 Feb 2008, 14:16
View user's profile Send private message Visit poster's website Reply with quote
DJ Mauretto



Joined: 14 Mar 2007
Posts: 464
Location: Rome,Italy
DJ Mauretto 08 Feb 2008, 14:21
Code:

MACRO Wait_INPB
        { 

@@:
     IN      AL,64H                  
    TEST    AL,00000010B            
    JNZ     @B                      

        }

MACRO Wait_OUTB   
    {

@@:
       IN      AL,64H                  
    TEST    AL,00000001B            
    JZ      @B                      

        }

;===============
; Enable A20
;===============

      Wait_INPB                       
        MOV AL,0D0H                 
        OUT         64H,AL                  
    Wait_OUTB                               
    IN      AL,60H                  
    OR      AL,00000010B            
    MOV     BL,AL                   
    Wait_INPB                       
        MOV AL,0D1H                 
        OUT         64H,AL                          
    Wait_INPB                       
    MOV     AL,BL                           
    OUT     60H,AL  

    
Post 08 Feb 2008, 14:21
View user's profile Send private message Reply with quote
Polygon



Joined: 08 Feb 2008
Posts: 13
Location: Fire Island, NY
Polygon 08 Feb 2008, 14:29
I guess I'm a little confused....

I'm executing code from within the BIOS which is mostly executing 16bit code. I need to address memory mapped registers, so I need 4gig addressing. Are you saying enabling the A20 gives me 4gig addressing?
Post 08 Feb 2008, 14:29
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20300
Location: In your JS exploiting you and your system
revolution 08 Feb 2008, 14:32
edfed wrote:
but the best is not to switch in unreal mode, but in protected mode.
Ah, I am glad someone has "seen the light" and agrees with me on this. Yes, PM is not any more difficult to operate then FRM, and no undocumented tricks are required to run it.
Post 08 Feb 2008, 14:32
View user's profile Send private message Visit poster's website Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4330
Location: Now
edfed 08 Feb 2008, 14:53
the main problem with PM is the resident OS.
unlike RM, PM don't permitts to replace all the system.
under RM OSes, we can replace all, from IVT to BIOS, but, if we boot on PM, the question is absent, no need of DOS, WIN$ or linuX to boot.
and soon, no need of bios too. cause there are people that works on the direct PM switch. ad that is a good, really good step.

VESA is a RM service, with optional PM services. but it's crap, i dislike the vesa mechanism. really.
Post 08 Feb 2008, 14:53
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 08 Feb 2008, 14:56
Quote:
the main problem with PM is the resident OS.
unlike RM, PM don't permitts to replace all the system.

Actually that's the feature, not problem. Otherwise OS wouldn't have protection and would thus be unusuable for real desktop work.


Quote:
VESA is a RM service, with optional PM services. but it's crap, i dislike the vesa mechanism. really.

feel free to write bunch of drivers for all those graphic cards Razz
Post 08 Feb 2008, 14:56
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4330
Location: Now
edfed 08 Feb 2008, 15:02
yep, and yep.

i'm reading the datasheet of my S3 savageIX card... ouch, it's really hardcore... it support besenham algorithm, hardware bitmap rotation, etc...
pfiouuuuuu!!!!
Post 08 Feb 2008, 15:02
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20300
Location: In your JS exploiting you and your system
revolution 08 Feb 2008, 15:26
edfed wrote:
unlike RM, PM don't permitts to replace all the system.
Why do you think that? Just run yourself at ring 0 and replace whatever you want to replace. When you get the interrupt you can still switch back to RM to handle it and then again to PM. This is no different than FRM and doesn't need a trick to do it.
Post 08 Feb 2008, 15:26
View user's profile Send private message Visit poster's website Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4330
Location: Now
edfed 08 Feb 2008, 15:50
if the system is like XP, you cannot run at IOPL 0
in fact, i don't know, i don't code for win$
Post 08 Feb 2008, 15:50
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2, 3, 4, 5  Next

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.