strcmp: strcmp_loop: ld a, (ix+0) ld b, (iy+0) cp b jp nz, strcmp_different cp 0 ret z inc ix inc iy jp strcmp_loop strcmp_different: ld a, 1 ret .global read_init ; Reads init.elf off the disk to 0x8000 in memory read_init: ld c, 0 ld de, 1 ri_find_loop: ld hl, 0x8000 push bc call read_sector ld ix, 0x8001 ld iy, init_str call strcmp pop bc jp z, ri_init_found push bc ld b, 0 ld a, (0x8000) ld c, a ld hl, 0x8004 add hl, bc ld c, (hl) inc hl ld b, (hl) ld l, c ld h, b inc hl add hl, de ld e, l ld d, h pop bc ld a, c adc a, 0 ld c, a jp ri_find_loop ri_init_found: push bc ld b, 0 ld a, (0x8000) ld c, a ld hl, 0x8004 add hl, bc pop bc ld b, (hl) ld hl, 1 add hl, de ld e, l ld d, h ld a, c adc a, 0 ld c, a ld hl, 0x8000 ri_read_loop: push bc call read_sector pop bc push hl ld hl, 1 add hl, de ld e, l ld d, h ld a, c adc a, 0 ld c, a pop hl djnz ri_read_loop ret ; Given a sector number in C:DE and a buffer address in HL, reads the sector off disk. read_sector: push bc ld c,0xFF ; Force the top half of the IO address to be the id of the card, ld a, (disk_num) ; so the block transfer instructions can be used out (c), a pop bc ld a, c ld c, 0 out (c), e inc c out (c), d inc c out (c), a ld b, 0x0 ; Setup a transfer of 256 bytes (1 sector) at a time ld c, 0x3 ; from the storage device's data port inir ld c,0xFF ; Unforce the top half of the IO address in a,(c) ret .global find_disk ; Clobbers A and HL find_disk: ld b,0x4 call find_first_card ld a, l ld (disk_num), a ret disk_num: .ds.b 1 /* initrd: */ /* .incbin "initrd" */ /* initrd_end: */ init_str: .asciz "init.elf"