Re: How to make a real stand-alone system?
Posted: Mon Mar 04, 2013 6:42 pm
Hi,
Now all we need is for someone to add comments, so that it's easy to see how bad this code actually is.
Cheers,
Brendan
Doing it right (e.g. following every call or jmp to determine what is/isn't executed) is a massive pain in the neck - I should know:dozniak wrote:You do realise that you've posted mostly wrong crap? Not everything in the bootsector is code, x86 assembly might look totally different if you accidentally start disassembling at the wrong offset.m12 wrote:ndisasm -b [16, 32, 64] file > out.lst
Code: Select all
00007C00 EB64 jmp short 0x7c66
00007C00 90 42 77 74 53 65 63 4f 53 76 62 72 29 7c | .BwtSecOSvbr)||
00007C10 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00007C20 00 00 00 00 00 00 00 00 00 00 7e 00 01 02 11 00 |..........~.....|
00007C30 a0 01 01 01 12 00 c4 00 02 01 12 00 e8 01 02 01 |................|
00007C40 0c ff |.. |
00007C42 E464 in al,0x64
00007C44 2401 and al,0x1
00007C46 7506 jnz 0x7c4e
00007C48 33C9 xor cx,cx
00007C4A E2FE loop 0x7c4a
00007C4C EBF4 jmp short 0x7c42
00007C4E B501 mov ch,0x1
00007C50 E2FE loop 0x7c50
00007C52 E460 in al,0x60
00007C54 CB retf
00007C55 BFC27C mov di,0x7cc2
00007C58 FE05 inc byte [di]
00007C5A FB sti
00007C5B 57 push di
00007C5C 9A687C0000 call word 0x0:0x7c68
00007C61 5F pop di
00007C62 FE0D dec byte [di]
00007C64 FA cli
00007C65 C3 ret
00007C66 EB6A jmp short 0x7cd2
00007C68 A10E7C mov ax,[0x7c0e]
00007C6B 96 xchg ax,si
00007C6C AC lodsb
00007C6D 3CFF cmp al,0xff
00007C6F 7201 jc 0x7c72
00007C71 CB retf
00007C72 8AE0 mov ah,al
00007C74 B000 mov al,0x0
00007C76 A3167C mov [0x7c16],ax
00007C79 8EC0 mov es,ax
00007C7B 8A4401 mov al,[si+0x1]
00007C7E 6633C9 xor ecx,ecx
00007C81 3C00 cmp al,0x0
00007C83 7402 jz 0x7c87
00007C85 B112 mov cl,0x12
00007C87 33C0 xor ax,ax
00007C89 8A4403 mov al,[si+0x3]
00007C8C 03C8 add cx,ax
00007C8E 8A4402 mov al,[si+0x2]
00007C91 8BD0 mov dx,ax
00007C93 B224 mov dl,0x24
00007C95 F7E2 mul dx
00007C97 03C8 add cx,ax
00007C99 66A1207C mov eax,[0x7c20]
00007C9D 6603C8 add ecx,eax
00007CA0 6649 dec ecx
00007CA2 66890E187C mov [0x7c18],ecx
00007CA7 AC lodsb
00007CA8 8AE0 mov ah,al
00007CAA B000 mov al,0x0
00007CAC A3147C mov [0x7c14],ax
00007CAF 93 xchg ax,bx
00007CB0 AC lodsb
00007CB1 8AE0 mov ah,al
00007CB3 A0287C mov al,[0x7c28]
00007CB6 92 xchg ax,dx
00007CB7 AC lodsb
00007CB8 50 push ax
00007CB9 8AE0 mov ah,al
00007CBB AC lodsb
00007CBC 91 xchg ax,cx
00007CBD AC lodsb
00007CBE A2127C mov [0x7c12],al
00007CC1 B402 mov ah,0x2
00007CC3 60 pushaw
00007CC4 BE107C mov si,0x7c10
00007CC7 CD13 int 0x13
00007CC9 7227 jc 0x7cf2
00007CCB 61 popaw
00007CCC 58 pop ax
00007CCD E80400 call word 0x7cd4
00007CD0 EB9A jmp short 0x7c6c
00007CD2 EB2A jmp short 0x7cfe
00007CD4 56 push si
00007CD5 91 xchg ax,cx
00007CD6 33C0 xor ax,ax
00007CD8 8ED8 mov ds,ax
00007CDA BF008F mov di,0x8f00
00007CDD B800B0 mov ax,0xb000
00007CE0 8EC0 mov es,ax
00007CE2 91 xchg ax,cx
00007CE3 0430 add al,0x30
00007CE5 AA stosb
00007CE6 5E pop si
00007CE7 C3 ret
00007CE8 50 push ax
00007CE9 E460 in al,0x60
00007CEB 3C01 cmp al,0x1
00007CED 58 pop ax
00007CEE 7407 jz 0x7cf7
00007CF0 EBD1 jmp short 0x7cc3
00007CF2 3C00 cmp al,0x0
00007CF4 61 popaw
00007CF5 74F1 jz 0x7ce8
00007CF7 58 pop ax
00007CF8 B0CE mov al,0xce
00007CFA EBD1 jmp short 0x7ccd
00007CF0 00 7e | .~ |
00007CFE 33C0 xor ax,ax
00007D00 8ED8 mov ds,ax
00007D02 8ED0 mov ss,ax
00007D04 BC007C mov sp,0x7c00
00007D07 92 xchg ax,dx
00007D08 A2287C mov [0x7c28],al
00007D0B 3C00 cmp al,0x0
00007D0D 7405 jz 0x7d14
00007D0F B042 mov al,0x42
00007D11 A2C27C mov [0x7cc2],al
00007D14 BE107C mov si,0x7c10
00007D17 1E push ds
00007D18 9A687C0000 call word 0x0:0x7c68
00007D1D 1F pop ds
00007D1E FA cli
00007D1F A1007E mov ax,[0x7e00]
00007D22 3C90 cmp al,0x90
00007D24 7503 jnz 0x7d29
00007D26 E8D700 call word 0x7e00
00007D29 B800B0 mov ax,0xb000
00007D2C 8EC0 mov es,ax
00007D2E 9A427C0000 call word 0x0:0x7c42
00007D33 3C41 cmp al,0x41
00007D35 74EF jz 0x7d26
00007D37 3C3F cmp al,0x3f
00007D39 7507 jnz 0x7d42
00007D3B 1E push ds
00007D3C E816FF call word 0x7c55
00007D3F 1F pop ds
00007D40 EBE7 jmp short 0x7d29
00007D42 BEFC7C mov si,0x7cfc
00007D45 8BDE mov bx,si
00007D47 3C4D cmp al,0x4d
00007D49 7504 jnz 0x7d4f
00007D4B FF04 inc word [si]
00007D4D EB06 jmp short 0x7d55
00007D4F 3C4B cmp al,0x4b
00007D51 7504 jnz 0x7d57
00007D53 FF0C dec word [si]
00007D55 EB08 jmp short 0x7d5f
00007D57 3C2D cmp al,0x2d
00007D59 7506 jnz 0x7d61
00007D5B AD lodsw
00007D5C 96 xchg ax,si
00007D5D FE04 inc byte [si]
00007D5F EB08 jmp short 0x7d69
00007D61 3C2C cmp al,0x2c
00007D63 7506 jnz 0x7d6b
00007D65 AD lodsw
00007D66 96 xchg ax,si
00007D67 FE0C dec byte [si]
00007D69 EB09 jmp short 0x7d74
00007D6B 3C23 cmp al,0x23
00007D6D 7505 jnz 0x7d74
00007D6F BF0A7C mov di,0x7c0a
00007D72 FE05 inc byte [di]
00007D74 90 nop
00007D75 90 nop
00007D76 90 nop
00007D77 8BF3 mov si,bx
00007D79 AD lodsw
00007D7A 96 xchg ax,si
00007D7B B8FA00 mov ax,0xfa
00007D7E BF0080 mov di,0x8000
00007D81 2BF0 sub si,ax
00007D83 B9F401 mov cx,0x1f4
00007D86 B40B mov ah,0xb
00007D88 A00A7C mov al,[0x7c0a]
00007D8B 2401 and al,0x1
00007D8D 7543 jnz 0x7dd2
00007D8F AC lodsb
00007D90 8AD0 mov dl,al
00007D92 2C64 sub al,0x64
00007D94 720F jc 0x7da5
00007D96 8AD0 mov dl,al
00007D98 2C64 sub al,0x64
00007D9A 7205 jc 0x7da1
00007D9C 92 xchg ax,dx
00007D9D B032 mov al,0x32
00007D9F EB06 jmp short 0x7da7
00007DA1 B031 mov al,0x31
00007DA3 EB02 jmp short 0x7da7
00007DA5 B020 mov al,0x20
00007DA7 AB stosw
00007DA8 92 xchg ax,dx
00007DA9 BB000B mov bx,0xb00
00007DAC 3C0A cmp al,0xa
00007DAE 7205 jc 0x7db5
00007DB0 43 inc bx
00007DB1 2C0A sub al,0xa
00007DB3 EBF7 jmp short 0x7dac
00007DB5 93 xchg ax,bx
00007DB6 3C00 cmp al,0x0
00007DB8 7507 jnz 0x7dc1
00007DBA 92 xchg ax,dx
00007DBB 3C20 cmp al,0x20
00007DBD 7404 jz 0x7dc3
00007DBF B000 mov al,0x0
00007DC1 0430 add al,0x30
00007DC3 AB stosw
00007DC4 93 xchg ax,bx
00007DC5 0430 add al,0x30
00007DC7 AB stosw
00007DC8 B020 mov al,0x20
00007DCA AB stosw
00007DCB E2C2 loop 0x7d8f
00007DCD EB22 jmp short 0x7df1
00007DC0 b0 | .|
00007DD0 20 | |
00007DD1 AB stosw
00007DD2 AC lodsb
00007DD3 50 push ax
00007DD4 C0E804 shr al,0x4
00007DD7 0430 add al,0x30
00007DD9 3C3A cmp al,0x3a
00007DDB 7202 jc 0x7ddf
00007DDD 0407 add al,0x7
00007DDF AB stosw
00007DE0 58 pop ax
00007DE1 240F and al,0xf
00007DE3 0430 add al,0x30
00007DE5 3C3A cmp al,0x3a
00007DE7 7202 jc 0x7deb
00007DE9 0407 add al,0x7
00007DEB AB stosw
00007DEC B020 mov al,0x20
00007DEE AB stosw
00007DEF E2E0 loop 0x7dd1
00007DF1 BFD187 mov di,0x87d1
00007DF4 B00C mov al,0xc
00007DF6 AA stosb
00007DF7 47 inc di
00007DF8 AA stosb
00007DF9 47 inc di
00007DFA AA stosb
00007DFB E930FF jmp word 0x7d2e
00007DF0 55 aa | U.|
Cheers,
Brendan