Jump to content
xisto Community

vizskywalker

Members
  • Content Count

    1,084
  • Joined

  • Last visited

Everything posted by vizskywalker

  1. I think it is a great idea, and I can't wait for a follow up. Now if only I had a full version of VB instead of the introductory version. Thanks microscopic^earthling.
  2. If DarkBasic works like later versions of QBasic with library support, then DarkBasic on its own may not be powerful enough, but lbraries for it can improve it's capabilities. And while C++ probably is better for making games than DarkBasic, if you want to learn easily, I would start with DarkBasic, and then use C++ to make a library.
  3. Another reason why OS's were written in assembly was that assembly has very tight control over memory usage. When computers had at most maybe 128Mb of RAM, this was necessary. Assemb;y programs are also frequently smaller, so a large Os could fit onto a 1Gb hard drive with plenty of space left over. In this day and age, neither of these two issues are large concerns, so OS writing is moving out of the assembly realm and into higher the higher level realm. However, I still prefer assembly.
  4. Update for Linux/NASM:Okay, this update covers NASM for both Linux and Windows users. First, replace all "h"'s at the end of numbers with "0x", this is the NASM format to designate hex numbers. Then, remove lines 1 thorugh 3. Replace line 5 with "segment data", and line 9 with "segment code". Replace line 12 with "mov ax, data" and switch lines 13 and 14. Then, for Linux users, replace line 21 with "mov eax, 0x01" and replace line 22 with "int 0x80". That ought to do it, I haven't yet had a chance to test this for wither format, so if it doesn't work, please let me know.
  5. It seems like partial tangent is the full blown tangent function. Partial tangent takes the tangent of the value in ST0 with a domain of -2 x 10 ^63 to 2 x 10^63. It also pushes 1 onto the FPU stack. I see no reason to call it a partial tangent, but whatever floats there boats. And the guru's method of dealing with the rnd function is easy to do. Simply add the #P exception, because this exception is set if any truncation had to take place. There is also something known as a rounding mode. This is set by the RC field in the FPU control word. it is two bits, and setting them to 00 rounds to the nearest (based on the .5 rule), setting them to 10 rounds up (the ceiling function), setting them to 11 truncates (floor function), and setting them to 01 rounds down (My guess is that this changes the .5 rule so that .5 rounds down, but I'm not sure).
  6. Sure, PC-GPE is a great site for VGA programming, as is Denthor's tutorials, although I believe that Denthor works in Pascal and C with assembly inline code, so I mostly took theory from him. VGA is definitely going to be a topic that I cover in a later tutorial as well.
  7. VGA memory is actually stored in a special section of RAM, so no, you won't burn the graphics card. What you will do is overwrite data that is probably crucial to some other program, but restarting the computer will fix that. And haha, that's a funny joke.
  8. Actually, VGA routines are very easy and don't require knowledge of pixel clocking. Pixel clocking comes into play with SVGA. I'm not exactly sure what a Hello World calculator is, but I'd be happy to help with that, the screensaver, or any other projects. The next tutorial will go up probably on Sunday, and I almost have Linux and NASM figured out. I just need to take care of the headers. Happy programming.
  9. Keep in mind that because extension types are designed to reflect the type of file, some different files share the same extension type. For example, .BAS can either be a VB module or a QBasic program. .OBJ is used for files that the creating program terms as an object file, but what that means differs for the creating program. .SKN frequently means a skin file for a game, but for every different engine this format is different. And .IFF is an extension used by The Sims for objects, but it also serves another more practical purpose. Don't always assume that because a file has a certain extension, it is that kind of file.
  10. Thank you, and you're right. I shall begin the next tutorial with that.
  11. Very well, I concede that point, although optimization is something I'm still struglling with, especially in my assembler. I wonder if anything is ever truly fully optimized.
  12. I have an idea, but I'm not sure. If you look at the graph of tangent, it has many vertical asymptotes at multiples of pi. I think the partial tangent limits the domain to between 0 and pi. i'm not sure though, and I'm trying to find out because I am curious as well.
  13. There is an instruction to convert from floating point to integer: FRNDINT. I'm not 100% sure of the format because I don't use FPU instructions yet. However, if you looked at the intel documents I told you about, it is covered in part A of volume 2.
  14. True, but I doubt m_rahman is going to start by making an OS. He needn't worry about optimization until that point or the point of a major project.
  15. Just to let you know, in case you don't look there, my first tutorial is up in the Tutorials section fo the gorum.
  16. Okay, because assembly is an awesome language that is being viewed as archaic in the face of high level languages, I'm writing this series of tutorials. Note: This tutorial assumes a working knowledge of binary and hex. If you don't have a working knowledge of these number systems, and you are interested in learning assembler, let me know and I'll write a brief introduction to binary. Currently, until I can do some testing, this tutorial also only works for Windows and MS-DOS computers. If anyone with a Linux box is willing to test a routine for me, please let me know. The first thing you need to write assembly is a compiler. I use TASM which is made by Borland and can be found in their C++ Builder 5. All of the code provided here will be written for TASM. If you don't feel like buying the Borland C++ compiler you can also use NASM or FASM. I will try to point out how to change the code so it compiles under these two compilers, but I won't promise anything because I may forget. There are also some utilities that will prove very important. The first is Ralf Brown's Interrupt List. The second is the intel software developement manuals, but these are not needed at this point in time. Unlike higher level languages, assembly does not really have variables. It has two kinds of data storage units. The first, registers, you can actually perform operations on. The second, labels, are simply placeholders for information, like pointers in a higher level language. The 386 and newer series of chip have four basic registers. They are the accumulator register, ax, the base register, bx, the count register, cx, and the displacement register, dx. Each register is subdivide into two smaller registers, the high register, xh, and the low register, xl. The large register contains 16 bits, while the sub registers contain 8 bits. There is also the extended form of the register which simply adds an "e" to the beginning of the complete register's name. Thus we have eax, ebx, ecx, and edx. These registers contain 32 bits. (See Figure 1) Figure 1: The registers using the accumulator as an example |------------------------------EAX------------------------------| [][][][][][][][] [][][][][][][][] [][][][][][][][] [][][][][][][][] |--------------AX--------------| [][][][][][][][] [][][][][][][][] |------AH-----||------AL------| [][][][][][][][] [][][][][][][][] The 386 and beyond also have segment registers. They are ds, the data segment, cs, the code segment, es, the extra segment, and ss, the stack segment. There are also special registers like si, the source index, di, the destination index, bp, the base pointer, sp, the stack pointer, and ip, the instruction pointer. Finally we have the extra registers, gs, and fs. Labels appear in the data segment. They are simply words that stand for a spot in the memory. You can use a certain command to place data at that spot in memory, and then use the label to access the data. You can't, however, manipulate the data. It is also important to understand memory management. RAM is divided into 64kb segments. Every 16 bytes there is another segment, so the segments overlap. This means that the last segments in RAM don't have the full 64kb of memory. Individual bytes are addressed by their offset from the segment. To illustrate this, let's look at segment 1000 and start at the first offset. This is addressed like this 1000:0000. If we go to the 16th offset, we can address it in two ways: 1000:0010 or 1001:0000. What this boils down to is the offset from the beginning of RAM. If you place a 0 at the end of the segment, and a 0 at the beginning of the offset and look at it like this, 100000:00010, and then you add the segment and offset together, you get the offset from the beginning of RAM: 10010. I know this probably isn't that clear, but really, all you need to know is that memory is addressed by segment and offset. (See Figure 2) Figure 2: Segment and offset Style Memory Segment: 1000 [0][1][2][3][4][5][6][7][8][9][10][11][12][13][14][15] Segment: 1001 (But it is 16 bytes past 1000 so it is also 1000:0010) [0][1][2][3][4][5][6][7][8][9][10][11][12][13][14][15] Segment: 1002 (But it is 32 bytes past 1000 so it is also 1000:0020) [0][1][2][3][4][5][6][7][8][9][10][11][12][13][14][15] Segment: 1003 (But it is 48 bytes past 1000 so it is also 1000:0030) [0][1][2][3][4][5][6][7][8][9][10][11][12][13][14][15] Segment: 1004 (But it is 64 bytes past 1000 so it is also 1000:0040) [0][1][2][3][4][5][6][7][8][9][10][11][12][13][14][15] Segment: 1005 (But it is 80 bytes past 1000 so it is also 1000:0050) [0][1][2][3][4][5][6][7][8][9][10][11][12][13][14][15] And now the moment you have all been waiting for. The sample code. Copy the code below to a blank text document, then follow the instructions to compile it. ---Begin Copy Next Line--- 1: .MODEL SMALL ;define the type of program 2: .STACK 200h ;define the stack size 3: .386 ;state the use of 386 instructions 4: 5: .DATA ;define the data segment 6: 7: Message db "Hello World$" ;the data 8: 9: .CODE ;define the code segment 10: 11: Start: ;start the program 12: mov ax, seg Message ;move the segment of Message to the accumulator 13: mov dx, offset Message ;move the offset of Message to displacement register 14: mov ds, ax ;move segment of Message to data segment register 15: mov ah, 09h ;move 9 to the accumulator 16: int 21h ;perform interrupt 33 17: 18: mov ah, 00h ;move 0 to the accumulator 19: int 16h ;perform interrupt 22 20: 21: mov ax, 4c00h ;move the close program directive to the accumulator 22: int 21h ;perform interrupt 33 23: End Start ;the program ends ---End Copy on Previous Line--- Okay, now it's time to compile: Instructions for everyone 1) First, remove the line numbers, they are for reference only 3) Create a new folder on the C: drive and call it "asm" 2) Save the file as "Hello.asm" in the newly created folder TASM instructions 1) Open up the commad prompt 2) Change to the directory that contains TASM 3) Type in "tasm c:\asm\hello.asm" and hit enter 4) Type in "tlink c:\asm\hello.obj c:\asm\hello.exe" and hit enter 5) To run the program, type in "c:\asm\hello.exe" and hit enter FASM instructions 1) Change line 1 to "format MZ" 2) Change line 2 to "stack 200h" 3) Chaneg line 3 to "entry cod:Start" 4) Change line 5 to "segment dat" 5) Change line 9 to "segment cod" 6) Change line 12 to "mov ax, dat" 7) Change line 13 to "mov dx, Message" 8) Remove line 23 9) Save the file 10) Open up the command prompt 11) Change to the directory that contains FASM 12) Type in "fasm c:\asm\hello.asm c:\asm\hello.exe" and hit enter 13) To run the program type in "c:\asm\hello.exe" and hit enter NASM Instructions Forthcoming For the explanation of the above code: The first three lines set up the format of the file. Line 1 tells the compiler to use a .EXE header. Line 2 sets up the stack, a special storage area that will be covered in a later part. Line 3 sets up the entry point for FASM and says we want to have access to all of the instructions a 386 has for TASM. Lines 5 through 8 set up the data: Line 5 defines the data segment. Line 7 actually uses our first assembly instruction, "db". Db says insert data at this point in memory that will be stored and accessed in bytes. Lines 9 through 23 contain the code: Line 9 defines the code segment. Line 11 sets the start of the code. Line 12 has the second of our assembly instructions, "mov". Mov takes data from one place and places it in another, frequently one of those places is a register. This line moves the segment number of the data segment into the accumulator Line 13 moves the offset from the data segment of Message into the displacement register Line 14 moves the contents of the accumulator (the segment number of the data segment) into the data segment register. The reason it had to go into the accumulator first is that the segment registers cannot be accessed directly, onlyt hrough other registers. Line 15 moves 9 into the high byte of the accumulator. Line 16 is another assembly instruction, "int". Int performs a hardware interrupt, a special task. If you downloaded Ralf's interrupt list, open up the program to view the interrupts and open the interrupt list. Scroll down until you see "2109" in the left column. Click on this interrupt. If you notice, when you perform interrupt 21 for this function, writing a string to the screen, ah must be 9h, which we set up. Ds:dx must also point to the segment and offset of the string, which we have. The string must end with a "$", which, if you look at Message, it does. Line 18 moves 0 into the high byte of the accumulator. Line 19 performs interupt 22 which, when it has function 0, waits for a keypress to continue. Line 21 moves 4c00, which is a hex number, into the accumulator. Line 22 calls the DOS interrupt again, this time the subfunction exits the program. Line 23 states the end of the code. All of the "h"'s after every number mean that those numbers are in hexadecimal. Without those h's, the numbers would be assumed to be in decimal. The ";"'s after every line indicate a comma. Everything that comes after a ; on a line is ignored by the compiler. Review: Registers Memory MOV instruction DB instruction INT instruction Coming up next week: Basic arithmetic Explanation of the stack Questions? Comments? Something you'd like to see? Let me know and I'll add it in.
  17. That's perfectly okay, I enjoy the research because this is stuff I need to know as well, and Perl is an awesome language. I'm having some problems with networking in it, but that should go in the Perl forum. It looks the only control you have is over FPU, but in the 486+ line of Intel chips, that is really what the x87 is built for. As a matter of fact, the math coprocessor has been renamed by Intel to the x87 FPU. Incase you didn't know, FPU is the floating point equivalent of CPU. The processor on those chips is capable of handling most basic math instructions just as fast as with a coprocessor, so the x87 is really only needed for higher math functions. You are right that the x87 does more than floating point, it also handles sine, cosine, partial tangent, partial arctangent, 2^x - 1 instructions, y*log to the base 2 of x, and other functions. However, these instructions return floating point numbers, and probably also take floating point numbers. All of this information came out of the IntelArchitecture Software Developer's Manual.
  18. Yup, setting border equal to zero in an <a> tag does remove the border, thanks for the heads up. That makes the map only useful if you have one image you want split up.
  19. I haven't done anything other than a "Hello World" floppy-os either, os I'm not laughing. And m_rahman, I agree that optimization is important, but make sure you have the gist of assembly first as on most modern computers, optimization isn't too important, especially with how much space the program takes up. And you should definitely look at osknockout's post about clock cycles. If you have any more questions, feel free to ask. And get Ralph Brown's Interrupt List: http://forums.xisto.com/no_longer_exists/.
  20. To sum up the different assemblers, the ASM in each is just short for assembler. TASM is Turbo assembler produced by Borland, NASM is Netwide assembler, MASM is Microsoft assembler, and FASM is Flat assembler, which (osknockout will have to correct me if i'm wrong here) I believe is because its primary form of compilation is to flat binary, which means without a header to designate it as a certain kind of file. Also in the works is an assembler I am working on, but that's going to take a while. Unfortunately, too many people feel assembler is archaic, which means new languages are being written in old languages and unoptimized code is being compunded. Assembler is still used in the world of operating systems, so all of the joke sites that have "Windows source code" in a C style language are way out of touch. Assembler is also used whenever maximum optimization is needed, so the government uses it heavily, or at least should.
  21. Osknockout raises a good point. TASM really is used more for writing programs for TI calculators, which is why I picked it up. I agree that for OS writing you will definitely need NASM and FASM. TASM probably isn't one of the best choices actually, although I still stand by my claim that MASM is worse. And osknockout, if you'd let me, I'd love to take a look at a compiled form of your OS. I'm working on one off and on now, but haven't delved very far into protected mode, so it doesn't really do anything yet. The lack of parameters, by the way m_rahman, is because variables don't really exist in assembly, registers are small data storage and manipulation units inside the processor.
  22. Actually, it's not that bad. Anything you do in Windows can't access system critical files because Windows runs in protected mode. People don't like using assembly because they see no reason not to use a higher level language, and your assembly program won't work right if even one simple statement is wrong. It is also hard to debug assmebly programs by doing a step by step trace, but TASM has a debugger that allows you to do that. Mostly people just feel assembly is archaic.
  23. Okay, clock cycles only count what the true processor does. This is the 86 part of an 808x+ processor. Starting with the 386 (or maybe the 286), a math coprocessor became available. THis would be labeled xxx87 instead of xxx86. The processor sends data and an instruction to the math coprocessor for many math instructions such as MUL perhaps. THen the processor continues processing other things as long as possible while the coprocessor takes care of the math instruction. If the processor can't go any further and the math instruction has multiple independant parts, it may help out on the processing of the math instruction. When the math instruction is finished, the math coprocessor sends the data back to the processor to deal with. Once again this is only a rough sketch of how the system works. I don't know all of the details yet, but now I feel like researching them. and thanks for the reputation point.
  24. I'm glad you brought it up because I had forgotten the <map> tag even existed.
  25. First question first, I'd recommend TASM or NASM over MASM. To get TASM jsut search for a TASM download or purchase Borland C++. I wouldn't get TASM version 3 or less, just 4 or 5. For NASM go to https://sourceforge.net/projects/nasm/files/ and download the proper version for your OS. Be sure to get the DOS-32 version if you have windows. Your second question is kind of vague, if you mean OS, just make sure you have a PC instead of an Apple. If you have Linux, you need NASM. Just do a search for Assembly Tutorials, there are millions of them out there. Art of Assembly is a very good one. Early next week I plan on putting the first in a series of assembly tutorials in the tutorials section here, so let me ask you a question. Do you understand binary and hexadecimal. Because whether or not you do will determine how I start the tutorial. Last but not least, welcome to the world of assembly program, where few except the brave dare to trod.
×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.