Find the answer to your Linux question:
Results 1 to 2 of 2
Hi I'm trying to create a boot disk and I have a few questions In the code below I basically copy some assembler code from the boot file into the ...
  1. #1
    Linux Enthusiast gerard4143's Avatar
    Join Date
    Dec 2007
    Location
    Canada, Prince Edward Island
    Posts
    714

    [SOLVED] Creating a boot disk

    Hi I'm trying to create a boot disk and I have a few questions

    In the code below I basically copy some assembler code from the boot file into the array ch and then I set ch[510] = 0x55, ch[511] = 0xaa. Why do I set the the byte ch[510] = 0x55 and ch[511] = 0xaa?

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <fcntl.h>
    
    int main(int argc, char**argv)
    {
    	char ch[512];
    
    	int fd = open("boot", O_RDONLY);
    	read(fd, ch, 512);
    	close(fd);
    
    	fd = open("/dev/fd0", O_RDWR);
    	lseek(fd, 0, SEEK_CUR);
    
    	ch[510] = 0x55;
    	ch[511] = 0xaa;
    
    	write(fd, ch, 512);
    
    	close(fd);
    
    	exit(EXIT_SUCCESS);
    }
    and question two - how could I get the assembler code below to display some characters. The examples I found on the Internet said to:

    movw $0xb800, %ax
    movw %ax, %es
    to here I have no problems
    but the next two lines???
    I have to move $0x41 into the address 0000 with offset %es or $0xb800
    and move $0x1f into address 0001 with offset %es or $0xb800

    movb $0x41, into address 0000 with offset 0xb800
    movb $0x1f, into address 0000 with offset 0xb8000

    this I don't know how to do??


    Code:
    .section .data
    
    .section .bss
    
    .section .text
    	.global _start
    _start:
    
    loop1:
    		jmp	loop1
    Make mine Arch Linux

  2. #2
    Linux Enthusiast gerard4143's Avatar
    Join Date
    Dec 2007
    Location
    Canada, Prince Edward Island
    Posts
    714
    Found the answer...

    Code:
    .code16
    
    .section .data
    
    .section .bss
    
    .section .text
    	.global _start
    _start:
    		movw	$0xb800, %ax
    		movw	%ax, %es
    
    		movb	$0x41, %es:0
    		movb	$0x1f, %es:1
    loop1: 		
    		jmp	loop1
    Make mine Arch Linux

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...