ECE291
Computer Engineering II
Polychronopoulos, Spring 2000

Machine Problem 4 and 5: Networked Quake2D

Assigned Thursday, March 23, 2000
Purpose Protected Mode, Video Mode Graphics, Networking, Mouse
Points 100
Checkpoint Due Date Tuesday April 4 5:00pm
Final Due Date Tuesday April 11 5:00pm (April 4, 5:00pm for 5 point bonus)
This MP is under (somewhat constant) improvement.

Introduction

This double-MP introduces many concepts. Some of them are very alien to the way the course has worked through now. Reading through the entirety of the MP writeup is highly suggested!

Having made your way through the previous four Machine Problems, and the exam, you've shown yourself to be a true ECE 291 student. Now you can almost see the carrot dangling out there, just this double-MP, a final project, and two exams away.

So we're stepping up the difficulty - and the rewards are commensurate. Have you ever looked at what we're doing in assembly and wondered how something like Quake is possible? The sheer size alone is daunting - how can you fit that in 64k? You can't. How about a few segments, like you started using in MP3? Nope - still too big.

Hey wait! What about the fact that text mode is obviously not up to the task of representing a 3D world, much less a complex 2D world?

Enter Protected Mode (often referred to as P-Mode), a powerful way of gaining access to as much memory as the computer has to offer. With this power comes some limitations, and differences. Right off the bat you'll have to adjust to writing for NASM instead of MASM. Here's a quick reference on the surface differences between the two. Similarly, you are welcome to read through the entire MP tutorial. For more about the development environment (and how to install it at home), see this page from the tutorial.

Be sure to read carefully through the preliminary procedure as some things have changed from previous MPs. This includes the build process, as you'll be using tools that are much more like Unix tools (make and gcc) than the Microsoft Unix-ish tools you've been using in past MPs.

To help make the transition to protected mode easier, a large library has been provided to you. The documentation for all the library functions is online, and even the entire source code is available in the MP's lib/ directory! Please notice that all functions the library provides and all the functions you will be writing for this MP conform to the C calling convention. This means the arguments are passed on the stack in reverse order, you are free to modify (without saving) eax, ebx, ecx, and edx (this also means that you should not expect these registers to be preserved when calling a library function), and the return value is in eax/ax/al (depending on its size). A few macros have been provided to make coding C procedures easier. Also, a very large library, written in assembly and with source, has been given to you to make coding some parts of this MP much easier. The source can be found in the lib/ directory of the MP, and the Library Reference is available online to help you find the functions you need.

Also remember that you now have full usage of the entire Intel instruction set, including all 32-bit registers and extended addressing modes. This means that you are free to address with any register, and even have an index register multiplied by a power of two, e.g.: mov eax, [edx+ecx*4+5]. You can use this to your definite advantage when you need to multiply by 3, 5, or 9: just look up the LEA instruction and think about the advanced addressing modes. Don't forget that you can't access the high 16 bits of the 32 bit registers directly, you either need to clear, shift, or load out of memory to set those bits. Feel free to look at the library source code for ideas and examples of how to use the extended registers and addressing modes!

The final three things that enter into play here are graphics, mouse control, and networking. The first two are amazingly easy to use, both conceptually and otherwise. There is a library for the third, but its use can seem a little obtuse. Time to move on to the Problem Description pages, and then start programming.

Problem Description

The Procedures

Preliminary Procedure

Monitor the newsgroup and this on-line section for revisions to the MP or to the write-up

Checkpoint

Because this MP is so large, we have made a checkpoint due a week before the final due date. You must turn the following procedures into a TA before the checkpoint due date. Print off the Checkpoint Gradesheet and demonstrate to a TA that you have completed the procedures on it. There will be no early points for handing in the checkpoint early, but it is in your best interest to do so, to give yourself more time on the remainder of the MP (and time to complete the bonus procedures). The checkpoint is worth 25% of your total MP grade, so don't forget to turn it in!

Final Steps

  1. Verify that your program meets all requirements for handin.
  2. Print a copy of the MP4 grading sheet.
  3. Demonstrate MP4.EXE to a TA or to the instructor.
  4. Be prepared to answer questions about any aspect of the operation of your program. The TAs will not accept an MP if you cannot fully explain all operations of your code.
  5. Handin in your program by running:

  6. A:\Handin YourWindowsLogin
  7. Print your MP4.ASM 4 pages per page and double sided. If you don't know how to do this ask a TA for assistance.
  8. Staple the MP4 grading sheet to the front of your MP4.ASM file and give both to the same TA that approved your demonstration.


mp4.asm