Some basic concepts:
ORG directive: Where to load into memory
Register: AX Cumulative Register CX count Register DX Data Register BX Base register SP stack pointer register BP base point pointer Register SI Source address register DI destination variable address register
BP, SP, SI, di do not have "L" and "H", to perform high and low bit operations to be assigned to AX
All 8 registers are only 16 bytes, in other words, even if we use these 8 registers, the CPU can only store a mere 16 bytes.
MOV si,msg The corresponding number of MSG sent to the SI (the number corresponding to the figure is org later calculated)
Memory is the external memory of the CPU
MOV byte[678],123 Memory number No. 678 address to save 123
Adjacent bytes, adjacent in ascending order of address
Only Bx,bp,si,di can be used to specify memory, AX,CX,DX,SP cannot be used to specify memory addresses because the CPU does not have a circuit to handle such instructions
Want to assign DX content to memory mov BX,DX mov al,byte[bx]
MOV source and destination number must be the same
BIOS basic input/output system INT 0x10; Control video card
A Web page of the BIOS:
http://community.osdev.info/? (at) Bios
Displays a character: ah=0x0e al=character code bh=0 bl=color Code
By following the steps above, a variety of values are sent to the register, which is displayed when the int 0x10 is called.
HLT let the CPU stop (not really stop), let the CPU into standby state
Memory distribution graph: http://community.osdev.info/? (at) Memorymap
0X00007C00--0X00007DFF; Boot area content loading address
;Hello-os;tab=4ORG 0x7c00;indicates the loading address of the program;The following section is a standard FAT12 format floppy disk-specific code JMPEntry DB 0x90 db"HELLOIPL" ;the name of the boot sector can make any stringDw + ;size of each sector (must be 512 bytes)Db1 ;the size of the cluster (must be 1 sectors)Dw1 ;Start position of fat (typically starting with the first sector)Db2 ;number of fat (must be 2)Dw224 ;the size of the root directory (typically set to 224)Dw2880 ;the size of the disk (must be 2880 sectors)DB 0xf0;type of disk (must be 0xf0)Dw9 ;fat Length (must be 9 sectors)Dw - ;1 tracks with several sectors (must be)Dw2 ;number of heads (must be 2)Dd0 ;do not try the partition (must be 0)Dd2880 ;override disk Size onceDb0,0, 0x29;fixedDD 0xFFFFFFFF;(may be) Volume code labelDb"Hello-os" ;Name of the disk (11 bytes)Db"FAT12" ;the name of the disk format (8 bytes)Resb - ;empty 18 bytes First;Program CoreEntry: MOVAx0 ;Initializing Registers MOVSs,axMOVsp,0x7c00MOVDs,axMOVEs,axMOVsi,msgPutloop: MOVAl,[si]ADDSI,1 ;add 1 to Si CMPAL,0 JEFinMOVah,0x0e;Display a text MOVBx the ;Specify character color INT0x10;calling the video card BIOS JMPPutloopFin: HLT ;let the CPU stop looping and wait for instructions JMPFin;Infinite Loopsmsg:DB 0x0a,0x0a;two-time line breakDb"Hello,world"DB 0x0a db0Resb 0x7dfe-$;fill in 0x00 until 0x001feDB 0x55, 0xaa;The following is an output from a section other than ScanDiskDB 0xf0, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00 resb4600DB 0xf0, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00 resb1469432
30-Day homemade operating system (next day)