The launcher implements a very simple function in the center of the screen; print a line of strings (assembler +c+red hat Linux implementation)

Source: Internet
Author: User

Programming: Start the program to implement a very simple function in the center of the screen; print a line of strings (assembler +c+red hat Linux implementation)

assembly language writing:

Boot.asm Startup program code:

; Our launcher implements very simple functions in the center of the screen

; Print a line of strings

org 07c00h; org directive explicitly tells the compiler that my program start address is 07c00h, not

; the original 00000

; int assembly directive INT 10h

MOV Ax,cs

MOV Es,ax

mov bp,msgstr; es:bp; The point is what we're going to show.

The address of the string

mov cx,12; string length

MOV dh,12; the line number displayed

MOV dl,36; display the column number

MOV bh,0; number of pages displayed

mov al,1; A string structure is displayed.

mov bl,0ch; display character attributes black-bottom Scarlet Letter

MOV ah,13h; explicitly call 13h subroutine

Msgstr:db "Hello my OSI"

int 10h

Times 210-($-$$) DB 0; Repeat n time each fill value is 0

DW 55aah

JMP $; Keep jumping to the current position is a dead loop. Note: $ is the current address.

Assembly Run Environment Legend:

650) this.width=650; the "alt=" launcher implements a very simple function in the center of the screen; print a line of strings (assembler +c+red Hat Linux implementation)-the writer-WELCOME MY BLOG. "Src=" Http://img2.ph.1 26.net/rv3nselsmle8chwrehmk3g==/3245125006597545695.jpg "style=" border:0px;margin:0px 10px 0px 0px; "/>

Virtual machine System: Write C code implementation under Red Hat Linux running environment:

Load the compiled BOOT.ASM launcher into the virtual machine and write the C language code in the virtual machine to implement the Boot.bin 512B launcher copy.

#include <stdio.h>

#include <fcnt1.h>

#include <sys/types.h>

#include <sys/stat.h>

int main (int argc,char *argv[])

{

int Fd_source;

int fd_dest;

int read_count = 0;

Char buffer[512]={0};

Fd_source=open ("Boot.bin", 0_rdonly);

if (fd_source<0)

{

Perror ("Open Boot.bin Error:");

return 0;

}

Fd_dest=ope ("virtual_floppy.vfd", 0_rwonly);

while ((Read_count=read (fd_source,buffer,512)) >0)

{

Write (Fd_dest,buffer,read_count);

memset (buffer,0,512);

}

printf ("Write Image ok!");

return 0;

}

Operating Procedure legend:


First step: Load the blank boot image that we wrote in the assembly.

Next, we're going to enter this command to write the C language code

650) this.width=650; the "alt=" launcher implements a very simple function in the center of the screen; print a line of strings (assembler +c+red Hat Linux implementation)-the writer-WELCOME MY BLOG. "Src=" H Ttp://img1.ph.126.net/docnlneut_hf_jp7_hnefa==/303148550017726501.jpg "style=" border:0px;margin:0px 10px 0px 0px; " />

Step Two: We have the C language Foundation, then we start to copy the 512B boot.bin start-up program.


650) this.width=650; the "alt=" launcher implements a very simple function in the center of the screen; print a line of strings (assembler +c+red Hat Linux implementation)-the writer-WELCOME MY BLOG. "Src=" Http://img0.ph.1 26.net/qtfhfjwryafwnbebdibqvg==/4805622277481413032.jpg "style=" border:0px;margin:0px 10px 0px 0px; "/>

Step three: Well, we've already written boot.bin.

650) this.width=650; the "alt=" launcher implements a very simple function in the center of the screen; print a line of strings (assembler +c+red Hat Linux implementation)-the writer-WELCOME MY BLOG. "Src=" Http://img2.ph.1 26.net/is7gw5ssf3bs9p0jqhy_-w==/705939241690819370.jpg "style=" border:0px;margin:0px 10px 0px 0px; "/>

650) this.width=650; the "alt=" launcher implements a very simple function in the center of the screen; print a line of strings (assembler +c+red Hat Linux implementation)-the writer-WELCOME MY BLOG. "Src=" Http://img0.ph.1 26.net/prd5g_8k_osz5m3jfv5xsq==/4854880398405824049.jpg "style=" border:0px;margin:0px 10px 0px 0px; "/>

Use WinImage to start the program we have written.


650) this.width=650; the "alt=" launcher implements a very simple function in the center of the screen; print a line of strings (assembler +c+red Hat Linux implementation)-the writer-WELCOME MY BLOG. "Src=" Http://img0.ph.1 26.net/cgyubwqrxzygwhz-ieyz6q==/6597961470588608232.jpg "style=" border:0px;margin:0px 10px 0px 0px; "/>

The author notes: Just learn the assembly, please Daniel do not spray!!!


This article is from the "struggle to improve each other" blog, please be sure to keep this source http://c10086.blog.51cto.com/6433044/1414030

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.