BIOS code looking for specific hard drives

x86 / x64 programming
Post Reply
Posts: 4
Joined: Sun Aug 29, 2021 3:57 am

BIOS code looking for specific hard drives

Post by shawnerz » Sat Sep 18, 2021 10:28 pm

If you haven't read my previous post about "why I'm here", reading it will provide context to this post. :)
In this BIOS code snippet, the '286 processor is looking for any 1 of 5 Connor Peripherals hard drives starting at $76da. There are annotations, but I was hoping to gain some more insight for a better understanding of the code. I'm hoping to learn from any comments and or discussion.

Can anyone recommend a good disassembler?


Code: Select all

0000769e  53                 push    bx {var_4_1}
0000769f  51                 push    cx {var_6_1}
000076a0  1e                 push    ds {var_8_1}
000076a1  56                 push    si {var_a_1}
000076a2  06                 push    es {var_c_1}
000076a3  57                 push    di {var_e_1}
000076a4  ba0000             mov     dx, 0x0  
000076a7  e8f7a7             call    sub_1ea1			{Call to retrive drive 40 character drive id string}
000076aa  7306               jae     0x76b2

000076ac  ba55aa             mov     dx, 0xaa55
000076af  eb7b               jmp     0x772c

000076b2  b92800             mov     cx, 0x28  			{set counter for the id string}

000076b5  26803d2d           cmp     byte [es:di], 0x2d  	{find the "-" in the string}	 
000076b9  7407               je      0x76c2

000076bb  47                 inc     di
000076bc  e2f7               loop    0x76b5

000076be  f8                 clc     
000076bf  eb68               jmp     0x7729

000076c2  47                 inc     di

000076c3  26803d20           cmp     byte [es:di], 0x20		{move past the " " to the first character of id}
000076c7  7505               jne     0x76ce

000076c9  47                 inc     di
000076ca  e2f7               loop    0x76c3

000076cc  eb5e               jmp     0x772c

000076ce  8bdf               mov     bx, di
000076d0  ba0500             mov     dx, 0x5  
000076d3  8cc8               mov     ax, cs
000076d5  8ed8               mov     ds, ax
000076d7  be3cf6             mov     si, 0xf63c				{address of dive string}
000076da  b90600             mov     cx, 0x6  {"CP3022"}		{lenght of string}
000076dd  f3a6               rep cmpsb byte [si], [di]  {0xf63c}	{check string}
000076df  744b               je      0x772c				{jump if good or continue}

000076e1  ba0500             mov     dx, 0x5  
000076e4  8bfb               mov     di, bx
000076e6  be42f6             mov     si, 0xf642
000076e9  b90600             mov     cx, 0x6  {"CP3024"}
000076ec  f3a6               rep cmpsb byte [si], [di]  {0xf642}
000076ee  743c               je      0x772c

000076f0  8bfb               mov     di, bx
000076f2  ba0600             mov     dx, 0x6  
000076f5  be54f6             mov     si, 0xf654
000076f8  b90500             mov     cx, 0x5  {"CP344"}
000076fb  f3a6               rep cmpsb byte [si], [di]  {0xf654}
000076fd  742d               je      0x772c

000076ff  ba0900             mov     dx, 0x9  
00007702  8bfb               mov     di, bx
00007704  be48f6             mov     si, 0xf648
00007707  b90600             mov     cx, 0x6  {"CP3044"}
0000770a  f3a6               rep cmpsb byte [si], [di]  {0xf648}
0000770c  741e               je      0x772c

0000770e  8bfb               mov     di, bx
00007710  be4ef6             mov     si, 0xf64e
00007713  b90600             mov     cx, 0x6  {"CP3042"}
00007716  f3a6               rep cmpsb byte [si], [di]  {0xf64e}
00007718  7412               je      0x772c

0000771a  8bfb               mov     di, bx
0000771c  ba0700             mov     dx, 0x7  
0000771f  be59f6             mov     si, 0xf659
00007722  b90600             mov     cx, 0x6  {"CP3104"}
00007725  f3a6               rep cmpsb byte [si], [di]  {0xf659}
00007727  7403               je      0x772c

00007729  ba0000             mov     dx, 0x0 				{fail} 

0000772c  1e                 push    ds {var_10_1}
0000772d  50                 push    ax {var_12_1}
0000772e  b84000             mov     ax, 0x40
00007731  56                 push    si {var_14_1}
00007732  bec300             mov     si, 0xc3
00007735  8bc2               mov     ax, dx
00007737  ab                 stosw   word [di]
00007738  5e                 pop     si {var_14_1}
00007739  58                 pop     ax {var_12_1}
0000773a  1f                 pop     ds {var_10_1}
0000773b  5f                 pop     di {var_e_1}
0000773c  07                 pop     es {var_c_1}
0000773d  5e                 pop     si {var_a_1}
0000773e  1f                 pop     ds {var_8_1}
0000773f  59                 pop     cx {var_6_1}
00007740  5b                 pop     bx {var_4_1}
00007741  e956ff             jmp     0x769a

00007744  1e                 push    ds
00007745  2e8e1ed9c6         mov     ds, word [cs:0xffffffffffffc6d9]
0000774a  8a16b200           mov     dl, byte [0xb2]
0000774e  32e4               xor     ah, ah
00007750  1f                 pop     ds
00007751  c3                 retn

Post Reply

Return to “8086 Assembly Programming”