; smaller ones or something. I'm just too lazy. Next version..\r
\r
\r
- commands: db 'ver', 0\r
- db 'help', 0\r
- db '?', 0\r
- db 'about', 0\r
- db 'cls', 0\r
- db 'clrscr', 0\r
- db 'reboot', 0\r
- db 'regdump', 0\r
- db 'time', 0\r
- db 'date', 0\r
- db 'delay', 0\r
- db 'vgatest', 0\r
- db 'memtest', 0\r
- db 'fddtest', 0\r
- db 0xFF ; end of command table\r
-\r
-\r
- call_table: dd show_ver ; commands.inc\r
- dd show_help ; commands.inc\r
- dd show_help ; commands.inc\r
- dd show_about ; commands.inc\r
- dd clrscr ; commands.inc\r
- dd clrscr ; comamnds.inc\r
- dd reboot ; commands.inc\r
- dd dump_regs ; debug.inc\r
- dd print_time ; time_date.inc\r
- dd print_date ; time_date.inc\r
- dd delay_test ; commands.inc\r
- dd vga_test ; commands.inc\r
- dd mem_test ; commands.inc\r
- dd fdd_test ; commands.inc\r
-\r
-\r
-\r
- ;--------------------------;\r
- ; not a valid command ;\r
- ;--------------------------;\r
- not_a_valid_cmd db 13,10,'No such command or program exists.', 0\r
-\r
- no_such_cmd:\r
- push esi\r
- push bx\r
-\r
- mov esi, not_a_valid_cmd\r
- mov bl, 0x04\r
- call print\r
-\r
- pop bx\r
- pop esi\r
- ret\r
-\r
-\r
- ;-------------------;\r
- ; show version ;\r
- ;-------------------;\r
- bos_ver_str db 13,10,'BOS version 0.05 by Christoffer Bubach, 2003-2005.', 0\r
- show_ver:\r
- push esi\r
- push bx\r
-\r
- mov esi, bos_ver_str\r
- mov bl, 0x07\r
- call print\r
-\r
- pop bx\r
- pop esi\r
- ret\r
-\r
-\r
- ;--------------------;\r
- ; show BOS help ;\r
- ;--------------------;\r
- bos_help_str db 13,10,13,10,' BOS 0.04 by Christoffer Bubach, 2003-2005.',13,10,\\r
- '--------------------------------------------',13,10,\\r
- 'Type a command and press ENTER to execute it.',13,10,13,10,\\r
- '"help" or "?" - Displays this text.',13,10,\\r
- '"ver" - Shows version information.',13,10,\\r
- '"about" - Shows information about the OS.',13,10,\\r
- '"cls" or "clrscr" - Clears the screen.',13,10,\\r
- '"memtest" - Shows memory info (and allocates/frees some, to test).',13,10,\\r
- '"vgatest" - Test some VGA stuff.',13,10,\\r
- '"fddtest" - Read and print bootsector from A:',13,10,\\r
- '"delay" - Tests the delay function for 5 s.',13,10,\\r
- '"time" - Prints current time.',13,10,\\r
- '"date" - Prints current date.',13,10,\\r
- '"regdump" - Dump some standard registers.',13,10,\\r
- '"reboot" - Restarts the computer.',0\r
- show_help:\r
- push esi\r
- push bx\r
-\r
- mov esi, bos_help_str\r
- mov bl, 0x07\r
- call print\r
-\r
- pop bx\r
- pop esi\r
- ret\r
-\r
-\r
- ;-----------------;\r
- ; show about ;\r
- ;-----------------;\r
- bos_about_str db 13,10,'About BOS',13,10,\\r
- 'Hmm.. I started with OS-dev in late 2003.. Anyway..',13,10,13,10,\\r
- 'Thanks for helping me get this far goes to:',13,10,\\r
- 'all people at mega-tokyo.com, osdever.net and flatassembler.net',13,10,\\r
- 'Robert ',153,'stling for Primula, http://ostling.no-ip.com/',13,10,\\r
- 'J.Thim for EelOS, http://www.ludd.luth.se/~ivileel/',13,10,\\r
- 'Tomasz Grysztar for fasm and fasmw, http://flatassembler.net/',13,10,\\r
- 'ASHLEY4, Candy, John S. Fine and Petroff Heroj.',0\r
+ commands:\r
+ db 'ver', 0\r
+ db 'help', 0\r
+ db '?', 0\r
+ db 'about', 0\r
+ db 'cls', 0\r
+ db 'clrscr', 0\r
+ db 'reboot', 0\r
+ db 'regdump', 0\r
+ db 'time', 0\r
+ db 'date', 0\r
+ db 'delay', 0\r
+ db 'vgatest', 0\r
+ db 'memtest', 0\r
+ db 'fddtest', 0\r
+ db 0xFF ; end of command table\r
+\r
+\r
+ call_table:\r
+ dd show_ver ; commands.inc\r
+ dd show_help ; commands.inc\r
+ dd show_help ; commands.inc\r
+ dd show_about ; commands.inc\r
+ dd clrscr ; commands.inc\r
+ dd clrscr ; comamnds.inc\r
+ dd reboot ; commands.inc\r
+ dd dump_regs ; debug.inc\r
+ dd print_time ; time_date.inc\r
+ dd print_date ; time_date.inc\r
+ dd delay_test ; commands.inc\r
+ dd vga_test ; commands.inc\r
+ dd mem_test ; commands.inc\r
+ dd fdd_test ; commands.inc\r
+\r
+\r
+\r
+ ;--------------------------;\r
+ ; not a valid command ;\r
+ ;--------------------------;\r
+ not_a_valid_cmd db 13,10,'No such command or program exists.', 0\r
+\r
+ no_such_cmd:\r
+ push esi\r
+ push bx\r
+\r
+ mov esi, not_a_valid_cmd\r
+ mov bl, 0x04\r
+ call print\r
+\r
+ pop bx\r
+ pop esi\r
+ ret\r
+\r
+\r
+ ;-------------------;\r
+ ; show version ;\r
+ ;-------------------;\r
+ bos_ver_str db 13,10,'BOS version 0.05 by Christoffer Bubach, 2003-2005.', 0\r
+ show_ver:\r
+ push esi\r
+ push bx\r
+\r
+ mov esi, bos_ver_str\r
+ mov bl, 0x07\r
+ call print\r
+\r
+ pop bx\r
+ pop esi\r
+ ret\r
+\r
+\r
+ ;--------------------;\r
+ ; show BOS help ;\r
+ ;--------------------;\r
+ bos_help_str db 13,10,13,10,' BOS 0.04 by Christoffer Bubach, 2003-2005.',13,10,\\r
+ '--------------------------------------------',13,10,\\r
+ 'Type a command and press ENTER to execute it.',13,10,13,10,\\r
+ '"help" or "?" - Displays this text.',13,10,\\r
+ '"ver" - Shows version information.',13,10,\\r
+ '"about" - Shows information about the OS.',13,10,\\r
+ '"cls" or "clrscr" - Clears the screen.',13,10,\\r
+ '"memtest" - Shows memory info (and allocates/frees some, to test).',13,10,\\r
+ '"vgatest" - Test some VGA stuff.',13,10,\\r
+ '"fddtest" - Read and print bootsector from A:',13,10,\\r
+ '"delay" - Tests the delay function for 5 s.',13,10,\\r
+ '"time" - Prints current time.',13,10,\\r
+ '"date" - Prints current date.',13,10,\\r
+ '"regdump" - Dump some standard registers.',13,10,\\r
+ '"reboot" - Restarts the computer.',0\r
+ show_help:\r
+ push esi\r
+ push bx\r
+\r
+ mov esi, bos_help_str\r
+ mov bl, 0x07\r
+ call print\r
+\r
+ pop bx\r
+ pop esi\r
+ ret\r
+\r
+\r
+ ;-----------------;\r
+ ; show about ;\r
+ ;-----------------;\r
+ bos_about_str db 13,10,'About BOS',13,10,\\r
+ 'Hmm.. I started with OS-dev in late 2003.. Anyway..',13,10,13,10,\\r
+ 'Thanks for helping me get this far goes to:',13,10,\\r
+ 'all people at mega-tokyo.com, osdever.net and flatassembler.net',13,10,\\r
+ 'Robert ',153,'stling for Primula, http://ostling.no-ip.com/',13,10,\\r
+ 'J.Thim for EelOS, http://www.ludd.luth.se/~ivileel/',13,10,\\r
+ 'Tomasz Grysztar for fasm and fasmw, http://flatassembler.net/',13,10,\\r
+ 'ASHLEY4, Candy, John S. Fine and Petroff Heroj.',0\r
show_about:\r
- push esi\r
- push bx\r
-\r
- mov esi, bos_about_str\r
- mov bl, 0x07\r
- call print\r
-\r
- pop bx\r
- pop esi\r
- ret\r
-\r
-\r
- ;-----------------------;\r
- ; clear the screen ;\r
- ;-----------------------;\r
- clrscr:\r
- call cls ; text.inc\r
- mov esi, prompt\r
- mov bl, 0x0E\r
- call print\r
- mov edi, cmd_buffer\r
- jmp shell ; no normal return, as it gives an extra line feed\r
-\r
-\r
-\r
- ;-------------;\r
- ; reboot ;\r
- ;-------------;\r
- reboot:\r
- call kbd_wait\r
- mov al, 0xFE\r
- out 0x64, al\r
- jmp $\r
- ret\r
-\r
-\r
- ;-----------------;\r
- ; delay test ;\r
- ;-----------------;\r
- bos_delay_str db 13,10,'~1 second has passed.', 0\r
- delay_test:\r
- mov ecx, 5\r
+ push esi\r
+ push bx\r
+\r
+ mov esi, bos_about_str\r
+ mov bl, 0x07\r
+ call print\r
+\r
+ pop bx\r
+ pop esi\r
+ ret\r
+\r
+\r
+ ;-----------------------;\r
+ ; clear the screen ;\r
+ ;-----------------------;\r
+ clrscr:\r
+ call cls ; text.inc\r
+ mov esi, prompt\r
+ mov bl, 0x0E\r
+ call print\r
+ mov edi, cmd_buffer\r
+ jmp shell ; no normal return, as it gives an extra line feed\r
+\r
+\r
+\r
+ ;-------------;\r
+ ; reboot ;\r
+ ;-------------;\r
+ reboot:\r
+ call kbd_wait\r
+ mov al, 0xFE\r
+ out 0x64, al\r
+ jmp $\r
+ ret\r
+\r
+\r
+ ;-----------------;\r
+ ; delay test ;\r
+ ;-----------------;\r
+ bos_delay_str db 13,10,'~1 second has passed.', 0\r
+ delay_test:\r
+ mov ecx, 5\r
.loop:\r
- push ecx\r
- mov ecx, 100\r
- call delay\r
- pop ecx\r
- mov esi, bos_delay_str\r
- mov bl, 0x07\r
- call print\r
- loop .loop\r
- ret\r
-\r
-\r
- ;----------------;\r
- ; VGA test ;\r
- ;----------------;\r
- bos_vga_str db 13,10,'It works..! :-D', 0\r
- vga_test:\r
-\r
- mov ax, 1 ; clear the screen\r
- call set_mode_0x13 ; set mode 0x13\r
-\r
- mov cx, 256 ; loop out some pixels\r
- .l1:\r
- mov bx, cx ; x value\r
- mov al, cl\r
- push cx\r
- mov cx, 50 ; y value\r
- call put_0x13_pixel\r
- pop cx\r
- loop .l1\r
-\r
- ; draw mario and some ground\r
- mov esi, mario\r
- mov ax, 260 ; x\r
- mov bx, 168 ; y\r
- mov cx, 20 ; height\r
- mov dx, 18 ; width\r
- call put_0x13_sprite ; in vga.inc\r
- mov esi, grass_l\r
- mov ax, 250\r
- mov bx, 186\r
- mov cx, 20\r
- mov dx, 14\r
- call put_0x13_sprite\r
- mov esi, grass_f\r
- mov ax, 265\r
- mov bx, 186\r
- mov cx, 20\r
- mov dx, 14\r
- call put_0x13_sprite\r
- mov esi, grass_ul\r
- mov ax, 280\r
- mov bx, 186\r
- mov cx, 20\r
- mov dx, 14\r
- call put_0x13_sprite\r
- mov esi, g_lefts\r
- mov ax, 280\r
- mov bx, 172\r
- mov cx, 20\r
- mov dx, 14\r
- call put_0x13_sprite\r
- mov esi, grass_l\r
- mov ax, 280\r
- mov bx, 158\r
- mov cx, 20\r
- mov dx, 14\r
- call put_0x13_sprite\r
- mov esi, g_earth\r
- mov ax, 300\r
- mov bx, 186\r
- mov cx, 20\r
- mov dx, 14\r
- call put_0x13_sprite\r
- mov esi, g_earth\r
- mov ax, 300\r
- mov bx, 172\r
- mov cx, 20\r
- mov dx, 14\r
- call put_0x13_sprite\r
- mov esi, grass_f\r
- mov ax, 300\r
- mov bx, 158\r
- mov cx, 20\r
- mov dx, 14\r
- call put_0x13_sprite\r
-\r
- call wait_key\r
-\r
- mov ax, 1 ; clear the screen\r
- call set_mode_0x03 ; set mode 0x03\r
-\r
- mov esi, bos_vga_str ; print that it worked!\r
- mov bl, 1\r
- call print\r
- ret\r
-\r
-\r
-\r
-\r
- ;--------------------------;\r
- ; fdd test ;\r
- ;--------------------------;\r
- fdd_test:\r
- mov bl, 13\r
- mov bh, 7 ; make newline\r
- call print_char\r
-\r
- mov ecx, 512\r
- mov edi, 0x80000\r
- .loop511:\r
- mov dword [edi], 'shit' ; set DMA buffer to shit, as a test\r
- add edi, 4\r
- sub ecx, 4\r
- cmp ecx, 0\r
- jne .loop511\r
-\r
- mov dh, 0x00 ; side\r
- mov dl, 0x00 ; drive\r
- mov ch, 0x00 ; track\r
- mov cl, 0x01 ; sector\r
- mov bl, 0x00 ; 1 = write\r
- call fdd_read_write\r
- jc .error\r
-\r
- mov esi, 0x80000 ; dma buffer\r
- mov ecx, 512\r
- .print:\r
- lodsb\r
- mov bl, al\r
- mov bh, 7\r
- call print_char ; print it. is it still\r
- dec ecx ; "shit" ?\r
- cmp ecx, 0\r
- jne .print\r
- jmp .end\r
-\r
- .error:\r
- mov bl, 13\r
- call print_char\r
- mov bl, 10\r
- call print_char\r
- mov bh, 0x40\r
- mov bl, 'E' ; error sign... :'(\r
- call print_char\r
-\r
- call fdd_reset\r
- mov al, 1\r
- call fdd_recal_seek ; do somthing about the error.. :P\r
-\r
- .end:\r
- ret\r
-\r
-\r
-\r
-\r
-\r
- ;------------------------------;\r
- ; memory test ;\r
- ;------------------------------;\r
-\r
- bos_mem_str1 db 13,10,'Performing memory test. (debugging allocs assume 32mb RAM)', 0\r
- bos_mem_str2 db 13,10,'Total installed memory (in bytes): ',0\r
- bos_mem_str3 db 13,10,13,10,'Memory chunks:',0\r
- bos_mem_str4 db 13,10,'Address Size Type Previous Next',0\r
- bos_mem_str5 db 13,10,'-------------------------------------------------------',0\r
- bos_mem_str6 db '0x',0\r
- bos_mem_str7 db 'Free ',0\r
- bos_mem_str8 db 'Used ',0\r
- bos_mem_str9 db 'None ',0\r
- bos_mem_str0 db ' ',0\r
- bos_mem_crlf db 13,10,0\r
- current_mem_pos dd 0\r
- next_free dd 0\r
-\r
- ;---------DEBUG---------\r
- test1_or_2 db 1\r
- test_address dd 0\r
- test_size dd 0\r
- test_address2 dd 0\r
- test_size2 dd 0\r
- ;---------END DEBUG---------\r
-\r
- mem_test:\r
- push eax\r
- push ebx\r
- push ecx\r
- push edx\r
-\r
- ;---------DEBUG---------\r
- cmp [test1_or_2],0\r
- je .free_the_test_block\r
-\r
- mov ebx, 0x1000000 ;first test\r
- mov [test_size2], ebx\r
- call allocate_mem\r
- mov [test_address2], ebx\r
-\r
- mov ebx, 0xE00000 ; second test\r
- mov ecx, ebx\r
- call allocate_mem\r
- push ebx\r
- push ecx\r
-\r
- mov ebx, 0x10000 ; third test\r
- mov [test_size], ebx\r
- call allocate_mem\r
- mov [test_address], ebx ; test allocation\r
-\r
- pop ecx\r
- pop ebx\r
- call free_mem\r
-\r
- mov [test1_or_2], 0\r
- jmp .end_test\r
- .free_the_test_block:\r
- mov ebx, [test_address]\r
- mov ecx, [test_size] ; and freeing\r
- call free_mem\r
- mov ebx, [test_address2]\r
- mov ecx, [test_size2] ; and freeing\r
- call free_mem\r
- mov [test1_or_2], 1\r
- .end_test:\r
- ;---------END DEBUG---------\r
-\r
- mov esi, bos_mem_str1\r
- mov bl, 0x07\r
- call print\r
- mov esi, bos_mem_str2\r
- mov bl, 0x07\r
- call print\r
- mov esi, bos_mem_str6\r
- mov bl, 0x04\r
- call print\r
- mov ebx, [ram_amount]\r
- mov cl, 0x04\r
- call print_hex32\r
-\r
- mov esi, bos_mem_str3\r
- mov bl, 0x07\r
- call print\r
- mov esi, bos_mem_str4\r
- mov bl, 0x07\r
- call print\r
- mov esi, bos_mem_str5\r
- mov bl, 0x07\r
- call print\r
-\r
- mov [current_mem_pos], 0\r
- mov eax, [first_free]\r
- mov [next_free], eax\r
-\r
- ;-------------------------;\r
- ; this is a used block ;\r
- ;-------------------------;\r
- .used:\r
- mov eax, [current_mem_pos]\r
- mov ebx, [next_free]\r
- cmp eax, [ram_amount] ; .free will always let us\r
- jae .end ; decide if we are to quit or not.\r
-\r
- cmp [next_free], 0\r
- jne .more_blocks\r
- mov ebx, [ram_amount] ; no next block, use ram size\r
- sub ebx, eax ; get size in ebx\r
- mov edi, 1\r
- call .print_mem_info\r
- jmp .end\r
-\r
- .more_blocks:\r
- sub ebx, eax\r
- mov edi, 1\r
- call .print_mem_info\r
-\r
- mov eax, [next_free]\r
- cmp eax, 0\r
- je .end\r
- mov ebx, [eax+8]\r
- mov [current_mem_pos], eax\r
- mov [next_free], ebx\r
-\r
- ;-------------------------;\r
- ; this is a free block ;\r
- ;-------------------------;\r
- .free:\r
- mov eax, [current_mem_pos] ; current pos. in eax\r
- mov ebx, [eax+4] ; current size in ebx\r
- mov ecx, [eax] ; prev pointer in ecx\r
- mov edx, [eax+8] ; next pointer in edx\r
- xor edi, edi\r
- call .print_mem_info\r
-\r
- add eax, ebx\r
- mov [current_mem_pos], eax\r
- jmp .used\r
-\r
- .end:\r
- pop eax\r
- pop ebx\r
- pop ecx\r
- pop edx\r
- ret\r
-\r
- ;-------------------------;\r
- ; print mem block info ;\r
- ;-------------------------;\r
- .print_mem_info:\r
- push eax ; current pos\r
- push ebx ; current size\r
- push ecx ; prev pointer\r
- push edx ; next pointer\r
- push edi ; 1 = used\r
-\r
- push ebx ; push size\r
- mov esi, bos_mem_crlf\r
- mov bl, 0x07\r
- call print\r
- mov esi, bos_mem_str6\r
- mov bl, 0x04\r
- call print\r
-\r
- push ecx ; push prev\r
- mov ebx, eax\r
- mov cl, 0x04\r
- call print_hex32\r
-\r
- mov esi, bos_mem_str0\r
- mov bl, 0x07\r
- call print\r
- mov esi, bos_mem_str6\r
- mov bl, 0x04\r
- call print\r
-\r
- pop ecx ; pop prev\r
- pop ebx ; pop size\r
- push ecx ; push prev\r
- mov cl, 0x04\r
- call print_hex32\r
- mov esi, bos_mem_str0\r
- mov bl, 0x07\r
- call print\r
-\r
- cmp edi, 1\r
- jne .print_free\r
- pop ecx ; pop prev\r
-\r
- mov esi, bos_mem_str8 ; it's used\r
- mov bl, 0x07\r
- call print\r
- mov esi, bos_mem_str9\r
- mov bl, 0x07\r
- call print\r
- mov esi, bos_mem_str9\r
- mov bl, 0x07\r
- call print\r
- jmp .print_end\r
-\r
- .print_free:\r
- mov esi, bos_mem_str7 ; it's free\r
- mov bl, 0x07\r
- call print\r
- mov esi, bos_mem_str6\r
- mov bl, 0x04\r
- call print\r
-\r
- pop ebx ; pop the pushed ecx\r
- mov cl, 0x04 ; into ebx instead.. ;)\r
- call print_hex32\r
- mov esi, bos_mem_str0\r
- mov bl, 0x07\r
- call print\r
- mov esi, bos_mem_str6\r
- mov bl, 0x04\r
- call print\r
- mov ebx, edx\r
- mov cl, 0x04\r
- call print_hex32\r
-\r
- .print_end:\r
- pop edi\r
- pop edx\r
- pop ecx\r
- pop ebx\r
- pop eax\r
- ret
\ No newline at end of file
+ push ecx\r
+ mov ecx, 100\r
+ call delay\r
+ pop ecx\r
+ mov esi, bos_delay_str\r
+ mov bl, 0x07\r
+ call print\r
+ loop .loop\r
+ ret\r
+\r
+\r
+ ;----------------;\r
+ ; VGA test ;\r
+ ;----------------;\r
+ bos_vga_str db 13,10,'It works..! :-D', 0\r
+ vga_test:\r
+\r
+ mov ax, 1 ; clear the screen\r
+ call set_mode_0x13 ; set mode 0x13\r
+\r
+ mov cx, 256 ; loop out some pixels\r
+ .l1:\r
+ mov bx, cx ; x value\r
+ mov al, cl\r
+ push cx\r
+ mov cx, 50 ; y value\r
+ call put_0x13_pixel\r
+ pop cx\r
+ loop .l1\r
+\r
+ ; draw mario and some ground\r
+ mov esi, mario\r
+ mov ax, 260 ; x\r
+ mov bx, 168 ; y\r
+ mov cx, 20 ; height\r
+ mov dx, 18 ; width\r
+ call put_0x13_sprite ; in vga.inc\r
+ mov esi, grass_l\r
+ mov ax, 250\r
+ mov bx, 186\r
+ mov cx, 20\r
+ mov dx, 14\r
+ call put_0x13_sprite\r
+ mov esi, grass_f\r
+ mov ax, 265\r
+ mov bx, 186\r
+ mov cx, 20\r
+ mov dx, 14\r
+ call put_0x13_sprite\r
+ mov esi, grass_ul\r
+ mov ax, 280\r
+ mov bx, 186\r
+ mov cx, 20\r
+ mov dx, 14\r
+ call put_0x13_sprite\r
+ mov esi, g_lefts\r
+ mov ax, 280\r
+ mov bx, 172\r
+ mov cx, 20\r
+ mov dx, 14\r
+ call put_0x13_sprite\r
+ mov esi, grass_l\r
+ mov ax, 280\r
+ mov bx, 158\r
+ mov cx, 20\r
+ mov dx, 14\r
+ call put_0x13_sprite\r
+ mov esi, g_earth\r
+ mov ax, 300\r
+ mov bx, 186\r
+ mov cx, 20\r
+ mov dx, 14\r
+ call put_0x13_sprite\r
+ mov esi, g_earth\r
+ mov ax, 300\r
+ mov bx, 172\r
+ mov cx, 20\r
+ mov dx, 14\r
+ call put_0x13_sprite\r
+ mov esi, grass_f\r
+ mov ax, 300\r
+ mov bx, 158\r
+ mov cx, 20\r
+ mov dx, 14\r
+ call put_0x13_sprite\r
+\r
+ call wait_key\r
+\r
+ mov ax, 1 ; clear the screen\r
+ call set_mode_0x03 ; set mode 0x03\r
+\r
+ mov esi, bos_vga_str ; print that it worked!\r
+ mov bl, 1\r
+ call print\r
+ ret\r
+\r
+\r
+\r
+\r
+ ;--------------------------;\r
+ ; fdd test ;\r
+ ;--------------------------;\r
+ fdd_test:\r
+ mov bl, 13\r
+ mov bh, 7 ; make newline\r
+ call print_char\r
+\r
+ mov ecx, 512\r
+ mov edi, 0x80000\r
+ .loop511:\r
+ mov dword [edi], 'shit' ; set DMA buffer to shit, as a test\r
+ add edi, 4\r
+ sub ecx, 4\r
+ cmp ecx, 0\r
+ jne .loop511\r
+\r
+ mov dh, 0x00 ; side\r
+ mov dl, 0x00 ; drive\r
+ mov ch, 0x00 ; track\r
+ mov cl, 0x01 ; sector\r
+ mov bl, 0x00 ; 1 = write\r
+ call fdd_read_write\r
+ jc .error\r
+\r
+ mov esi, 0x80000 ; dma buffer\r
+ mov ecx, 512\r
+ .print:\r
+ lodsb\r
+ mov bl, al\r
+ mov bh, 7\r
+ call print_char ; print it. is it still\r
+ dec ecx ; "shit" ?\r
+ cmp ecx, 0\r
+ jne .print\r
+ jmp .end\r
+\r
+ .error:\r
+ mov bl, 13\r
+ call print_char\r
+ mov bl, 10\r
+ call print_char\r
+ mov bh, 0x40\r
+ mov bl, 'E' ; error sign... :'(\r
+ call print_char\r
+\r
+ call fdd_reset\r
+ mov al, 1\r
+ call fdd_recal_seek ; do somthing about the error.. :P\r
+\r
+ .end:\r
+ ret\r
+\r
+\r
+\r
+\r
+\r
+ ;------------------------------;\r
+ ; memory test ;\r
+ ;------------------------------;\r
+\r
+ bos_mem_str1 db 13,10,'Performing memory test. (debugging allocs assume 32mb RAM)', 0\r
+ bos_mem_str2 db 13,10,'Total installed memory (in bytes): ',0\r
+ bos_mem_str3 db 13,10,13,10,'Memory chunks:',0\r
+ bos_mem_str4 db 13,10,'Address Size Type Previous Next',0\r
+ bos_mem_str5 db 13,10,'-------------------------------------------------------',0\r
+ bos_mem_str6 db '0x',0\r
+ bos_mem_str7 db 'Free ',0\r
+ bos_mem_str8 db 'Used ',0\r
+ bos_mem_str9 db 'None ',0\r
+ bos_mem_str0 db ' ',0\r
+ bos_mem_crlf db 13,10,0\r
+ current_mem_pos dd 0\r
+ next_free dd 0\r
+\r
+ ;---------DEBUG---------\r
+ test1_or_2 db 1\r
+ test_address dd 0\r
+ test_size dd 0\r
+ test_address2 dd 0\r
+ test_size2 dd 0\r
+ ;---------END DEBUG---------\r
+\r
+ mem_test:\r
+ push eax\r
+ push ebx\r
+ push ecx\r
+ push edx\r
+\r
+ ;---------DEBUG---------\r
+ cmp [test1_or_2],0\r
+ je .free_the_test_block\r
+\r
+ mov ebx, 0x1000000 ;first test\r
+ mov [test_size2], ebx\r
+ call allocate_mem\r
+ mov [test_address2], ebx\r
+\r
+ mov ebx, 0xE00000 ; second test\r
+ mov ecx, ebx\r
+ call allocate_mem\r
+ push ebx\r
+ push ecx\r
+\r
+ mov ebx, 0x10000 ; third test\r
+ mov [test_size], ebx\r
+ call allocate_mem\r
+ mov [test_address], ebx ; test allocation\r
+\r
+ pop ecx\r
+ pop ebx\r
+ call free_mem\r
+\r
+ mov [test1_or_2], 0\r
+ jmp .end_test\r
+ .free_the_test_block:\r
+ mov ebx, [test_address]\r
+ mov ecx, [test_size] ; and freeing\r
+ call free_mem\r
+ mov ebx, [test_address2]\r
+ mov ecx, [test_size2] ; and freeing\r
+ call free_mem\r
+ mov [test1_or_2], 1\r
+ .end_test:\r
+ ;---------END DEBUG---------\r
+\r
+ mov esi, bos_mem_str1\r
+ mov bl, 0x07\r
+ call print\r
+ mov esi, bos_mem_str2\r
+ mov bl, 0x07\r
+ call print\r
+ mov esi, bos_mem_str6\r
+ mov bl, 0x04\r
+ call print\r
+ mov ebx, [ram_amount]\r
+ mov cl, 0x04\r
+ call print_hex32\r
+\r
+ mov esi, bos_mem_str3\r
+ mov bl, 0x07\r
+ call print\r
+ mov esi, bos_mem_str4\r
+ mov bl, 0x07\r
+ call print\r
+ mov esi, bos_mem_str5\r
+ mov bl, 0x07\r
+ call print\r
+\r
+ mov [current_mem_pos], 0\r
+ mov eax, [first_free]\r
+ mov [next_free], eax\r
+\r
+ ;-------------------------;\r
+ ; this is a used block ;\r
+ ;-------------------------;\r
+ .used:\r
+ mov eax, [current_mem_pos]\r
+ mov ebx, [next_free]\r
+ cmp eax, [ram_amount] ; .free will always let us\r
+ jae .end ; decide if we are to quit or not.\r
+\r
+ cmp [next_free], 0\r
+ jne .more_blocks\r
+ mov ebx, [ram_amount] ; no next block, use ram size\r
+ sub ebx, eax ; get size in ebx\r
+ mov edi, 1\r
+ call .print_mem_info\r
+ jmp .end\r
+\r
+ .more_blocks:\r
+ sub ebx, eax\r
+ mov edi, 1\r
+ call .print_mem_info\r
+\r
+ mov eax, [next_free]\r
+ cmp eax, 0\r
+ je .end\r
+ mov ebx, [eax+8]\r
+ mov [current_mem_pos], eax\r
+ mov [next_free], ebx\r
+\r
+ ;-------------------------;\r
+ ; this is a free block ;\r
+ ;-------------------------;\r
+ .free:\r
+ mov eax, [current_mem_pos] ; current pos. in eax\r
+ mov ebx, [eax+4] ; current size in ebx\r
+ mov ecx, [eax] ; prev pointer in ecx\r
+ mov edx, [eax+8] ; next pointer in edx\r
+ xor edi, edi\r
+ call .print_mem_info\r
+\r
+ add eax, ebx\r
+ mov [current_mem_pos], eax\r
+ jmp .used\r
+\r
+ .end:\r
+ pop eax\r
+ pop ebx\r
+ pop ecx\r
+ pop edx\r
+ ret\r
+\r
+ ;-------------------------;\r
+ ; print mem block info ;\r
+ ;-------------------------;\r
+ .print_mem_info:\r
+ push eax ; current pos\r
+ push ebx ; current size\r
+ push ecx ; prev pointer\r
+ push edx ; next pointer\r
+ push edi ; 1 = used\r
+\r
+ push ebx ; push size\r
+ mov esi, bos_mem_crlf\r
+ mov bl, 0x07\r
+ call print\r
+ mov esi, bos_mem_str6\r
+ mov bl, 0x04\r
+ call print\r
+\r
+ push ecx ; push prev\r
+ mov ebx, eax\r
+ mov cl, 0x04\r
+ call print_hex32\r
+\r
+ mov esi, bos_mem_str0\r
+ mov bl, 0x07\r
+ call print\r
+ mov esi, bos_mem_str6\r
+ mov bl, 0x04\r
+ call print\r
+\r
+ pop ecx ; pop prev\r
+ pop ebx ; pop size\r
+ push ecx ; push prev\r
+ mov cl, 0x04\r
+ call print_hex32\r
+ mov esi, bos_mem_str0\r
+ mov bl, 0x07\r
+ call print\r
+\r
+ cmp edi, 1\r
+ jne .print_free\r
+ pop ecx ; pop prev\r
+\r
+ mov esi, bos_mem_str8 ; it's used\r
+ mov bl, 0x07\r
+ call print\r
+ mov esi, bos_mem_str9\r
+ mov bl, 0x07\r
+ call print\r
+ mov esi, bos_mem_str9\r
+ mov bl, 0x07\r
+ call print\r
+ jmp .print_end\r
+\r
+ .print_free:\r
+ mov esi, bos_mem_str7 ; it's free\r
+ mov bl, 0x07\r
+ call print\r
+ mov esi, bos_mem_str6\r
+ mov bl, 0x04\r
+ call print\r
+\r
+ pop ebx ; pop the pushed ecx\r
+ mov cl, 0x04 ; into ebx instead.. ;)\r
+ call print_hex32\r
+ mov esi, bos_mem_str0\r
+ mov bl, 0x07\r
+ call print\r
+ mov esi, bos_mem_str6\r
+ mov bl, 0x04\r
+ call print\r
+ mov ebx, edx\r
+ mov cl, 0x04\r
+ call print_hex32\r
+\r
+ .print_end:\r
+ pop edi\r
+ pop edx\r
+ pop ecx\r
+ pop ebx\r
+ pop eax\r
+ ret
\ No newline at end of file