flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
Dex4u 24 Aug 2007, 03:07
Try
Code: out_buffer: times 512 db ' ' dd 0 You can mod this to suit your print function. |
|||
![]() |
|
dosin 24 Aug 2007, 03:45
Code: out_buffer: times 512 db ' ' dd 0 Sorry but that don't help me... I am new to asm... And I am trying to move the data from es:bx to the data buffer Code: mov data, byte ptr es:bx or something like that.. |
|||
![]() |
|
Dex4u 24 Aug 2007, 04:30
Here is a simple com file example
Code: use16 ; 16bit addressingorg 0x100 ; Com file stuffstart:push cs ; Push CS on stackpop ds ; Move CS into DSpush ds ; Push DSpop es ; Move DS into ESmov [count],3mov bx,out_bufferTryAgain:mov ah,02hmov al,1 ;number of sectors to readmov ch,0 ;trackmov cl,1 ;sectormov dh,0 ;headmov dl,00hint 13hjnc PrintBuffer dec [count]cmp [count],0jne TryAgainFddError:mov si,fdd_err ; Point SI to stringcall print ; call our print functionjmp $ ; Note: if run from dos change this for RETPrintBuffer:mov si,out_buffer ; Point SI to stringcall print ; call our print functionjmp $ ; Note: if run from dos change this for RET;====================================================;; print. ;;====================================================;print:mov ah,0Eh ; Request displayagain1:lodsb ; load a byte into AL from DS:SIor al,al ; Or ALjz done1 ; Jump 0, to label done1int 10h ; Call interrupt servicejmp again1 ; Jump to label again1done1:ret ; Return count db 0 fdd_err db 'Error reading floppy',0 out_buffer: times 512 db ' ' dd 0 http://alexfru.chat.ru/epm.html#bootprog Note the above code as not bean tested. |
|||
![]() |
|
sinsi 24 Aug 2007, 05:24
Quote: It loads the read contents into es:bx.. It loads the data (512 bytes) into a buffer pointed to by ES:BX - a buffer you need to allocate yourself Quote: And I am trying to move the data from es:bx to the data buffer As above, you should already have a buffer... |
|||
![]() |
|
dosin 24 Aug 2007, 17:10
I have tried the example above but it crashes when I read the disk.
And just to make sure I understand the above example: I need to point my diskdata db 512 ' ' to es:bx before calling int 13h? and then print the string.. Thanks again for any help |
|||
![]() |
|
Dex4u 24 Aug 2007, 18:23
Well it run fine on my PC run in Dos (win98), the only change is to the print function because if not it only print about 10 byte as it must have a 0 in the boot sector.
Code: use16 ; 16bit addressingorg 0x100 ; Com file stuffstart:push cs ; Push CS on stackpop ds ; Move CS into DSpush ds ; Push DSpop es ; Move DS into ESmov [count],3mov bx,out_bufferTryAgain:mov ah,02hmov al,1 ;number of sectors to readmov ch,0 ;trackmov cl,1 ;sectormov dh,0 ;headmov dl,00hint 13hjnc PrintBuffer dec [count]cmp [count],0jne TryAgainFddError:mov si,fdd_err ; Point SI to stringcall print ; call our print functionret ; Note: if run from dos change this for RETPrintBuffer:mov si,out_buffer ; Point SI to stringcall printF ; call our print functionret ; Note: if run from dos change this for RET;====================================================;; print. ;;====================================================;print:mov ah,0Eh ; Request displayagain1:lodsb ; load a byte into AL from DS:SIor al,al ; Or ALjz done1 ; Jump 0, to label done1int 10h ; Call interrupt servicejmp again1 ; Jump to label again1done1:ret ; Return ;====================================================;; printF. ;;====================================================;printF:mov cx,512mov ah,0Eh ; Request displayagain2:lodsb ; load a byte into AL from DS:SIint 10h ; Call interrupt serviceloop again2 ; Jump to label again1ret ; Returncount db 0 fdd_err db 'Error reading floppy',0 out_buffer: times 512 db ' ' dd 0 Note: your code to read boot sector is wrong, it should be sector = 1. How was you running it ?. Last edited by Dex4u on 25 Aug 2007, 15:07; edited 1 time in total |
|||
![]() |
|
dosin 24 Aug 2007, 18:41
Thanks its working now!
|
|||
![]() |
|
Hayden 26 Aug 2007, 19:29
here is a 16-bit boot sector i wrote a while ago, it shows you how to correctly load address into es:bx. ( sectors are read into the 'SystemSpace' variable ) hope it helps.
Code: ; ------------------------------------------------ ; BOOT-OS.ASM Build(0620a) ; Created By: Hayden McKay ; ------------------------------------------------ use16 jmp far 007C0h:init_bootsys ; must be far align 4 SystemStack dd 08000h:0fbffh ; 1k SystemSpace dd 09000h:00000h ; 64k SectorStart dw 1 ; lba SectorCount db 128 ; maximum 64k align 4 init_bootsys: ; setup stack ect... lss sp, dword [cs:SystemStack] ; nmi safe pushf pusha push dx ; boot num push sp ; setup for lba->chs translation... mov ah,08h ; drive params int 13h xor ah, ah mov al, dh ; maximum head and cx,3fh ; clear d6->d7 inc ax mul cx mov si, cx ; sector count mov di, ax ; heads x secs ; begin the lba->chs, mutli-sector read... pop bp ; ptr boot num les bx, dword [cs:SystemSpace] align 4 read_sectors: mov ax, word [cs:SectorStart] xor dx, dx div di mov cl, ah mov ch, al ; cylinder d0->d7 shl cl, 6d ; cylinder d8->d9 mov ax, dx xor dx, dx div si inc dl mov dh, al ; head or cl, dl ; sector d0->d5 mov dl, byte [ss:bp] ; read how many sectors... mov al, cl and ax,3fh sub ax, si ; - max sec... neg ax ; abs inc al ; +=1 cmp al, byte [cs:SectorCount] ; more than... jbe @f mov al, byte [cs:SectorCount] ; less than... align 4 @@: ; use the bios int13 i/o... pusha ; bios safe xor ax, ax ; calibrate int 13h popa pusha mov ah,02h ; read secs stc ; bios safe int 13h popa jc @b ; use force ; prepare for some more sectors... add word [cs:SectorStart], ax ; update start sub byte [cs:SectorCount], al ; update count jz @f ; done! shl ax, 9d ; *=512 add bx, ax ; update es:bx jmp near read_sectors align 4 @@: pop dx ; boot num ; initiate the system file... popa popf lds bx, dword [cs:SystemSpace] ; setup data call far dword [cs:SystemSpace] ; enter code ; 157 bytes ; Todo list... ; * maybee copy the system to the hma ; * maybee supply an open file system rb 510d - $ db 055h db 0AAh ; bootme! _________________ New User.. Hayden McKay. |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.