flat assembler
Message board for the users of flat assembler.

Index > OS Construction > The REAL OS construction contest

Goto page Previous  1, 2, 3, 4, 5, 6, 7  Next
Author
Thread Post new topic Reply to topic
DJ Mauretto



Joined: 14 Mar 2007
Posts: 464
Location: Rome,Italy
DJ Mauretto 06 Mar 2009, 10:15
edfed wrote:
OK for no bios INT13h, but at least, does somebody have a ready to use driver non destructive?

it would be interresting to share a common driver for beginners like me.


OK i wrote a simply low level floppy sector loader for beginners like me Razz
Code:
;
;
; copyright (c) Mauro Di Cicco 
;
;
;=============================================================================
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; EQU ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;=============================================================================

OFFSET           EQU 
Stack_Seg       EQU  0000H              ; Stack Segment start
Stack_Off      EQU  7B00H              ; Stack OFFSET  start
Number_Sectors EQU  1                  ; Number Of Sectors To Load (Max 64)

;=============================================================================
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; MAIN ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;=============================================================================

ORG 7C00H

 CLI
 JMP     0000H:Start

Start:

       MOV     AX,Stack_Seg
        MOV     SS,AX
       MOV     AX,Stack_Off
        MOV     SP,AX
       XOR     AX,AX
       MOV     DS,AX

        XOR     BX,BX
  MOV     CX,Number_Sectors
@@:
        CALL    @Read_Sector            
    ADD     [Buffer],2
  MOV     AL,[Floppy_S]           
    ADD     AL,1
        CMP     AL,19
        SETNC   BL
 SBB     DL,DL                           
    AND     AL,DL                   
        ADD     AL,BL
   MOV     [Floppy_S],AL           
    ADD     DL,1                    
    MOV     AL,[Floppy_C]           
    ADD     AL,DL           
    CMP     AL,80   
    SBB     DL,DL                   
    AND     AL,DL
       MOV     [Floppy_C],AL           
    ADD     DL,1                    
    ADD     [Floppy_H],DL           
    SUB     CX,1
        JNZ     @B
                  
;=============
; Stop Motor
;=============

    MOV     DX,3F2H                 
    XOR     AL,AL           
    OUT     DX,AL                   
    STI
;==============
;     RUN
;==============

      
        JMP     0000H:7E00H         ; Run Smile


;=============================================================================
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Proc ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;=============================================================================

;=============================
; Read 1 Sector from Floppy
;=============================

@Read_Sector:

 PUSHA

;==============
; Disable DMA
;==============

        MOV     AL,14H                  ; Disable DMA
       OUT     8,AL                    ; Command Register

;===================
; Set Mode Transfer
;===================

   MOV     AL,46H                  ; Single mode, Address increment select, Write transfer, Channel 2 
 OUT     0BH,AL                  ; Mode Register

;==================
; Clear FlipFlop
;==================

   MOV     AL,-1                   ; Any Data
  OUT     0CH,AL                  ; Clear First/Last Flip-Flop 

;=====================
; Set Address Buffer
;=====================

   XOR     AL,AL
       OUT     4,AL                    ; Send Low Byte Address
     MOV     AL,[Buffer]             ; Offset Destination Buffer                     
    OUT     4,AL                    ; Send High byte Address
    XOR     AL,AL
       OUT     81H,AL                  ; Page 0

;==================
; Clear FlipFlop
;==================

  MOV     AL,-1                   ; Any Data
  OUT     0CH,AL                  ; Clear First/Last Flip-Flop

;=================
; 512 byte Please
;=================
           
    OUT     5,AL                    ; Send Low Byte Count
       NEG     AL                      
    OUT     5,AL                    ; Send High Byte Count

;====================
; Unmask Channel 2
;====================

      MOV     AL,010B                 ; bit   2 - Clear Mask bit
                                  ; bit 1:0 - Select channel 2  
  OUT     0AH,AL                  ; Mask Register

;=============
; Enable DMA
;=============

 MOV     AL,10H                  ; Enable DMA
        OUT     8,AL                    ; Command Register

