mc 404
Questions and Answers

Send your questions by email and they will be answered on this page. Do not send the program source code.

Lab 1
Lab 2
Lab 3
Lab 4
Lab 5
Work. 1
Work. 2
Work. 3

Lab 3

Why when I use the 01h (or 11h) service from the 16h interruption and there is a key pressed, the same value is always returned?
Both services (01h and 11h) only serve to check if there is a button on the buffer on the keyboard. Although they say what the key is, it remains on the buffer on the keyboard. Therefore, you need to call the 00h or 10h services to read the key and remove it from the buffer. Use the services 01h or 11h when you want to know if there is a key pressed to perform an activity, as they are able to warn even that no key was pressed (Zero Flag).

Lab 4


Lab 5


Work. 2

How to read what's in the industry boat a floppy disk?
Use the DOS debug utility for this. You can take the opportunity to see an example from the boat using the command:
-l address disk sector number
then use address = c700, disk = 0, sector = 0, number = 1 to request the reading of the first sector of the diskette and place it in the position c700 of memory from the current segment. The command w debug does the reverse operation (writes a block of memory to a sector of the disk:
-w address disk sector number
Note that the boat recorded by DOS has a block of information after the first 3 bytes of the sector. And the program bypasses this block by placing an instruction jmp early on.

What does the NTLDR missing error message mean when I insert the floppy to boot?
It means that you formatted the floppy with Windows NT and that you did not install your boat loader. The NT always records a sector of boat standard warning that the floppy disk is not boat. The same is true for other Windows and DOS when you don't format the floppy with a system.

I'm having problems trying to allocate memory, however small the memory segment that I try to allocate the function returns saying that there is not enough memory. Would that be a limitation of .com programs? As I understand it, I need to allocate memory to create the buffer in the loader intaller, I was also trying to allocate memory to create an FCB, since it is easier to determine the file size through FCB´s.
In neither program will it be mandatory to allocate memory. Remember that buffer = variable. Then you just have to declare the variable with the size needed for the buffer. For example, if you want to declare a 210-byte variable, use:
variable resb 210

One of our tasks is to develop a program to be installed in the boot sector of the floppy disk that has the functionalities
described in the work script. Is it my impression or should this program have a maximum of 512 bytes to fit completely in this sector? If the answer is negative, where should I install the rest of the program? In the following sectors?
Really the boat it is only 512 bytes long and will only accept a program of up to 510 bytes (remember that the last two bytes contain the signature of the sector to show that it is executable). If your program fits in 510 bytes, better for you. The BIOS will load it directly when the computer boat. But if it is bigger than that, you should break it into two or more pieces and record it in different sectors. But the BIOS will continue to load only the first one,
 then you should also create a routine (which should be in the first sector) that loads the other sectors into memory and executes them as needed.

How should I end my program?
Your program must not end. To restart the computer, use the reset.

My program works perfectly on the command line, but when I write to the boat it does not work.
This question is very general, use the checklist below:
  • Check that the floppy disk is ok. Use the command "l c700 0 0 1"inside the debug to read the disk sector. If it fails, it could be a floppy problem;
  • Make sure you have changed the address of orgof your .asm file. Remember that the policy org it only informs the assembler that the program will be loaded in another memory location but does not generate any extra instructions. A .com program generated for an address other than 0x100 may not run correctly on the DOS command line;
  • Remember that when the computer starts running the boat, only the CS and IP registers have valid values. You must define initial values ​​for all other registers (through instructions in the program), mainly for segment registers (SS, ES and DS) and for stack registers (BP and SP).

Is it necessary to type the name of the file to be installed from the command line or is it enough to define it inside the .ASM file itself?
Just put it inside the .ASM itself. Don't forget to specify this in the report.

Work. 3

What should be the context of a process?
Basically, each process must have its own stack. To change the context, just save the registers on the stack, change the stack (SP) and restore the registers for the new process. Be careful only when setting the initial values ​​for each of the batteries.

When I write to video memory, does the program only work inside the debugger?
This is a problem with Windows NT (and other windows perhaps). The debugger is able to force you to emulate the video memory correctly. But you just need to call the debugger and run the program inside it since from there the DOS window you opened will accept direct access to the video memory.

I'm having problems with interrupt 1Ch.
Try to use interrupt 8h which is also called once per tick of the clock. It is interrupt 8 that calls 1Ch.

Since each process must be run for 1tick, how fast can you change the frequency of the process 4 sound?
Use a loop to do your timing. Your program will become machine dependent, but at least you will be able to change it during the execution of the process.