flat assembler
Message board for the users of flat assembler.
Index
> OS Construction > Echo MBR |
Author |
|
Mac2004 13 Oct 2004, 05:50
Hi!
I just took a quick look at your code and I think your problem is that lodsb (etc.) instructions use (as far as I remember now) ds:si segment register pair and stosb (etc.) instructions es:di pair. I think you might try setting ds segment pointing to 0x9000 along es segment. But unfortunately I haven't had time to test this. regards Mac2004 |
|||
13 Oct 2004, 05:50 |
|
da_man 13 Oct 2004, 14:51
setting ds to 0x9000 hangs the program.
as i understand the print function above it should copy [si] to al and inrement si by one. then it checks if al is empty (if yes it returns), after these steps it copies the parameters for int 0x10 to the corresponding registers and finally it triggers int 0x10. but i can't figure out why it doesn't print anything. how would you solve this problem? |
|||
13 Oct 2004, 14:51 |
|
drh3xx 13 Oct 2004, 15:05
Hi, I have no idea why loading 0x9000 into ds is hanging bochs that is strange.
Because you know the length of the MBR (512 bytes) I'd loop through the lodsb/print value routine. The way you have it at the minute checking for the null value will stop printing as soon as it encounters a byte set to 0 so it might not print all of the MBR. Also mov si,[es:bx] loads the value at that address into si. You want to simply set ds=es and then mov si,bx. hope you get your code working soon. |
|||
13 Oct 2004, 15:05 |
|
da_man 13 Oct 2004, 15:39
sorry i messed something up.
it works now. i replaced mov si,[es:bx] with mov si, bx and set ds to 0x9000. the downside is, that i can't use the print function to print a message embedded in the code. should i code another function, that avoids lodsb and prints out the data 'manually' doing what lodsb does, but utilizing the es register? i'd also like to know how it is possible to not display the data converted to ascii, but the raw hex values. thank you for helping me. the whole code is: Code: [BITS 16] [ORG 0] jmp 07C0h:start ; Declare the string that will be printed msg db 'Hello',13,10,0 start: ; Update the segment registers mov ax, cs mov ds, ax mov ax, 0x9000 mov ds, ax mov es, ax mov si, msg ; Print msg call print readsec: ; ; ES:BX = Location ; AX = Sector xor bx,bx mov ax, 0x201 mov cx, 0x0001 mov dx, 0x0080 int 0x13 mov si, bx call print jmp hang print: lodsb or al,al jz printd mov ah,0x0E mov bx,0x0007 int 0x10 jmp print printd: retn hang: ; Hang! jmp hang |
|||
13 Oct 2004, 15:39 |
|
drh3xx 13 Oct 2004, 18:20
You need to setup a table of db's '0123456789abcdef'
and then use the low nibble (bits 0->3) of al and use that value as an offset in to the table. With me so far? then print the character it points to using the bios call you already use. IMPORTANT: Remember the first character you want to print is the value in bits 4->7. If you get stuck let me know. I don't want to just do the code for you as you'd not learn anything |
|||
13 Oct 2004, 18:20 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.