flat assembler
Message board for the users of flat assembler.
Index
> OS Construction > Strange problem... probably with the Stack |
Author |
|
j.vimal 19 Mar 2006, 11:48
Hi
I wanted to make a full fledged kernel loader, that would present a prompt (Linux like ) in the beginning and allow me to browse through a FAT32 file system, and tell it what to load. For that, I wrote a decent MBR, with all details pertaining to a FAT file system embedded on it, like the Bios parameter block etc, that corresponds to a 124 MB USB disk. (Stole it from my previous MBR ) Secondly, I put my program at sector 12, (zero based index), just after some wierd info ... My program is 2 KB long. The MBR would load this sector 12 at 0x0:7E00 (just below the MBR) and jump to it. Everything goes fine till this point. The program also loads successfully. While executing, I just wanted to load 512 bytes of the FAT into the memory. (see code). It too loads successfully. I type 'd' at the prompt (just one command that I have added) to dump the FAT on to the screen. I should be getting values ... I got some. Fine till now... The problem is: the next time I press 'd', it dumps some values and gets stuck. I think this is some stack related problem. or, it doesnt return to the executing code properly. Could you please check it for me? Thanks Vimal
|
|||||||||||
19 Mar 2006, 11:48 |
|
LocoDelAssembly 19 Mar 2006, 23:24
Code: call _terminal_loop ;The main loop function hlt ;Stop ;**************************************** ;_terminal_loop ;**************************************** _terminal_loop: __loop: mov si,prompt call printf mov si,msg_buffer mov byte [ds:si],0 ;Flush out the previous input call gets ;gets a string into the buffer mov si,msg_buffer cmp byte [ds:si],'d' je dump jmp __loop ret ;**************************************** ;dump function ;**************************************** dump: ;Dumps the FAT Cache call endl mov si,FS_Type call printf ret First time your dump code returns but since you jumped to it instead of call it you return to the HLT instruction. After the execution of HLT (interruptions are not disabled so it stop execution of the program but not for too much time) you enter to the loop again but this time you didn't called _terminal_loop so the next time you return you will return to an unknown address. Check it out. Regards [edit]I forgot the fix, replace this: Code: cmp byte [ds:si],'d' je dump Code: cmp byte [ds:si],'d' jne __loop call dump |
|||
19 Mar 2006, 23:24 |
|
Madis731 20 Mar 2006, 07:52
And on lines 7 and 8 you should have:
Code:
ORG 0x7E00
use16
and in every <label> times <number> db <value> label should have a colon ( : ) following it. What assembler are you using? Maybe on your assembler it works... |
|||
20 Mar 2006, 07:52 |
|
j.vimal 20 Mar 2006, 11:52
Hey thanks for the help locodelassembly.
Now it works Anyway, Dex4u, thanks for the reply. Madis731, I am using NASM, for the time being. Probably I wouldnt have got this error if I had used FASM, which is a little more advanced in its syntax like calling functions etc. Thanks a lot! Vimal |
|||
20 Mar 2006, 11:52 |
|
UCM 20 Mar 2006, 21:54
the colon is not necessary, by the way.
`times' works like db,rb etc. and doesn't require a colon before it |
|||
20 Mar 2006, 21:54 |
|
Tomasz Grysztar 21 Mar 2006, 07:37
No, TIMES doesn't work like DB or RB. It works this way in NASM but I don't see any reason why it should.
|
|||
21 Mar 2006, 07:37 |
|
UCM 22 Mar 2006, 01:18
hmm thats odd, it worked before
|
|||
22 Mar 2006, 01:18 |
|
Tomasz Grysztar 22 Mar 2006, 07:44
With fasm it didn't, for sure.
|
|||
22 Mar 2006, 07:44 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.