;=============
; Read Sector
;=============

     MOV     AH,46H                  ; Read Sector 
      CALL    OUT_FDC         
    JC      @FDC_Error      

        MOV     AH,[Floppy_H]           ; Head
      SHL     AH,2                    ; Drive 00
  CALL    OUT_FDC         
    JC      @FDC_Error

      MOV     AH,[Floppy_C]
       CALL    OUT_FDC         
    JC      @FDC_Error

      MOV     AH,[Floppy_H]
       CALL    OUT_FDC         
    JC      @FDC_Error

      MOV     AH,[Floppy_S]
       CALL    OUT_FDC         
    JC      @FDC_Error

      MOV     AH,2                    ; Bytes per Sector 
 CALL    OUT_FDC         
    JC      @FDC_Error

      MOV     AH,12H                  ; Sector per Track
  CALL    OUT_FDC         
    JC      @FDC_Error

      MOV     AH,1BH                  ; Intersector gap Length
    CALL    OUT_FDC         
    JC      @FDC_Error

      MOV     AH,0FFH                 ; Data Length
       CALL    OUT_FDC         
    JC      @FDC_Error

;======================
; Wait End of Transfer
;======================

  XOR     CX,CX
@@:
    SUB     CX,1
        JZ      @Transfer_TimeOut

       IN      AL,8
        TEST    AL,100B                 ; Transfer Complete ?
       JZ      @B

;===================
; Read Result Phase
;===================

   MOV     BX,7                    
    MOV     DI,OFFSET Result_Phase  
@@:
 CALL    IN_FDC                  
    MOV     [DI],AL                 
    INC     DI                      
    SUB     BX,1
        JNZ     @B                      

        MOV     SI,OFFSET Result_Phase
      MOV     BX,OFFSET St_Number

;===============
; Status 0
;===============

   MOV     Byte [BX],'0'
     MOV     AL,[SI]
     TEST    AL,1100'0000B
      JNZ     @Status_ko

;===============
; Status 1
;===============

    MOV     Byte [BX],'1'
     MOV     AL,[SI+1]
   TEST    AL,10110111B
        JNZ     @Status_ko

;===============
; Status 2
;===============

    MOV     Byte [BX],'2'
     MOV     AL,[SI+2]
   TEST    AL,00110110B
        JNZ     @Status_ko

      POPA
        RET

OUT_FDC:

 XOR     CX,CX
       MOV     DX,3F4H                 ; Main Status Register
@@:
   IN      AL,DX                   ; Read Status
       AND     AL,1100'0000B
      CMP     AL,1000'0000B
      LOOPNZ  @B              
    JNZ     @FDC_TimeOut
        
    INC     DX                      
    MOV     AL,AH                   
    OUT     DX,AL                   ; Write data

    TEST    AL,AL                   ; Clear Flag Carry
  RET

IN_FDC:

  XOR     CX,CX
       MOV     DX,3F4H                 ; Main Status Register
@@:
   IN      AL,DX                   ; Read Status
       AND     AL,1100'0000B
      CMP     AL,1100'0000B          ; 
  LOOPNZ  @B      
    JNZ     @FDC_TimeOut
                
    INC     DX                      
    IN      AL,DX                   ; Read Data

     TEST    AL,AL                   ; Clear Flag Carry
  RET

@FDC_TimeOut:    

        STC
 RET

@Transfer_TimeOut:

       MOV     DX,3F2H                 
    XOR     AL,AL           
    OUT     DX,AL   

        MOV     SI,OFFSET Transfer_ko
       CALL    @Bios_TTY
@@:
        STI
 HLT
 JMP     @B

@FDC_Error:

       MOV     DX,3F2H                 
    XOR     AL,AL           
    OUT     DX,AL   

        MOV     SI,OFFSET FDC_ko
    CALL    @Bios_TTY
@@:
        STI
 HLT
 JMP     @B

@Status_ko:

       MOV     DI,OFFSET Stat_AL
   MOV     BL,30H
      MOV     CL,8
@@:
     XOR     DL,DL
       SHL     AL,1
        ADC     DL,BL
       MOV     [DI],DL
     INC     DI
  SUB     CL,1
        JNZ     @B
  
    MOV     SI,OFFSET Status
    CALL    @Bios_TTY

       MOV     DX,3F2H                 
    XOR     AL,AL           
    OUT     DX,AL   
@@:
 STI
 HLT
 JMP     @B

;=====================
; Bios Tele Type Out
;=====================

@Bios_TTY:

        LODSB
       TEST    AL,AL
       JZ      @F

      MOV     BX,0007H                ; BH = Page Number  BL = Color
      MOV     AH,0EH                  ; Teletype output
   INT     10H                     ; Bios Video
        JMP     @Bios_TTY
@@:

    RET

;=============================================================================
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DATA ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;=============================================================================

Buffer             DB 7EH
Floppy_C      DB 0            ; Cylinder
Floppy_H  DB 0            ; Head
Floppy_S      DB 2            ; Sector
Result_Phase        DB 7 dup (0)

FDC_ko              DB "FDC Time-out",0
Transfer_ko    DB "DMA Time-out",0
Status         DB "Status "
St_Number     DB " "
            DB " Error",13,10
         DB "AL = "
Stat_AL         DB 8 dup (?),13,10,0


Padding         RB 1FEH -($-$$)         ; $= Local Offset, $$= Base Offset(7C00H) 
Boot      DW 0AA55H


;=============
; Sector 2
;=============

     MOV     SI,OFFSET Hello_Mess
        CALL    @Bios_TTY2

@@:
   STI
 HLT
 JMP     @B

;=====================
; Bios Tele Type Out
;=====================

@Bios_TTY2:

       MOV     AL,[SI] 
    ADD     SI,1
        TEST    AL,AL
       JZ      @F

      MOV     BX,0007H                ; BH = Page Number  BL = Color
      MOV     AH,0EH                  ; Teletype output
   INT     10H                     ; Bios Video
        JMP     @Bios_TTY2
@@:

   RET


Hello_Mess       DB "Hello From Sector 2",0    

_________________
Nil Volentibus Arduum Razz


Last edited by DJ Mauretto on 06 Mar 2009, 14:51; edited 1 time in total
Post 06 Mar 2009, 10:15
View user's profile Send private message Reply with quote
MazeGen



Joined: 06 Oct 2003
Posts: 977
Location: Czechoslovakia
MazeGen 06 Mar 2009, 10:28
revolution wrote:
no new registrants may vote (to stop vote stuffing, okay)

How can you achieve that? Will we vote by regular posting to a particular thread?
Post 06 Mar 2009, 10:28
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: 20309
Location: In your JS exploiting you and your system
revolution 06 Mar 2009, 10:38
I expect the voting to be quite informal. I doubt a simple vote-for-one scheme would work if the phpBB forum voting system was used.
Post 06 Mar 2009, 10:38
View user's profile Send private message Visit poster's website Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4330
Location: Now
edfed 06 Mar 2009, 12:22
i think the vote should be made by a jury.
composed by 256 selected users?

and then, give these users the right to vote to a poll somewhere.

is it possible stuff?
Post 06 Mar 2009, 12:22
View user's profile Send private message Visit poster's website Reply with quote
MazeGen



Joined: 06 Oct 2003
Posts: 977
Location: Czechoslovakia
MazeGen 07 Mar 2009, 15:44
revolution, is there any prize for the winner?
Post 07 Mar 2009, 15:44
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: 20309
Location: In your JS exploiting you and your system
revolution 07 Mar 2009, 16:09
MazeGen wrote:
revolution, is there any prize for the winner?
Oh yes of course. The kudos from fellow forum members should be enough but I also offer a small extra prize of one star for the winner.

And remember that everyone that enters is a winner just for meeting the deadline so no one really loses.
Post 07 Mar 2009, 16:09
View user's profile Send private message Visit poster's website Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4330
Location: Now
edfed 13 Mar 2009, 00:26
i post the link to the page where to load my package update. because it would be interrseting for who wants to participate but don't know if it is easy to win.

http://board.flatassembler.net/topic.php?p=87567#87567
if nobody post best, i'll win! Smile but not now because it uses int10h and int13h for the moment.
the os is only comsys.inc. the rest is the rest, for test under dos.
Post 13 Mar 2009, 00:26
View user's profile Send private message Visit poster's website Reply with quote
BigLew



Joined: 05 Jun 2009
Posts: 1
BigLew 05 Jun 2009, 09:24
has this competition gone ahead???
Post 05 Jun 2009, 09:24
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20309
Location: In your JS exploiting you and your system
revolution 05 Jun 2009, 09:48
Yes, it is happening now. You are welcome to participate.
Post 05 Jun 2009, 09:48
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: 20309
Location: In your JS exploiting you and your system
revolution 11 Jun 2009, 06:47
Just 75 days remaining. You should have long ago finished the design and layout of your OS. Coding and things should be well underway by now. Indeed, I expect you should be nearing the testing phase.
Post 11 Jun 2009, 06:47
View user's profile Send private message Visit poster's website Reply with quote
bitshifter



