flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Generic Boot and then 2nd file execute with FLOPPY or CD.

Goto page Previous  1, 2, 3  Next
Author
Thread Post new topic Reply to topic
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17662
Location: In your JS exploiting you and your system
revolution
janequorzar wrote:
I actually am writing TWO OSs. The reason is because one of them is from the famous TV show Star Trek. I am making an OS based off their LCARS interface just like I did back in 2000.
Why do you need a separate OS just to change the interface?

Looks to me like you are trying to make the interface part of the OS. Perhaps you should reconsider the basic design of your OS.
Post 25 Sep 2010, 23:44
View user's profile Send private message Visit poster's website Reply with quote
janequorzar



Joined: 11 Sep 2010
Posts: 60
janequorzar
revolution wrote:
janequorzar wrote:
I actually am writing TWO OSs. The reason is because one of them is from the famous TV show Star Trek. I am making an OS based off their LCARS interface just like I did back in 2000.
Why do you need a separate OS just to change the interface?

Looks to me like you are trying to make the interface part of the OS. Perhaps you should reconsider the basic design of your OS.


LCARS is an interface from the TV show that I am not allowed to sell. The other one is original but both use the same base code. The difference is the one I can sell, is not taken from anyone else work. The one I can sell, will have more customizations that the LCARS one will not do to the fact that its an LCARS only OS.

The LCARS one is basically a Novelty item that trek lovers will love around the world. Trust me, it will go over big, LCARS has a Huge following.
Post 26 Sep 2010, 01:39
View user's profile Send private message Reply with quote
nop



Joined: 01 Sep 2008
Posts: 165
Location: right here left there
nop
hi again janequorzar sorry but what is it about lcars that makes it necessary to be an os? im probably ignorant but isnt it mainly a style thing so why not just an application?
Post 26 Sep 2010, 08:15
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 3043
Location: vpcmipstrm
bitRAKE
I was feeling creative...
Code:
{updated several posts down}    
I could only get version 0.11 of QEMU to work -- newer versions would not correctly load more than 7 sectors without freezing. No testing done on actual hardware. Having it all in one file makes testing easy.


Last edited by bitRAKE on 03 Oct 2010, 02:34; edited 1 time in total
Post 26 Sep 2010, 10:30
View user's profile Send private message Visit poster's website Reply with quote
egos



Joined: 10 Feb 2009
Posts: 144
egos
Back to original theme Smile

I have more progressive boot technology and sources for fasm to make floppy and CD images (it's true). Just don't say to MS (it's joke). Do you want to know about it?
Post 26 Sep 2010, 12:50
View user's profile Send private message Reply with quote
janequorzar



Joined: 11 Sep 2010
Posts: 60
janequorzar
nop wrote:
hi again janequorzar sorry but what is it about lcars that makes it necessary to be an os? im probably ignorant but isnt it mainly a style thing so why not just an application?


We love its design. Its not about the OS really, but more about HOW it was designed. We truly love its interface. The other thing is, no one yet has done it. Sure they have made the GUI of it but on top of someone else's framework. AND I am using it as my test grounds for the REAL OS I am working on.

egos wrote:
Back to original theme Smile

I have more progressive boot technology and sources for fasm to make floppy and CD images (it's true). Just don't say to MS (it's joke). Do you want to know about it?


Sure bring it on.. I love to see new technology and creative ideas. Its why I love programming languages. People can be as creative as they want. Smile


bitRAKE wrote:
I was feeling creative...
Code:
format binary as "img"

; although beginning at address $7C00 it is not possible to know how every
; BIOS has chosen to segment CS:IP - could be $7C0:0 thru 0:$7C00.
org 0
STAGE0:

; The choice of ES:BX for INT13/02 is important to get STAGE1.Entry aligned
; to STAGE0.Exit -- this is irrespective of memory needed by STAGE1.

        mov ax,$0200 + STAGE1.sectors   ; read 130,560 bytes or less
        mov cx,$0002                    ; CHS: 0/0/2
        mov dh,$00                      ; DL from BIOS Boot Specification/BAID
        mov bx,STAGE1.offset
        push STAGE1.segment
        pop es
        int $13                         ; Read Disk Sector(s) into Memory
.Exit:

; this code only executes when an error occurs
        push $7C0
        pop ds
        mov si,.Error
        mov cx,.Error..
@@:     lodsb
        mov ah,$0E                      ; Teletype Output
        mov bh,$00
        int $10
        loop @B

        xchg ax,cx                      ; Get Keystroke
        int $16

        int $19                         ; return to bootstrap loader
.Error \ ;  0123456789012345678901234567890123456789
        db 13,10,7
        db "Rather than silently hide the negative",13,10
        db "result which just occured, this message",13,10
        db "attempts to amuse the naive and inform",13,10
        db "the weary. The plain fact that execution",13,10
        db "did not proceed beyond the boot sector",13,10
        db "should now be most present in your mind.",13,10
        db 13,10
        db "--->   -->  -> > ERROR! < <-  <--   <---",13,10
        db 13,10,7
        db "Silly. I know.",13,10
        db "Some people need an alarmist display.",13,10
.Error.. = $ - .Error

        rb $$+510-$
        dw $AA55


org STAGE1.offset
STAGE1:



  .GoodTest \
        db "Everything happened like something",13,10
        db "important was going to happen.",13,10
  .GoodTest.. = $ - .GoodTest


  rb 512*37


  .load = $7C00 - ($ - $$) + (STAGE0.Exit - STAGE0)
  .segment = .load shr 4
  .offset = .load and $F
  .Entry:
        push STAGE1.segment
        pop ds
        mov si,.GoodTest
        mov cx,.GoodTest..
@@:     lodsb
        mov ah,$0E                      ; Teletype Output
        mov bh,$00
        int $10
        loop @B

        xchg ax,cx                      ; Get Keystroke
        int $16

        int $19                         ; return to bootstrap loader



;  .. = $ - STAGE1
  .sectors = ($ - STAGE1 + 511)/512
  if .sectors > 255
    display "ERROR: Second stage is too large!",13,10
  end if

  ; pad to floppy size
  db 80*2*2*9*512 - ($-$$) - 512 dup (-1)    
I could only get version 0.11 of QEMU to work -- newer versions would not correctly load more than 7 sectors without freezing. No testing done on actual hardware. Having it all in one file makes testing easy.


Although I have to say thats pretty slick, it doesn't go past the warning message, even when I put it on a floppy and rebooted my machine. And i'm not trying to be negative about your creativity, but try splitting it up to two files and then have the first one call the second. Its pretty neat though so don't give up.. I want to see more of your work. Smile
Post 26 Sep 2010, 13:13
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 3043
Location: vpcmipstrm
bitRAKE
Removing the " rb 512*37 " line would prolly fix it. I'm thinking the real BIOS's don't have consistent support for multi-sector reads with INT13/02. With LBA modes the progression through the media is consistent - that's why the extended read function is used.
Post 26 Sep 2010, 13:33
View user's profile Send private message Visit poster's website Reply with quote
janequorzar



Joined: 11 Sep 2010
Posts: 60
janequorzar
bitRAKE wrote:
Removing the " rb 512*37 " line would prolly fix it. I'm thinking the real BIOS's don't have consistent support for multi-sector reads with INT13/02. With LBA modes the progression through the media is consistent - that's why the extended read function is used.


yes that worked. I tried it a second time and it came up that time.
Post 26 Sep 2010, 13:37
View user's profile Send private message Reply with quote
janequorzar



Joined: 11 Sep 2010
Posts: 60
janequorzar
Now can you make that generic so its not only on a floppy ? I noticed your pulling in the "current" drive, but I also noticed your setting it up for floppy only.

Code:
;  .. = $ - STAGE1 
  .sectors = ($ - STAGE1 + 511)/512 
  if .sectors > 255 
    display "ERROR: Second stage is too large!",13,10 
  end if 

  ; pad to floppy size 
  db 80*2*2*9*512 - ($-$$) - 512 dup (-1)
    


I would figure since its one file, that it would be kind of hard to know where this code is going to end up. Either on floppy, CD or HD.

Of course, if you take that code out, it could be made to be generic I suppose.. Great work by the way !!!!!
Post 26 Sep 2010, 13:44
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 3043
Location: vpcmipstrm
bitRAKE
It would be as simple as changing a comment line, or adding an IF statement. Depends on how the final product is being used and the degree of automation desired. Ideally, there would be a setting for each supported output format: floppy, iso, hd image, vhd, etc...

Testing worked well in latest version of Boch.

I've a couple other creative bootsectors in this thread.
Post 26 Sep 2010, 13:59
View user's profile Send private message Visit poster's website Reply with quote
janequorzar



Joined: 11 Sep 2010
Posts: 60
janequorzar
bitRAKE wrote:
It would be as simple as changing a comment line, or adding an IF statement. Depends on how the final product is being used and the degree of automation desired. Ideally, there would be a setting for each supported output format: floppy, iso, hd image, vhd, etc...

Testing worked well in latest version of Boch.

I've a couple other creative bootsectors in this thread.


Awesome stuff there. Very Happy
Post 26 Sep 2010, 14:11
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 3043
Location: vpcmipstrm
bitRAKE
I got up to take a pee, and when I came back this was done:
Code:
format binary as "img"

; although beginning at address $7C00 it is not possible to know how every
; BIOS has chosen to segment CS:IP - could be $7C0:0 thru 0:$7C00.

        org $7C00 - (16*STAGE0.Error..) ; trick to save a byte
STAGE0:

; The choice of ES:BX for INT13/02 is important to get STAGE1.Entry aligned
; to STAGE0.Exit -- this is irrespective of memory needed by STAGE1.

        push STAGE1.SEG
        mov bx,STAGE1.OFF
        mov ax,$0200 + STAGE1.SECTORS   ; read 130,560 bytes or less
        mov cx,$0002                    ; CHS: 0/0/2
        mov dh,ch                       ; DL from BIOS Boot Specification/BAID
        pop es
        int $13                         ; Read Disk Sector(s) into Memory
.Exit:
        ; this code only executes when an error occurs

        cld                             ; maybe needed?
        mov si,.Error
        mov cx,.Error..
        mov ds,cx                       ; trick to save a byte
@@:     lodsb
        mov ah,$0E
        mov bh,$00
        int $10                         ; Teletype Output
        loop @B
        xchg ax,cx
        int $16                         ; Get Keystroke
        int $19                         ; Return to Bootstrap Loader

.Error \ ;  0123456789012345678901234567890123456789
        db 13,10
        db "Rather than silently hide the negative",13,10
        db "result which just occured, this message",13,10
        db "attempts to amuse the naive and inform",13,10
        db "the weary. The plain fact that execution",13,10
        db "did not proceed beyond the boot sector",13,10
        db "should now be most present in your mind.",13,10
        db 13,10
        db "--->   -->  -> > ERROR! < <-  <--   <---",13,10
        db 13,10
        db "Silly. I know.",13,10
        db "Some people need an alarmist display.",13,10
.Error.. = $ - .Error


        db $ and 1 dup 0 ; same as align 2
        dw (512-$+$$)/2 dup $AA55 ; pattern fill
;###############################################################################
;###############################################################################

org $1000
STAGE1:
        lss sp,[cs:.Entry+1]            ; set SS:SP
        cld
        push cs
        push cs
        pop ds
        pop es

        mov ax,$4F00
        mov di,.vBuf
        int $10                         ; Detecting VESA
        cmp ax,$004F
        jz  .VESA.Good

        mov si,.badVESA
        call .Print_DS_SI

        xor si,si
@@:     mov cx,256/16
        call .Print_Dump

        mov ah,$00                      ; Get Keystroke
        int $16
        jmp @B

        .badVESA db 'VESA: it no workie!',13,10,0

.VESA.Good:

        mov eax,dword [.vBuf]
        mov [.A],eax

        mov ax,[.vBuf.Version]
        add [.B],ah
        add [.B+2],al

        mov si,.dvbeib
        call .Print_DS_SI

        lds si,[.vBuf.OEMStringPtr]
        call .Print_DS_SI
        push cs
        pop ds
        mov si,.crlf
        call .Print_DS_SI

        lds si,[.vBuf.OEMVendorName]
        call .Print_DS_SI
        push cs
        pop ds
        mov si,.crlf
        call .Print_DS_SI

; decode flags and modes

        mov ah,$00                      ; Get Keystroke
        int $16
        mov ah,$00                      ; Get Keystroke
        int $16
        xor si,si
        jmp @B


.dvbeib:db "Dumping VBE InfoBlock",13,10
        db "---------------------",13,10
        db "Signature: "
.A:     db "xxxx",13,10
        db "Version:    "
.B:     db "0.0"
.crlf   db 13,10,0


        align 16
.vBuf                   db 'VBE2' ; 'VESA','VBE2'
.vBuf.Version           dw ?
.vBuf.OEMStringPtr      dd ?
.vBuf.Capabilities      dd ?
.vBuf.VideoModePtr      dd ?    ; seg:off
.vBuf.TotalMemory       dw ?    ; 64k blocks
  ; Added for VBE 2.0
.vBuf.OEMSoftwareRev    dw ?
.vBuf.OEMVendorName     dd ?
.vBuf.OEMProductName    dd ?
.vBuf.OEMProductRevPtr  dd ?
                        db 222 dup 0
.vBuf.OEMData           db 256 dup 0


;###############################################################################
        db $7C00 + (STAGE0.Exit - STAGE0) - $ dup -1
;###############################################################################
;  .LOAD = $7C00 - ($ - $$) + (STAGE0.Exit - STAGE0)
  .LOAD = $1000
  .SEG = 0
  .OFF = $1000
  .Entry:
        jmp .SEG:STAGE1            ; set preferred CS:IP


;========================
; SOME LIBRARY FUNCTIONS:
;------------------------

@@:     mov ah,$0E
;        mov bh,$00
        int $10                         ; Teletype Output
.Print_DS_SI:
        lodsb
        test al,al
        jnz @B
        retn

.Print_DS.SI:                           ; Print Segmented Address
        mov ax,ds
        call .Print_AX
        mov ax,$0E00 + ':'
;        mov bh,$00
        int $10                         ; Teletype Output
        mov ax,si
.Print_AX:                              ; Print Hex Word
        xchg al,ah                      ; high byte first
        call .Print_AL
        rol ax,4
.Print_AL:                              ; Print Hex Byte
        call @F
        rol ax,4
@@:     push ax
        shr al,4
        cmp al,$0A
        sbb al,$69
        das 
        mov ah,$0E
;        mov bh,$00
        int $10                         ; Teletype Output
        pop ax
        retn


; ssss:oooo   00 11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF   0123456789ABCDEF
; Display CX paragraphs starting at DS:SI
.Print_Dump:
        push cx
        call .Print_DS.SI

        mov ax,$0E00 + ' '
        int $10                         ; Teletype Output
        mov ax,$0E00 + '|'
        int $10                         ; Teletype Output
        mov ax,$0E00 + ' '
        int $10                         ; Teletype Output

        mov cx,16
@@:     lodsb
        call .Print_AL
        mov ax,$0E00 + ' '
;        mov bh,$00
        int $10                         ; Teletype Output
        loop @B

        mov ax,$0E00 + '|'
        int $10                         ; Teletype Output
        mov ax,$0E00 + ' '
        int $10                         ; Teletype Output

        push si
        std
        lodsb
        mov cx,16
@@:     lodsb
        mov bx,$0004
        mov ah,$09
        int $10                         ; Teletype Output
        loop @B
        cld
        pop si

        mov ax,$0E00 + 13
        int $10                         ; Teletype Output
        mov ax,$0E00 + 10
        int $10                         ; Teletype Output

        pop cx
        loop .Print_Dump

        retn





  .SECTORS = ($ - STAGE1 + 511)/512
  if .SECTORS > 255
    display "ERROR: Second stage is too large!",13,10
  end if

  ; pad to floppy size
  db 80*2*2*9*512 - ($-$$) - 512 dup (-1)    
...play on. I'm switching back to EDD (Enhanced Disk Device) loading in the boot sector: the only consistent multi-sector loading, imho. Well, documented and standardized.
Post 03 Oct 2010, 02:32
View user's profile Send private message Visit poster's website Reply with quote
janequorzar



Joined: 11 Sep 2010
Posts: 60
janequorzar
That is some awesome code. I noticed your using a ton of interrupts. I have been working on my OS to use as few interrupts as possible. I am working on writing routines that replace having to use them. Got a few of them done. I'm currently working on the routine that talks directly to video ram. In this way, I can run this in 16 Bit all the way up to 64 Bit mode without worry. All I have to do is write it for the mode i'm in.

I have decided to go this rout to get the OS done by making a library first. When I realized I would have to write this one driver, it dawned on me I should have started this part of the project first.
Post 03 Oct 2010, 12:09
View user's profile Send private message Reply with quote
janequorzar



Joined: 11 Sep 2010
Posts: 60
janequorzar
bitRAKE - I was going over your code and compiled it.. It comes up. But again, I get that error message that should not show up. I'm working on tracking the problem right now.

UPDATE : Hmmm i'm stumped. It looks like it should work. It does a check if VESA is there and then prints the results. I see what its trying to do, but for some reason it defaults back to the error and will not print the results. I'm going to take a break and come back to this. Could be that i'm tired from working an 18+ hour shift.
Post 04 Oct 2010, 14:10
View user's profile Send private message Reply with quote
bitshifter



Joined: 04 Dec 2007
Posts: 764
Location: Massachusetts, USA
bitshifter
Where to go after success?
Code:
int $13                         ; Read Disk Sector(s) into Memory
jnc STAGE1.SEG:STAGE1.OFF    ; Continue if no errors...
    

I didnt try to compile (label may be too far for jcc)
push push retf would do it also...
Post 05 Oct 2010, 13:12
View user's profile Send private message Reply with quote
janequorzar



Joined: 11 Sep 2010
Posts: 60
janequorzar
bitshifter wrote:
Where to go after success?
Code:
int $13                         ; Read Disk Sector(s) into Memory
jnc STAGE1.SEG:STAGE1.OFF    ; Continue if no errors...
    

I didnt try to compile (label may be too far for jcc)
push push retf would do it also...


Yea I thought about that also. I tried to correct it.. but it still didn't work.
Post 05 Oct 2010, 13:38
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 3043
Location: vpcmipstrm
bitRAKE
JNC isn't the instruction in the listing - it's JMP. It seems to work in QEMU 1.1, but is broke elsewhere. Maybe the sectors aren't loaded completely. That is why I switched to EDD.
Post 05 Oct 2010, 17:29
View user's profile Send private message Visit poster's website Reply with quote
janequorzar



Joined: 11 Sep 2010
Posts: 60
janequorzar
bitRAKE wrote:
JNC isn't the instruction in the listing - it's JMP. It seems to work in QEMU 1.1, but is broke elsewhere. Maybe the sectors aren't loaded completely. That is why I switched to EDD.


Something I noticed is that QEMU doesn't work half the time for a lot of people. I use Virtual Box and QEMU at the same time. If one doesn't work the other sometimes does. If both work then I know I did it right. So I try to make my stuff so that BOTH work and that is how I know its working properly.
Post 05 Oct 2010, 18:18
View user's profile Send private message Reply with quote
bitshifter



Joined: 04 Dec 2007
Posts: 764
Location: Massachusetts, USA
bitshifter
Sorry i didnt have much time before...
Does this not work the way i expect?
Code:
...
int 13h
jc .Exit
push STAGE1.SEG
push STAGE1.OFF
retf

.Exit:
...    
Post 05 Oct 2010, 23:57
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 3043
Location: vpcmipstrm
bitRAKE
No, that will not work because the trick baldr suggests is being used -- the boot sector is being overwritten by the INT 19! This saves the needed code to relocate the boot sector. Really, this is just playing around - better solutions exist.
Post 06 Oct 2010, 00:04
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  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-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.