From efa6c5f44e6a0d5e0b1f16c2819be67128bf05ef Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Thu, 7 Jan 2021 22:41:41 -0800 Subject: 7481 --- html/baremetal/boot.hex.html | 395 ++++++++++++++++++++++--------------------- html/baremetal/ex3.hex.html | 115 ++++++------- 2 files changed, 259 insertions(+), 251 deletions(-) (limited to 'html/baremetal') diff --git a/html/baremetal/boot.hex.html b/html/baremetal/boot.hex.html index 65cd7afe..e4a54cfb 100644 --- a/html/baremetal/boot.hex.html +++ b/html/baremetal/boot.hex.html @@ -287,7 +287,7 @@ if ('onhashchange' in window) { 233 # if (status & 0x1) == 0, return 234 24 01 # al <- and 0x1 235 3c 00 # compare al, 0 -236 74 2d # jump to epilogue if = [label] +236 74 35 # jump to epilogue if = [label] 237 # 120: 238 # if keyboard buffer is full, return 239 31 c9 # ecx <- xor ecx; 11/direct 001/r32/ecx 001/rm32/ecx @@ -302,105 +302,105 @@ if ('onhashchange' in window) { 248 # . if (al != 0) return 249 3c 00 # compare al, 0 250 # 130: -251 75 1b # jump to epilogue if != [label] +251 75 23 # jump to epilogue if != [label] 252 # read keycode into al 253 e4 60 # al <- port 0x60 -254 # al <- *(keyboard normal map + eax) -255 8a # copy m8 at rm32 to r8 -256 80 # 10/mod/*+disp32 000/r8/al 000/rm32/eax -257 00 80 00 00 # disp32 [label] -258 # store al in keyboard buffer -259 88 # copy r8 to m8 at r32 -260 81 # 10/mod/*+disp32 000/r8/al 001/rm32/ecx -261 d0 7d 00 00 # disp32 [label] -262 # 140: -263 # increment index -264 fe # increment byte -265 05 # 00/mod/indirect 000/subop/increment 101/rm32/use-disp32 -266 ce 7d 00 00 # disp32 [label] -267 # clear top nibble of index (keyboard buffer is circular) -268 80 # and byte -269 25 # 00/mod/indirect 100/subop/and 101/rm32/use-disp32 -270 ce 7d 00 00 # disp32 [label] -271 0f # imm8 -272 # 14d: -273 # epilogue -274 61 # pop all registers -275 fb # enable interrupts -276 cf # iret -277 -278 # padding -279 # 150: -280 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -281 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -282 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -283 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -284 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -285 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -286 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -287 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -288 -289 # 1ce: -290 # var keyboard circular buffer -291 # write index: nibble -292 00 -293 # 1cf: -294 # read index: nibble -295 00 -296 # circular buffer: byte[16] -297 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -298 -299 # padding -300 # 1e0: -301 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -302 00 00 00 00 00 00 00 00 -303 -304 # 1f8: -305 # idt_descriptor: -306 ff 00 # idt_end - idt_start - 1 -307 00 7e 00 00 # start = idt_start [label] -308 -309 # 1fe: -310 # final 2 bytes of boot sector -311 55 aa -312 -313 ## sector 2 -314 # loaded by load_disk, not automatically on boot +254 # if (al & 0x80) a key is being lifted; return +255 50 # push eax +256 24 80 # al <- and 0x80 +257 3c 00 # compare al, 0 +258 58 # pop to eax (without touching flags) +259 75 19 # jump to epilogue if != [label] +260 # 13c: +261 # al <- *(keyboard normal map + eax) +262 8a # copy m8 at rm32 to r8 +263 80 # 10/mod/*+disp32 000/r8/al 000/rm32/eax +264 00 80 00 00 # disp32 [label] +265 # store al in keyboard buffer +266 88 # copy r8 to m8 at r32 +267 81 # 10/mod/*+disp32 000/r8/al 001/rm32/ecx +268 d0 7d 00 00 # disp32 [label] +269 # 148: +270 # increment index +271 fe # increment byte +272 05 # 00/mod/indirect 000/subop/increment 101/rm32/use-disp32 +273 ce 7d 00 00 # disp32 [label] +274 # clear top nibble of index (keyboard buffer is circular) +275 80 # and byte +276 25 # 00/mod/indirect 100/subop/and 101/rm32/use-disp32 +277 ce 7d 00 00 # disp32 [label] +278 0f # imm8 +279 # 155: +280 # epilogue +281 61 # pop all registers +282 fb # enable interrupts +283 cf # iret +284 +285 # padding +286 # 158: +287 00 00 00 00 00 00 00 00 +288 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +289 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +290 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +291 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +292 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +293 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +294 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +295 +296 # 1ce: +297 # var keyboard circular buffer +298 # write index: nibble +299 00 +300 # 1cf: +301 # read index: nibble +302 00 +303 # circular buffer: byte[16] +304 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +305 +306 # padding +307 # 1e0: +308 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +309 00 00 00 00 00 00 00 00 +310 +311 # 1f8: +312 # idt_descriptor: +313 ff 00 # idt_end - idt_start - 1 +314 00 7e 00 00 # start = idt_start [label] 315 -316 # offset 200 (address 0x7e00): interrupt descriptor table -317 # 32 entries * 8 bytes each = 256 bytes (0x100) -318 # idt_start: +316 # 1fe: +317 # final 2 bytes of boot sector +318 55 aa 319 -320 00 00 00 00 00 00 00 00 -321 00 00 00 00 00 00 00 00 -322 00 00 00 00 00 00 00 00 -323 00 00 00 00 00 00 00 00 -324 00 00 00 00 00 00 00 00 -325 00 00 00 00 00 00 00 00 -326 00 00 00 00 00 00 00 00 +320 ## sector 2 +321 # loaded by load_disk, not automatically on boot +322 +323 # offset 200 (address 0x7e00): interrupt descriptor table +324 # 32 entries * 8 bytes each = 256 bytes (0x100) +325 # idt_start: +326 327 00 00 00 00 00 00 00 00 -328 -329 # entry 8: clock -330 00 7d # target[0:16] = null interrupt handler [label] -331 08 00 # segment selector (gdt_code) -332 00 # unused -333 8e # 1/p 00/dpl 0 1110/type/32-bit-interrupt-gate -334 00 00 # target[16:32] +328 00 00 00 00 00 00 00 00 +329 00 00 00 00 00 00 00 00 +330 00 00 00 00 00 00 00 00 +331 00 00 00 00 00 00 00 00 +332 00 00 00 00 00 00 00 00 +333 00 00 00 00 00 00 00 00 +334 00 00 00 00 00 00 00 00 335 -336 # entry 9: keyboard -337 10 7d # target[0:16] = keyboard interrupt handler [label] +336 # entry 8: clock +337 00 7d # target[0:16] = null interrupt handler [label] 338 08 00 # segment selector (gdt_code) 339 00 # unused 340 8e # 1/p 00/dpl 0 1110/type/32-bit-interrupt-gate 341 00 00 # target[16:32] 342 -343 00 00 00 00 00 00 00 00 -344 00 00 00 00 00 00 00 00 -345 00 00 00 00 00 00 00 00 -346 00 00 00 00 00 00 00 00 -347 00 00 00 00 00 00 00 00 -348 00 00 00 00 00 00 00 00 -349 00 00 00 00 00 00 00 00 +343 # entry 9: keyboard +344 10 7d # target[0:16] = keyboard interrupt handler [label] +345 08 00 # segment selector (gdt_code) +346 00 # unused +347 8e # 1/p 00/dpl 0 1110/type/32-bit-interrupt-gate +348 00 00 # target[16:32] +349 350 00 00 00 00 00 00 00 00 351 00 00 00 00 00 00 00 00 352 00 00 00 00 00 00 00 00 @@ -416,105 +416,105 @@ if ('onhashchange' in window) { 362 00 00 00 00 00 00 00 00 363 00 00 00 00 00 00 00 00 364 00 00 00 00 00 00 00 00 -365 # idt_end: -366 -367 # offset 300 (address 0x7f00): -368 # video mode info: -369 00 00 # attributes -370 00 # winA -371 00 # winB -372 # 304 -373 00 00 # granularity -374 00 00 # winsize -375 # 308 -376 00 00 # segmentA -377 00 00 # segmentB -378 # 30c -379 00 00 00 00 # realFctPtr (who knows) -380 # 310 -381 00 00 # pitch -382 00 00 # Xres -383 # 314 -384 00 00 # Yres -385 00 00 # Wchar Ychar -386 # 318 -387 00 # planes -388 00 # bpp -389 00 # banks -390 00 # memory_model -391 # 31c -392 00 # bank_size -393 00 # image_pages -394 00 # reserved -395 # 31f -396 00 00 # red_mask red_position -397 00 00 # green_mask green_position -398 00 00 # blue_mask blue_position -399 00 00 # rsv_mask rsv_position -400 00 # directcolor_attributes -401 # 328 -402 00 00 00 00 # physbase <== linear frame buffer -403 -404 # 32c -405 # reserved for video mode info -406 00 00 00 00 -407 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -408 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -409 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -410 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -411 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -412 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -413 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +365 00 00 00 00 00 00 00 00 +366 00 00 00 00 00 00 00 00 +367 00 00 00 00 00 00 00 00 +368 00 00 00 00 00 00 00 00 +369 00 00 00 00 00 00 00 00 +370 00 00 00 00 00 00 00 00 +371 00 00 00 00 00 00 00 00 +372 # idt_end: +373 +374 # offset 300 (address 0x7f00): +375 # video mode info: +376 00 00 # attributes +377 00 # winA +378 00 # winB +379 # 304 +380 00 00 # granularity +381 00 00 # winsize +382 # 308 +383 00 00 # segmentA +384 00 00 # segmentB +385 # 30c +386 00 00 00 00 # realFctPtr (who knows) +387 # 310 +388 00 00 # pitch +389 00 00 # Xres +390 # 314 +391 00 00 # Yres +392 00 00 # Wchar Ychar +393 # 318 +394 00 # planes +395 00 # bpp +396 00 # banks +397 00 # memory_model +398 # 31c +399 00 # bank_size +400 00 # image_pages +401 00 # reserved +402 # 31f +403 00 00 # red_mask red_position +404 00 00 # green_mask green_position +405 00 00 # blue_mask blue_position +406 00 00 # rsv_mask rsv_position +407 00 # directcolor_attributes +408 # 328 +409 00 00 00 00 # physbase <== linear frame buffer +410 +411 # 32c +412 # reserved for video mode info +413 00 00 00 00 414 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 415 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 416 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 417 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 418 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 419 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -420 -421 # offset 400 (address 0x8000): -422 # keyboard normal map: -423 00 -424 # es -425 1b -426 # |<--- digits -------------->| - = bs -427 31 32 33 34 35 36 37 38 39 30 2d 3d 08 -428 # offset 40f -429 # tb q w e r t y u i o p [ ] -430 09 71 77 65 72 74 79 75 69 6f 70 5b 5d -431 # offset 41c -432 # enter -433 0a 00 -434 # offset 41e -435 # a s d f g h j k l ; ' ` \ -436 61 73 64 66 67 68 6a 6b 6c 3b 27 60 00 5c -437 # offset 42c -438 # z x c v b n m , . / -439 7a 78 63 76 62 6e 6d 2c 2e 2f -440 # offset 436 -441 00 00 00 00 00 00 00 00 00 00 -442 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -443 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -444 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -445 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -446 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -447 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -448 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +420 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +421 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +422 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +423 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +424 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +425 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +426 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +427 +428 # offset 400 (address 0x8000): +429 # keyboard normal map: +430 00 +431 # es +432 1b +433 # |<--- digits -------------->| - = bs +434 31 32 33 34 35 36 37 38 39 30 2d 3d 08 +435 # offset 40f +436 # tb q w e r t y u i o p [ ] +437 09 71 77 65 72 74 79 75 69 6f 70 5b 5d +438 # offset 41c +439 # enter +440 0a 00 +441 # offset 41e +442 # a s d f g h j k l ; ' ` \ +443 61 73 64 66 67 68 6a 6b 6c 3b 27 60 00 5c +444 # offset 42c +445 # z x c v b n m , . / +446 7a 78 63 76 62 6e 6d 2c 2e 2f +447 # offset 436 +448 00 00 00 00 00 00 00 00 00 00 449 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 450 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 451 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 452 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 453 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -454 -455 # 500: -456 # keyboard shift map: +454 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +455 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +456 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 457 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 458 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 459 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 460 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -461 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -462 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -463 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +461 +462 # 500: +463 # keyboard shift map: 464 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 465 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 466 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 @@ -524,16 +524,16 @@ if ('onhashchange' in window) { 470 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 471 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 472 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -473 -474 # 600: -475 # keyboard ctrl map: +473 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +474 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +475 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 476 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 477 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 478 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 479 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -480 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -481 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -482 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +480 +481 # 600: +482 # keyboard ctrl map: 483 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 484 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 485 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 @@ -543,16 +543,16 @@ if ('onhashchange' in window) { 489 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 490 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 491 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -492 -493 # padding (there might be more keyboard tables) -494 # 700: +492 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +493 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +494 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 495 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 496 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 497 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 498 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -499 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -500 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -501 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +499 +500 # padding (there might be more keyboard tables) +501 # 700: 502 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 503 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 504 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 @@ -562,15 +562,15 @@ if ('onhashchange' in window) { 508 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 509 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 510 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -511 -512 # 800: +511 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +512 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 513 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 514 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 515 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 516 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 517 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -518 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -519 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +518 +519 # 800: 520 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 521 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 522 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 @@ -596,14 +596,14 @@ if ('onhashchange' in window) { 542 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 543 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 544 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -545 # a00: +545 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 546 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 547 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 548 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 549 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 550 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 551 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -552 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +552 # a00: 553 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 554 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 555 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 @@ -629,9 +629,16 @@ if ('onhashchange' in window) { 575 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 576 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 577 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -578 # offset c00 (address 0x8800) -579 -580 # vim:ft=subx +578 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +579 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +580 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +581 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +582 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +583 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +584 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +585 # offset c00 (address 0x8800) +586 +587 # vim:ft=subx diff --git a/html/baremetal/ex3.hex.html b/html/baremetal/ex3.hex.html index d2cf7595..b39c442f 100644 --- a/html/baremetal/ex3.hex.html +++ b/html/baremetal/ex3.hex.html @@ -51,63 +51,64 @@ if ('onhashchange' in window) { https://github.com/akkartik/mu/blob/main/baremetal/ex3.hex
- 1 # Draw pixels in response to keyboard events.
- 2 #
- 3 # To run, first prepare a realistically sized disk image:
- 4 #   dd if=/dev/zero of=disk.img count=20160  # 512-byte sectors, so 10MB
- 5 # Load the program on the disk image:
- 6 #   cat baremetal/boot.hex baremetal/ex3.hex  |./bootstrap run apps/hex  > a.bin
- 7 #   dd if=a.bin of=disk.img conv=notrunc
- 8 # To run:
- 9 #   qemu-system-i386 disk.img
-10 # Or:
-11 #   bochs -f baremetal/boot.bochsrc  # boot.bochsrc loads disk.img
-12 
-13 # main:  (address 0x8800)
-14 
-15 # eax <- LFB
-16 8b  # copy *rm32 to r32
-17   05  # 00/mod/indirect 000/r32/eax 101/rm32/use-disp32
-18   28 7f 00 00 # disp32 [label]
-19 
-20 # var read index/ecx: byte = 0
-21 31 c9  # ecx <- xor ecx;  11/direct 001/r32/ecx 001/rm32/ecx
-22 
-23 # $loop:
-24   # CL = *read index
-25   8a  # copy m8 at r32 to r8
-26     0d  # 00/mod/indirect 001/r8/cl 101/rm32/use-disp32
-27     cf 7d 00 00  # disp32 [label]
-28   # CL = *(keyboard buffer + ecx)
-29   8a  # copy m8 at r32 to r8
-30     89  # 10/mod/*+disp32 001/r8/cl 001/rm32/ecx
-31     d0 7d 00 00  # disp32 [label]
-32   # if (CL == 0) loop (spin loop)
-33   80
-34     f9  # 11/mod/direct 111/subop/compare 001/rm8/CL
-35     00  # imm8
-36   74 ef  # loop -17 [label]
-37 # offset 0x19:
-38   # otherwise increment read index
-39   fe  # increment byte
-40     05  # 00/mod/indirect 000/subop/increment 101/rm32/use-disp32
-41     cf 7d 00 00  # disp32 [label]
-42   # clear top nibble of index (keyboard buffer is circular)
-43   80  # and byte
-44     25  # 00/mod/indirect 100/subop/and 101/rm32/use-disp32
-45     cf 7d 00 00  # disp32 [label]
-46     0f  # imm8
-47   # print a pixel in fluorescent green
-48   c6  # copy imm8 to m8 at rm32
-49     00  # 00/mod/indirect 000/subop 000/rm32/eax
-50     31  # imm32
-51   40  # increment eax
-52   eb dc # loop -36 [label]
-53 
-54 # $break:
-55 e9 fb ff ff ff  # hang indefinitely
-56 
-57 # vim:ft=subx
+ 1 # Draw pixels in response to keyboard events, starting from the top-left
+ 2 # and in raster order.
+ 3 #
+ 4 # To run, first prepare a realistically sized disk image:
+ 5 #   dd if=/dev/zero of=disk.img count=20160  # 512-byte sectors, so 10MB
+ 6 # Load the program on the disk image:
+ 7 #   cat baremetal/boot.hex baremetal/ex3.hex  |./bootstrap run apps/hex  > a.bin
+ 8 #   dd if=a.bin of=disk.img conv=notrunc
+ 9 # To run:
+10 #   qemu-system-i386 disk.img
+11 # Or:
+12 #   bochs -f baremetal/boot.bochsrc  # boot.bochsrc loads disk.img
+13 
+14 # main:  (address 0x8800)
+15 
+16 # eax <- LFB
+17 8b  # copy *rm32 to r32
+18   05  # 00/mod/indirect 000/r32/eax 101/rm32/use-disp32
+19   28 7f 00 00 # disp32 [label]
+20 
+21 # var read index/ecx: byte = 0
+22 31 c9  # ecx <- xor ecx;  11/direct 001/r32/ecx 001/rm32/ecx
+23 
+24 # $loop:
+25   # CL = *read index
+26   8a  # copy m8 at r32 to r8
+27     0d  # 00/mod/indirect 001/r8/cl 101/rm32/use-disp32
+28     cf 7d 00 00  # disp32 [label]
+29   # CL = *(keyboard buffer + ecx)
+30   8a  # copy m8 at r32 to r8
+31     89  # 10/mod/*+disp32 001/r8/cl 001/rm32/ecx
+32     d0 7d 00 00  # disp32 [label]
+33   # if (CL == 0) loop (spin loop)
+34   80
+35     f9  # 11/mod/direct 111/subop/compare 001/rm8/CL
+36     00  # imm8
+37   74 ef  # loop -17 [label]
+38 # offset 0x19:
+39   # otherwise increment read index
+40   fe  # increment byte
+41     05  # 00/mod/indirect 000/subop/increment 101/rm32/use-disp32
+42     cf 7d 00 00  # disp32 [label]
+43   # clear top nibble of index (keyboard buffer is circular)
+44   80  # and byte
+45     25  # 00/mod/indirect 100/subop/and 101/rm32/use-disp32
+46     cf 7d 00 00  # disp32 [label]
+47     0f  # imm8
+48   # print a pixel in fluorescent green
+49   c6  # copy imm8 to m8 at rm32
+50     00  # 00/mod/indirect 000/subop 000/rm32/eax
+51     31  # imm32
+52   40  # increment eax
+53   eb dc # loop -36 [label]
+54 
+55 # $break:
+56 e9 fb ff ff ff  # hang indefinitely
+57 
+58 # vim:ft=subx
 
-- cgit 1.4.1-2-gfad0