Visualizzazione dei risultati da 1 a 2 su 2

Discussione: Programma bootable

  1. #1

    Programma bootable

    Ciao a tutti, non so se ho indovinato la sezione del forum, ma mi sembrava la più adatta.
    Da non molto ho intrapreso la via di programmare in Assembly sul pc, e mi sarebbe piaciuto molto fare un semplice programmino che partisse al boot del sistema e che stampasse qualcosa attraverso l'uso delle librerie del BIOS.
    Ho seguito una guida per farlo, che mi ha fatto eseguire FASM(Flat Assembler) producendomi un file .img (in realtà sarebbe un .bin con l'estensione modificata -.-").
    La guida diceva di caricare il file .img in Qemu(emulatore di processori) e vedere il risultato. Dopo vari tentativi non sono riuscito ad installare questo Qemu e volevo sapere se c'è un modo semplice per fare un boot da USB a questo punto direttamente dal mio pc.

    Il codice nella guida è questo:
    codice:
    use16	    ; 16-bit mode
    org 0x7C00	; this is the address of the boot sector
    
    BootStageOne:
        ;
        mov ah,0x00 ; reset disk
        mov dl,0	; drive number
        int 0x13	; call BIOS interrupt routine
        ;
        ; load the sector from disk using BIOS interrupt 0x13
        mov ah,0x02 ; read sectors into memory
        mov al,1	; number of sectors to read
        mov dl,0	; drive number
        mov ch,0	; cylinder number
        mov dh,0	; head number
        mov cl,2	; starting sector number
        mov bx,Main ; memory location to load to 
        int 0x13	; call BIOS interrupt routine
        ;
        jmp Main	; now that it's been loaded
        ;
    
    PadOutSectorOneWithZeroes:
        ; pad out all but the last two bytes of the sector with zeroes
        times ((0x200 - 2) - ($ - $$)) db 0x00
    
    BootSectorSignature:
        dw 0xAA55 ; these must be the last two bytes in the boot sector
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    org 0x7E00 ; the address of the sector after the boot sector
    
    Main:
    
        mov si,TextHelloWorld ; point the si register at the string to display
        mov ah,0x0E 	  ; for int 0x10: write chars in teletype mode
    
        ForEachChar:	  ; begin loop
    
    	lodsb		  ; load al with what si points to, increment si
    	cmp al,0x00	  ; if char is null...
    	je EndForEachChar ; .. then break out of the loop
    	int 0x10	  ; call interrupt 0x10 (BIOS: print char)
    
        jmp ForEachChar	  ; jump back to beginning of loop
        EndForEachChar:	  ; end of the loop
    
        ret 		  ; quit the program
    
        ; data to display
        TextHelloWorld: db 'Hello, world!',0
    
    PadOutSectorTwoWithZeroes:
        times ((0x200) - ($ - $$)) db 0x00
    Grazie in anticipo!

  2. #2
    Sono riuscito a metterlo su macchina virtuale, attraverso la emulazione del floppy
    Se però poi vorrei farlo partire dal mio pc, che programma posso usare per mettere l'img su pennina?? e se la masterizzo su cd/dvd anche riscrivibile va?

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.