Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Address Bus:
- //0 - 2048 ... Console screen
- //2048 - 56 ... Keyboard
- //2104 - 20971520 ... Memory
- jmp codestart;
- define screen,65536;
- define keyboard,67584;
- define floppy,67640;
- inputbuffer: alloc 30;
- bufferpointer: db 0;
- commandline: db 0;
- commandchar: db '>';
- txtdiskinfo1: db 'You have ',0;
- txtdiskinfo2: db 'bytes total.',0;
- MemoryErrorFlag: db 0;
- MemoryErrorCounter: db 0;
- InterruptHandler:
- alloc 1024;
- MemoryError:
- mov #MemoryErrorFlag,1;
- inc #MemoryErrorCounter;
- iret;
- Wait: //001 - ecx = time in seconds |
- push eax;
- push ebx;
- timer ebx;
- Loop_001:
- timer eax;
- sub eax,ebx;
- cmp eax,ecx;
- jne Loop_001;
- pop ebx;
- pop eax;
- ret
- WriteString: //002 - esi = string; edi = CS-X/Y; ecx = color(RGBRGBX) |
- push esi;
- push edi;
- push es;
- push eax;
- mov es,screen;
- Loop_002:
- cmp #esi,0;
- je End_002;
- cmp #esi,13;
- je Newline_002;
- mov es:#edi,#esi;
- inc edi;
- mov es:#edi,ecx;
- inc edi;
- inc esi;
- jmp Loop_002;
- Newline_002:
- push ecx;
- push edx;
- inc #commandline;
- cmp #commandline,16;
- cg ScrollScreen;
- mov edx,#commandline;
- mov ecx,0;
- call XYToCS;
- mov edi,eax;
- inc esi;
- pop edx;
- pop ecx;
- jmp Loop_002;
- End_002:
- pop eax;
- pop es;
- pop edi;
- pop esi;
- ret
- ReadKey: //003 - | eax = pressed key
- push es;
- mov es,keyboard;
- mov eax,0;
- cmp es:#0,0;
- je End_003; //no keys in buffer, exit
- mov eax,es:#1;
- mov es:#1,eax;
- End_003:
- pop es;
- ret
- WaitForKey: //004 - | eax = Key
- push es;
- mov es,keyboard;
- Loop_004:
- cmp es:#0,0;
- jne Next_004;
- idle;
- jmp Loop_004;
- Next_004:
- mov eax,es:#1;
- mov es:#1,eax;
- pop es;
- ret
- strcmp: //005 - esi = string1; edi = string2 | eax = same?
- Loop_005:
- cmp #esi,0;
- je A_0_005;
- cmp #edi,0;
- je unsame;
- cmp #esi,#edi;
- jne unsame;
- inc esi;
- inc edi;
- jmp Loop_005;
- A_0_005:
- cmp #edi,0;
- jne unsame;
- mov eax,1;
- jmp End_005;
- unsame:
- mov eax,0;
- End_005:
- ret
- XYToCS: //006 - ecx = X; edx = Y | eax = CS
- mov eax,edx;
- mul eax,30;
- add eax,ecx;
- mul eax,2;
- ret
- WriteNum: //007 - esi = number; edi = position; ecx = color |
- push esi;
- push es;
- push eax;
- push ebx;
- push edi;
- push edx;
- mov es,screen;
- mov eax,esi;
- call GetNumberLength;
- mov eax,ebx;
- Loop_007:
- mov edx,10;
- fpwr edx,eax;
- mov ebx,esi;
- mod ebx,edx;
- div edx,10;
- div ebx,edx;
- fint ebx;
- add ebx,48;
- mov es:#edi,ebx;
- inc edi;
- mov es:#edi,ecx;
- inc edi;
- cmp eax,1;
- je End_007;
- dec eax;
- jmp Loop_007;
- End_007:
- pop edx;
- pop edi;
- pop ebx;
- pop eax;
- pop es;
- pop esi;
- ret
- ClearScreen: //008 - |
- push es;
- mov es,screen;
- mov es:#2041,1;
- idle;
- mov #commandline,0;
- pop es;
- ret
- WriteByte: //009 - esi = byte; edi = position; ecx = color |
- push es;
- mov es,screen;
- mov es:#edi,esi;
- inc edi;
- mov es:#edi,ecx;
- dec edi;
- pop es;
- ret
- space_010: db ' ';
- ProcessKey: //010 - eax = key |
- push ebx;
- cmp eax,154; //SHIFT
- je End_010;
- cmp eax,158; //CTRL
- je End_010;
- cmp eax,144; //CAPS
- je End_010;
- cmp eax,160; //WINDOWS
- je End_010;
- cmp eax,9; //TAB
- je End_010;
- cmp eax,127; //BACKSPACE
- je backspace_010;
- cmp eax,162; //the thing next to the right windows key
- je End_010;
- cmp eax,13; //Enter Key
- je enter_010;
- cmp eax,13;
- je End_010;
- cmp #bufferpointer,29;
- je End_010;
- mov ebx,inputbuffer;
- add ebx,#bufferpointer;
- mov #ebx,eax;
- inc #bufferpointer;
- jmp End_010;
- backspace_010:
- cmp #bufferpointer,0;
- je End_010;
- mov ebx,inputbuffer;
- dec #bufferpointer;
- add ebx,#bufferpointer;
- mov #ebx,0;
- mov esi,#space_010;
- mov ecx,#bufferpointer;
- inc ecx;
- mov edx,#commandline;
- call XYToCS;
- mov edi,eax;
- mov ecx,000999;
- call WriteByte;
- jmp End_010;
- enter_010:
- ce ProcessInput;
- jmp End_010;
- End_010:
- pop ebx;
- ret
- strlen: //011 - esi = string | eax = length
- push esi;
- mov eax,0;
- Loop_011:
- cmp #esi,0;
- je End_011;
- inc esi;
- inc eax;
- jmp Loop_011;
- End_011:
- pop esi;
- ret
- scmdhelp_012: db 'help',0;
- scmdclear_012: db 'clear',0;
- scmddiskinfo_012: db 'diskinfo',0;
- scmdformat_012: db 'format',0;
- txtHelp_012: db 'The current commands are:',13;
- db 'help - displays this help',13;
- db 'clear - clears the screen',13;
- db 'diskinfo - disk information',13;
- db 'format - format the disk',13,0;
- txtUnknownCommand_012: db 'The command could not be found',0;
- txtFormat1_012: db 'Formatting disk...',0;
- txtFormat2_012: db 'Disk formatted.',0;
- ProcessInput: //012 - |
- push esi;
- push eax;
- push edi;
- push ecx;
- push edx;
- mov #bufferpointer,0;
- mov esi,inputbuffer;
- //help
- mov edi,scmdhelp_012;
- call strcmp;
- cmp eax,1;
- je cmdhelp_012;
- //clear
- mov edi,scmdclear_012;
- call strcmp;
- cmp eax,1;
- je cmdclear_012;
- //diskinfo
- mov edi,scmddiskinfo_012;
- call strcmp;
- cmp eax,1;
- je cmddiskinfo_012;
- //format
- mov edi,scmdformat_012;
- call strcmp;
- cmp eax,1;
- je cmdformat_012;
- //unknown command
- inc #commandline;
- cmp #commandline,16;
- cg ScrollScreen;
- mov esi,txtUnknownCommand_012;
- mov ecx,0;
- mov edx,#commandline;
- call XYToCS;
- mov edi,eax;
- mov ecx,000999;
- call WriteString;
- inc #commandline;
- cmp #commandline,16;
- cg ScrollScreen;
- jmp End_012;
- cmdclear_012:
- call ClearScreen;
- jmp End_012;
- cmdhelp_012:
- inc #commandline;
- cmp #commandline,16;
- cg ScrollScreen;
- mov esi,txtHelp_012;
- mov ecx,0;
- mov edx,#commandline;
- call XYToCS;
- mov edi,eax;
- mov ecx,000999;
- call WriteString;
- jmp End_012;
- cmddiskinfo_012:
- inc #commandline;
- cmp #commandline,16;
- cg ScrollScreen;
- mov ecx,0;
- mov edx,#commandline;
- call XYToCS;
- mov edi,eax;
- mov esi,txtdiskinfo1;
- mov ecx,000999;
- call WriteString;
- add edi,18;
- call GetFloppySize;
- mov esi,eax;
- call WriteNum;
- push ebx;
- mov eax,esi;
- call GetNumberLength;
- mov ecx,ebx;
- pop ebx;
- inc ecx;
- mul ecx,2;
- add edi,ecx;
- mov esi,txtdiskinfo2;
- mov ecx,000999;
- call WriteString;
- inc #commandline;
- jmp End_012;
- cmdformat_012:
- inc #commandline;
- cmp #commandline,16;
- cg ScrollScreen;
- mov ecx,0;
- mov edx,#commandline;
- call XYToCS;
- mov esi,txtFormat1_012;
- mov edi,eax;
- mov ecx,000999;
- call WriteString;
- inc #commandline;
- call FormatDisc;
- mov ecx,0;
- mov edx,#commandline;
- call XYToCS;
- mov esi,txtFormat2_012;
- mov edi,eax;
- mov ecx,000999;
- call WriteString;
- inc #commandline;
- jmp End_012;
- End_012:
- pop edx;
- pop ecx;
- pop edi;
- pop eax;
- pop esi;
- call ClearInputBuffer;
- call WriteCommandChar;
- ret
- ClearInputBuffer: //013 - |
- push ecx;
- push esi;
- mov ecx,29;
- Loop_013:
- mov #bufferpointer,29;
- sub #bufferpointer,ecx;
- mov esi,inputbuffer;
- add esi,#bufferpointer;
- mov #esi,0;
- loop Loop_013;
- mov #bufferpointer,0;
- pop esi;
- pop ecx;
- ret
- ScrollScreen: //014 - |
- push es;
- mov es,screen;
- mov es:#2038,1;
- dec #commandline;
- pop es;
- ret
- GetFloppySize: //015 - | eax = size
- push es;
- push ebx;
- push ecx;
- push edx;
- mov es,floppy;
- mov ebx,262144; //stepsize
- mov eax,0; //output
- mov ecx,0; //the byte to be checked
- mov edx,0;
- mov #MemoryErrorFlag,0;
- mov es:#ecx,5;
- cmp es:#ecx,5;
- jne Null_015;
- cmp #MemoryErrorFlag,1;
- je Null_015;
- mov es:#ecx,0;
- add ecx,ebx;
- Loop_015:
- mov #MemoryErrorFlag,0;
- mov es:#ecx,5;
- cmp es:#ecx,5;
- jne NP_015;
- cmp #MemoryErrorFlag,1;
- je NP_015;
- mov es:#ecx,0;
- cmp ebx,1;
- je End_P_015;
- add ecx,ebx;
- jmp Loop_015;
- NP_015:
- mov #MemoryErrorFlag,0;
- cmp ebx,1;
- je End_NP_015;
- div ebx,2;
- sub ecx,ebx;
- jmp Loop_015;
- End_P_015:
- mov eax,ecx;
- inc eax;
- jmp End_015;
- End_NP_015:
- mov eax,ecx;
- jmp End_015;
- Null_015:
- mov eax,0;
- mov #MemoryErrorFlag,0;
- jmp End_015;
- End_015:
- pop edx;
- pop ecx;
- pop ebx;
- pop es;
- ret
- CSToXY: //016 - eax = CS | ecx = X; edx = Y
- mov ecx,eax;
- mod ecx,30;
- mov edx,eax;
- sub edx,ecx;
- div eax,30;
- ret
- WriteCommandChar: //017 - |
- mov esi,#commandchar;
- mov ecx,0;
- mov edx,#commandline;
- call XYToCS;
- mov edi,eax;
- mov ecx,999;
- call WriteByte;
- ret
- WriteInputBuffer: //018 - |
- mov esi,inputbuffer;
- mov ecx,1;
- mov edx,#commandline;
- call XYToCS;
- mov edi,eax;
- mov ecx,000999;
- call WriteString;
- ret
- GetNumberLength: //019 - eax = number | ebx = length
- cmp eax,0;
- je Null_019;
- flog10 ebx,eax;
- fint ebx;
- inc ebx;
- jmp End_019;
- Null_019:
- mov ebx,1;
- jmp End_019;
- End_019:
- ret
- Disc_020:
- db 0,0,0,'Xandaros',512,0; //last 0: FAT_Size
- FormatDisc: //020 - |
- push eax;
- push esi;
- push edi;
- push ecx;
- call GetFloppySize; //EAX = Gg
- sub eax,8205;
- div eax,513;
- fint eax; //EAX = FAT_SIZE
- mov edi,Disc_020;
- add edi,12;
- mov #edi,eax; //put FAT_Size in
- mov edi,floppy;
- mov esi,Disc_020;
- mcopy 13;
- mov ecx,eax;
- mul ecx,17;
- inc ecx;
- Loop_020:
- mov edi,floppy;
- add edi,12;
- add edi,ecx;
- mov #edi,0;
- loop Loop_020;
- pop ecx;
- pop edi;
- pop esi;
- pop eax;
- ret
- strmid: //021 - esi = string; edi = output-string; eax = start; ebx = length |
- push ecx;
- push esi;
- add esi,eax;
- dec esi;
- mov ecx,ebx;
- Loop_021:
- mov #edi,#esi;
- inc edi;
- inc esi;
- loop Loop_021;
- mov #edi,0;
- pop esi;
- pop ecx;
- ret
- MakeFile: //022 - esi = filename(string; length MUST be 8, not zero-terminated); edi = extension (length 3, not zero-terminated) |
- push edx;
- push ecx;
- push eax;
- push es;
- mov es,floppy; //Floppy
- add es,13; //RootDirectory
- mov ecx,512;
- Loop1_022:
- mov edx,512;
- sub edx,ecx; //EDX = 512 - ECX
- mul edx,16; //Each RootDirectory entry has 16 byte
- cmp es:#edx,0; //If the first character of the file name is 0,
- je Found_022; //We found some space
- loop Loop1_022;
- je End_022; //Otherwise all 512 files are taken
- Found_022:
- mov port1,1;
- mov ecx,8;
- Loop2_022:
- mov eax,esi;
- add eax,8;
- sub eax,ecx;
- mov es:#edx,#eax;
- inc edx;
- loop Loop2_022;
- mov ecx,3;
- Loop3_022:
- mov eax,edi;
- add eax,3;
- sub eax,ecx;
- mov es:#edx,#eax;
- inc edx;
- loop Loop3_022;
- mov #edx,0;
- inc edx;
- mov #edx,0;
- inc edx;
- mov #edx,0;
- inc edx;
- mov #edx,0;
- inc edx;
- mov #edx,0;
- // mov ecx,floppy;
- // add ecx,12;
- // mov ecx,#ecx; //Get FAT size - why?
- // mov eax,floppy;
- // add eax,8205; //FAT - why?
- // Loop1_022:
- // cmp #eax,0;
- // je SpaceFound_022;
- // inc eax;
- // loop Loop1_022;
- // jmp End_022;
- //
- // SpaceFound_022:
- // mov es:#eax,-1;
- // mov ecx,eax;
- // sub ecx,floppy;
- // sub ecx,8205;
- // out 0,ecx;
- // mul ecx,16;
- // mov eax,floppy;
- // add eax,12;
- // add eax,ecx;
- //
- // mov ecx,8;
- // Loop2_022:
- // mov edx,esi;
- // add edx,8;
- // sub edx,ecx;
- // mov #eax,#edx;
- // inc eax;
- // loop Loop2_022;
- //
- // mov ecx,3;
- // Loop3_022:
- // mov edx,edi;
- // add edx,3;
- // sub edx,ecx;
- // mov #eax,#edx;
- // inc eax;
- // loop Loop3_022;
- //
- // mov #eax,0;
- // inc eax;
- // mov #eax,0;
- // inc eax;
- // mov #eax,0;
- // inc eax;
- // mov #eax,0;
- // inc eax;
- // mov #eax,0;
- End_022:
- pop es;
- pop eax;
- pop ecx;
- pop edx;
- ret
- Filename: db 'asdfghjk';
- Filename2: db 'sadfghjk';
- Extension: db 'txt';
- codestart:
- stp;
- sti;
- lidtr InterruptHandler;
- mov edi,InterruptHandler;
- add edi,28;
- mov #edi,MemoryError;
- inc edi;
- mov #edi,0;
- inc edi;
- mov #edi,0;
- inc edi;
- mov #edi,32;
- call ClearScreen;
- mov edx,0;
- mov port1,0;
- mov port2,0;
- mov port3,0;
- mov port4,0;
- mov port5,0;
- mov port6,0;
- mov port7,0;
- mov port8,0;
- call WriteCommandChar;
- realstart:
- call ReadKey;
- cmp eax,0;
- cne ProcessKey;
- je realstart;
- call WriteInputBuffer;
- //call FormatDisc;
- //
- //mov esi,Filename;
- //mov edi,Extension;
- //call MakeFile;
- //mov esi,Filename2;
- //call MakeFile;
- jmp realstart;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement