flat assembler
Message board for the users of flat assembler.
Index
> OS Construction > int 13, 2 es:bx incrementation |
Author |
|
Coddy41 26 Dec 2009, 01:04
Tyler wrote: When I read a sector into memory with int 13, 2 does it increment es:bx so the next read will not overwrite the previous sector, if not, how much should I add to it. I do not think it does it automaticly unless you have a magic processer. And I cannot tell you how much to do it, that all depends on the size of the kernel ect. eg: you could load your kenel at 1000:0000 and apps at 6000:0000 ect. I may be misunderstanding the question though. _________________ Want hosting for free for your asm project? You can PM me. (*.fasm4u.net) |
|||
26 Dec 2009, 01:04 |
|
Tyler 26 Dec 2009, 02:20
From what I know(just from others' examples) you're supposed to read one sector at a time with a boot loader. How much do I add to es(indirectly) from one read to the next, so as to not overwrite the last sector?
|
|||
26 Dec 2009, 02:20 |
|
LocoDelAssembly 26 Dec 2009, 04:09
Quote:
mmm, what a pity fasm doesn't say nothing about that... Anyway, you'll have to increment BX by 512 on every read and after 128 reads you'll need to increment ES by 1000h too. I think it will be easier if you copy the sectors starting at 1000:0000 (hex) address. Something like this: Code: ;DISK - READ SECTOR(S) INTO MEMORY ; ;AH = 02h ;AL = number of sectors to read (must be nonzero) ;CH = low eight bits of cylinder number ;CL = sector number 1-63 (bits 0-5) ;high two bits of cylinder (bits 6-7, hard disk only) ;DH = head number ;DL = drive number (bit 7 set for hard disk) ;ES:BX -> data buffer mov ax, $1000 mov es, ax xor bx, bx mov cx, 1 mov dh, 0 mov si, NUMBER_OF_SECTORS ; 0 < NUMBER_OF_SECTORS < 64 next_read: mov di, 3 ; number of tries .read: mov ax, $0201 int $13 jc .fail ; Prepare for next sector inc cl add bx, 512 dec si jnz next_read jmp $1000:0000 ; Jump to second stage (loaded sectors) .fail: ; Check if we have another try dec di jnz .read ; Handle the fatal error here [edit]If you plan to place the second stage code in the same file the boot loader is then don't forget to use "org 0" before the code/data begins. |
|||
26 Dec 2009, 04:09 |
|
Tyler 26 Dec 2009, 05:34
LocoDelAssembly wrote:
Ooops, I put that there while I was guessing at what it should be. Forgot to delete it. Anyway, thanks, that's what I wanted to know. Nice code too, you did it a lot more efficiently than I did. |
|||
26 Dec 2009, 05:34 |
|
sinsi 26 Dec 2009, 05:43
A way to load more than 64k is to leave BX=0 and increment ES
Code: mov ax,es add ax,512/16 ;(bytes per sector) / (bytes per paragraph) mov es,ax You will also need to increment DH (head) if CL (sector) goes past 'sectors per track' (and then CH (track) once DH goes past 'number of heads'). |
|||
26 Dec 2009, 05:43 |
|
Mac2004 27 Dec 2009, 09:22
Tyler: One possible approach to solve this 64kb barrier problem is to use a temporary buffer
and copy the read sector from the temporary bufffer to the desired location right after you've read each sector. regards Mac2004 |
|||
27 Dec 2009, 09:22 |
|
baldr 27 Dec 2009, 12:03
Mac2004,
Buffering is good to support arbitrary-length reads, but Tyler wants to read sectors as a whole. ___ Tyler, Modern BIOSes handle DMA-across-64KiB boundary (unrelated to mentioned "64kb barrier", it's from design of DMA in PC), yet you may opt to be on the safe side (since there isn't check for error 9 in any shown code). CF is more reliable indicator of int 13h failure than ah being zero. I recall at least one such BIOS (that returns ah!=0 even if there is no error, CF was cleared). mov sp, 0ffffh looks strange. Maybe it's there to catch stack overflow (386+ will shutdown because of triple fault on push when sp==1). In other case, it looks misaligned at least. There is a trick to execute some code 2**n times without counter, using stack: Code: add4: call add2 add2: call add1 add1: add ax, 1 ret |
|||
27 Dec 2009, 12:03 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.