Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 831 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
assembler help #319372
04/14/10 15:57
04/14/10 15:57

F
Fear411
Unregistered
Fear411
Unregistered
F



hey,

is there anyone who knows assembler and can help me with a problem (bootloader)?

Thanks,
Fear

Re: assembler help [Re: ] #319406
04/14/10 19:13
04/14/10 19:13
Joined: Jan 2003
Posts: 4,615
Cambridge
Joey Offline
Expert
Joey  Offline
Expert

Joined: Jan 2003
Posts: 4,615
Cambridge
assembler is a wide topic. what problem do you have?

Re: assembler help [Re: Joey] #319410
04/14/10 19:26
04/14/10 19:26

F
Fear411
Unregistered
Fear411
Unregistered
F



i dont know if the problem is in the bootloader or in the bootable floppy image,
but i created a bootload which should load a program, but the program doesn't get loaded.

Re: assembler help [Re: ] #319412
04/14/10 19:52
04/14/10 19:52
Joined: Aug 2005
Posts: 1,230
M
MichaelGale Offline
Serious User
MichaelGale  Offline
Serious User
M

Joined: Aug 2005
Posts: 1,230
Have you verified that your bootloader is exactly 512 bytes long and located in the first sector on your floppy?
Is your computer / virtual machine set to boot from the floppy?
What happens if you run your bootloader?


Your friendly mod is at your service.
Re: assembler help [Re: MichaelGale] #319415
04/14/10 20:02
04/14/10 20:02

F
Fear411
Unregistered
Fear411
Unregistered
F



yes
yes

The bootloader does everything he should except loading/jumping to the program.

Do you need some code?

Re: assembler help [Re: ] #319416
04/14/10 20:04
04/14/10 20:04
Joined: Aug 2005
Posts: 1,230
M
MichaelGale Offline
Serious User
MichaelGale  Offline
Serious User
M

Joined: Aug 2005
Posts: 1,230
I suppose so; otherwise it's hard to tell what is going wrong.


Your friendly mod is at your service.
Re: assembler help [Re: MichaelGale] #319422
04/14/10 20:48
04/14/10 20:48

F
Fear411
Unregistered
Fear411
Unregistered
F



Thats the bootloader

Click to reveal..
Code:
org 0x7C00		;start address of the bootloder that will load the kernel

xor ax, ax
mov ds, ax
mov es, ax
mov ss, ax
mov sp, ax


mov [bootdrive], dl 	;bootdrive stored by BIOS in DL.
                        ;we save it to [bootdrive] to play for safety.


mov si, strLoad		;show loading message
call printStr


;-----------------------

loadKernel:
  mov si, strDot	;show loading progress
  call printStr

  xor ax, ax         	;mov ax, 0 => function "reset"
  mov dl, [bootdrive] 	;boot drive
  int 0x13   		;reset floppy drivers
  jc loadKernel     	;CF set? try again

  mov si, strDot
  call printStr

			;set parameters for reading function
  mov ah, 0x2          	;read sectors 
  mov al, 10          	;read 10 sectors
  mov ch, 0          	;cylinder = 0
  mov cl, 2          	;sector = 2
  mov dh, 0          	;head = 0
  mov dl, [bootdrive] 	;boot drive
  mov bx, 0x8000	;start address of kernel

  int 0x13         	;read sectors
  jc loadKernel     	;CF set? try again

  mov si, strDot
  call printStr
  
  mov si, strDone
  call printStr

  jmp 0x8000

;-----------------------

printStr:
  mov ah, 0x0E      	;teletype output
.loop:   
  lodsb             	;grab a byte from SI
  test al, al       	;NULL?
  jz .done          	;if NULL exit
  int 0x10          	;print out the character!
  jmp .loop
.done:
  ret

;-----------------------

bootdrive db 0    	;boot drive, 0 = floppy
strLoad db "Loading kernel", 0
strDot db ".", 0
strDone db "[DONE]", 13, 10, 0
    
times 510-($-$$) hlt
db 0x55
db 0xAA



and thats the kernel:

Code:
[BITS 32]
[global kernelMain]
[extern _main]

kernelMain:
    jmp 0xffff:0x0000  ;reset pc
    jmp $



the c kernel is just a main function. At this stage i dont call it.

The linker script:
Code:
ENTRY(kernelMain)
SECTIONS
{
  .text  0x8000 : {
    *(.text)
  }
  .data  : {
    *(.data)
  }
  .bss  :  { 					
    *(.bss)
  }
}




and the program to create the floppy image:
Code:
char boot_buf[512];
	char kernel_buf[1024];
	char space_buf[1474560-512-1024] = {0};
	int floppy_desc, file_desc;

	file_desc = open("boot.bin", O_RDONLY);

        read(file_desc, boot_buf, 512);
        close(file_desc);

        floppy_desc = open("floppy.img", O_RDWR);

        lseek(floppy_desc, 0, SEEK_SET);
        write(floppy_desc, boot_buf, 512);

        file_desc = open("kernel.bin", O_RDONLY);
        read(file_desc, kernel_buf, 1024);
        close(file_desc);

        lseek(floppy_desc, 512, SEEK_SET);
        write(floppy_desc, kernel_buf, 1024);

	lseek(floppy_desc, 1024+512, SEEK_SET);
        write(floppy_desc, space, 1474560-512-1024);

        close(floppy_desc);




Last edited by Fear411; 04/15/10 14:19.
Re: assembler help [Re: ] #319438
04/14/10 21:21
04/14/10 21:21
Joined: Jan 2003
Posts: 4,615
Cambridge
Joey Offline
Expert
Joey  Offline
Expert

Joined: Jan 2003
Posts: 4,615
Cambridge
i'm not quite sure about all that absolute addressing stuff and asm linking but could it be that you're jumping into the text section of your kernel and not to the program itself?

edit: nevermind, i mixed data and text. (can't they call it code and data?)

Re: assembler help [Re: ] #319440
04/14/10 21:23
04/14/10 21:23
Joined: Aug 2005
Posts: 1,230
M
MichaelGale Offline
Serious User
MichaelGale  Offline
Serious User
M

Joined: Aug 2005
Posts: 1,230
You are trying to run a 32-bit program in real mode which is something you can't do. You need to switch to protected mode if you want to run your 32-bit kernel.


Your friendly mod is at your service.
Re: assembler help [Re: MichaelGale] #319522
04/15/10 14:29
04/15/10 14:29

F
Fear411
Unregistered
Fear411
Unregistered
F



mhh it doesnt work, also when i switch the program to 16bit.
But i have another problem. I used fat_imgen to generate the image and then inserted the bootloader and the kernel. But i changed it so it creates the image with the file above, but now it doesnt even boots.

Page 1 of 2 1 2

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1