Joined: 04 Dec 2007
Posts: 796
Location: Massachusetts, USA
bitshifter 13 Jun 2009, 10:44
I was working on my entry for Micro-OS contest but it seems dead?
Maybe i should have spent all that time participating in this one...
The only problem is my experience is limited to 16 bit BIOS driven.
Oh well, at least i get to study these entries when the time comes.
Post 13 Jun 2009, 10:44
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20309
Location: In your JS exploiting you and your system
revolution 13 Jun 2009, 11:39
bitshifter: I think Coddy41 still visits occasionally, so you might still want to enter the micro-OS contest. Although, the rules there seem to change quite frequently so it is possible that the end date will be extended again for that one.

However, to all, the end date for this contest will not be changing. If you miss the deadline then you won't be able to enter. Hehe, I am a being tough for this one, the closing date is REAL also.
Post 13 Jun 2009, 11:39
View user's profile Send private message Visit poster's website Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2465
Location: Bucharest, Romania
Borsuc 13 Jun 2009, 23:38
I have a question even though I have nothing to do with this nice competition. Isn't the BIOS like some low-level driver for your motherboard? How will you be able to test a code if it will only work for a specific motherboard or a specific configuration?

Also isn't it somewhat (if not impossible) difficult to make a disk driver in 512 bytes?
Post 13 Jun 2009, 23:38
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20309
Location: In your JS exploiting you and your system
revolution 14 Jun 2009, 01:27
Borsuc: Basically, yes, you are correct, but there are still many common things that mobo hardware does.

Also, what sort of disk driver are you asking about? Floppy? USB? HDD? CD?

And anyway, what sort of competition would if be if it didn't pose some sort of difficulty? With everything easy then there is no competition, just 1000 entries all the same.
Post 14 Jun 2009, 01:27
View user's profile Send private message Visit poster's website Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2465
Location: Bucharest, Romania
Borsuc 15 Jun 2009, 01:10
Oh my bad, I thought it was supposed to be a generic disk driver lol that's why I thought it would be impossible Laughing

_________________
Previously known as The_Grey_Beast
Post 15 Jun 2009, 01:10
View user's profile Send private message Reply with quote
neville



Joined: 13 Jul 2008
Posts: 507
Location: New Zealand
neville 29 Jul 2009, 06:45
revolution, when's the deadline for entries?

_________________
FAMOS - the first memory operating system
Post 29 Jul 2009, 06:45
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: 20309
Location: In your JS exploiting you and your system
revolution 08 Aug 2009, 20:58
25-Feb-2009 + 6 months.

So the deadline is coming up fast.
Post 08 Aug 2009, 20:58
View user's profile Send private message Visit poster's website Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4330
Location: Now
edfed 10 Aug 2009, 21:59
sorry sorry.

but just imagine a real os contest:

the principle will be the disponibility of coders, and as i know, coders are mainly disponible in winter, more exactlly, when you are full of emotions and dreams about a better world, then, i propose to change the dates of the contest.
Code:
month           motivation               useage
             0%             100%
january        OOOOOOOOOOOOO           coding
february       OOOOOOOOOOOO            coding
mars           OOOOOOOOOO              coding
april          OOOO                    changing
may            OO                      no code
june           O                       no code
july           OO                      no code
august         O                       no code
september      OOOOOO                  coding
october        OOOOOOOOOOOO            coding
november       OOOOOOOOOOOOOOOOOOO     coding
december       OOOOOOOOOOOOO           coding
                    


start in automn. for example, the 29th october 2009.
end in spring. for example, the 1st april 2010 (fool day Smile)

what do you think of it?

and now i return to my occupations. Smile bye bye!
Post 10 Aug 2009, 21:59
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: 20309
Location: In your JS exploiting you and your system
revolution 19 Aug 2009, 13:35
This competition will end at 25-August-2009 0508 GMT, 6 months after the announcement.

With so little talk lately I hope that means that some of you are busy coding and testing it with no time to post here.

So anyhow, currently there are no submissions. If at the closing time you are the only entrant then you will win by default. Good luck.
Post 19 Aug 2009, 13:35
View user's profile Send private message Visit poster's website Reply with quote
Rahsennor



Joined: 07 Jul 2007
Posts: 61
Rahsennor 24 Aug 2009, 00:36
I have an entry.
Sorry for lurking! Embarassed


Description:
Download
Filename: Tea-7a.7z
Filesize: 11.09 KB
Downloaded: 315 Time(s)

Post 24 Aug 2009, 00:36
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2, 3, 4, 5, 6, 7  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.