?

Log in

No account? Create an account
June 27th, 2009 - Sarah's Blog — LiveJournal [entries|archive|friends|userinfo]
Sarah

[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

June 27th, 2009

Someone with too much time on their hands... [Jun. 27th, 2009|09:01 am]
Sarah
“I do not know where family doctors acquired illegibly perplexing handwriting, nevertheless, extraordinary pharmaceutical intellectuality, counterbalancing indecipherability, transcendentalizes intercommunications incomprehensibleness”.

This is the longest sentence in the English language in which the Nth word contains N letters.
The shortest is possibly "I am."
linkpost comment

Boot disk x86 programming! [Jun. 27th, 2009|09:50 am]
Sarah
I've found some assembly for Fasm, that writes a file to the boot sector of a floppy.
As it is written to the first sector on the floppy - it looks empty. =)
It's a command line program, if you called it "makeboot.asm", and compiled to a COM file, you'd use it like:

makeboot myLittleProgram.com

I don't have a floppy drive on my computer.
So here I'm using VMWare with XP Pro and a virtual floppy to write the boot sector, some may say that's overkill:


Here's the boot writer:
;write boot sector to CHS sector 0,0,1 of drive A:, preserving boot record
;information

        org     100h

;scan command line for a file name
        mov     ch,01h
        mov     di,81h
        mov     al,' '
        repe    scasb
        lea     dx,[di-1]
        dec     di
        mov     al,13
        repne   scasb
        mov     byte [di-1],0

;open the file
        mov     ax,3D00h
        int     21h
        jc      quit

        xchg    bx,ax

;read boot sector from it
        mov     ah,3Fh
        mov     cx,512
        mov     dx,sektor
        int     21h
        jc      quit

;read the original boot sector from floppy
        mov     bp,3

        mov     cx,0001h
        xor     dx,dx    ;mov    dx,cx for drive B:
        mov     bx,original

read_retry:
        mov     ax,0201h
        int     13h
        jnc     read_ok

        xor     ah,ah
        int     13h

        dec     bp
        jnz     read_retry

        retn

read_ok:
        mov     si,original+0Bh
        mov     di,sektor+0Bh
        mov     cl,28
        rep     movsb

        mov     bp,3
        mov     cx,0001h
        mov     bx,sektor

write_retry:
        mov     ax,0301h
        int     13h
        jnc     quit

        xor     ah,ah
        int     13h

        dec     bp
        jnz     write_retry

quit:
        retn
original        rb 512
sektor          rb 512

This is a small demo program that's changes to the simple graphics mode, and writes funky colours to the screen (I found it only -ahem-, but added my own comments).
I've set the output as "Com" just so I can run it from Windows without renaming it.
If it's compiled to myLittleProgram.com, you can then write this to the boot sector of a floppy with the above program.

30 bytes big!

I'm using a really low spec-virtual x86 machine, with a blank hard disk to do the boot test. It's connected to the same virtual floppy file the XP virtual machine above is using. The graphics program work in Windows, but it's very satisfying to see it appear after the BIOS screen on the PC:


   format binary as "com"

  ;Change the video mode to 13h
    xor      ah, ah         ;VIDEO Function 00h: Change screen
    mov      al, 13h        ;Put the desired graphics mode into AL
    int      10h            ;Call video interrupt

  ;es=Video RAM
  ;bx=0
  ;cl=0
    mov ax,0A000h
    mov es,ax               ;es is now the pointer to the start of video RAM
    xor bx,bx
    xor cl,cl               ;Clear bx, and cl registers

  ; Main loop
@main:
  ;Spin the colour
    inc cl
    rol cx,1                ;Increment pixel colour, rotate it left 1 bit

  ;Plot [Video RAM + bx], cl
    inc bx                  ;Inceremnt pixel offset
    mov [es:bx],cl          ;Plot pixel to screen

  ; Check for Escape key
    in   al,60h             ;Read keyboard input
    dec  al                 ;Subtract 1
    jnz  @main              ;Loop program if Escape wasn't pressed

    ret


If you need more than 500 Bytes (whatever for!?), this is a Fat12 Bootstrap loader that you write to the disk using makeboot.com(above), near the bottom of the program BASECODE is the name of the file on the floppy to continue loading.
It can be used for bigger programs (up to 640ishK)Collapse )

Edit::
Ah, I can't write the graphics program directly to the boot sector. =(
I have to use bootmaker, and add the graphics file as a standard file named "boot", as it looks like the boot writer program puts certain values on the disk so the OS knows it's a boot disk.
link3 comments|post comment

navigation
[ viewing | June 27th, 2009 ]
[ go | Previous Day|Next Day ]