+; waiting for keypress
+; x86 has 2 special instructions to read/write from I/O
+; devices: in and out (because some processors have different
+; address spaces for devices and for memory, arm not)
+.key_wait:
+ in al, 64h ; 60h = keyb data port, 64h = keyb status port
+ and al, 1 ; 1 = OUTBUF_FULL = the keyb controller out buf is full
+ jz .key_wait
+
+ in al, 60h ; reads the keyb that was pressed to reset the flag
+
+; load 2nd sector from boot device and jump to it
+; bios helpers, 13h = disk io
+ mov ax, 0
+ mov ds, ax
+ mov ah, 02h ; call 2: read sectors into memory
+ mov al, 1 ; number of sectors to read
+ mov ch, 0 ; low 8 bits of cylinder number
+ mov cl, 2 ; sector number that starts from 1
+ mov dh, 0 ; head number
+ mov dl, [saved_drive_num] ; 8bits
+ mov bx, sector_2
+ int 13h
+; error check: if carry flag isn't set jump to loaded code
+ jnc sector_2
+.inf_loop:
+ jmp .inf_loop
+