
Basically, DOS Assembly is designed for a CISC ( Complex Intruction Set Code) Processor, while MIPS is designed for a RISC (Reduced Instruction Set Code) Processor. What does this mean to you? Good question! What this means is that DOS Assembly is going to have a much larger command set than MIPS will, and, in general you'll have a lot more leway with DOS ASM code than one would have with MIPS. For example, there is a HUGE difference in the amount and kinds of jump or branch instructions in the two langauges. Most MIPS compilers will accept alternative branches and jumps, but translate them to the standard ones opon compilation.
Anyway, the first thing to learn 'bout Assembly is the register naming conventions. The following tables show how the registers are named in both DOS ASM and MIPS :
| Number | Name | Description |
| $0 | zero | Always Contains 0 |
| $1 | $at | Reserved for Internal Assembler |
| $2,$3 | $v0,$v1 | Syscall Return, Expression Evaluation |
| $4-$7 | $a0-$a3 | Function Call and Syscall Parameters |
| $8-$15 | $t0-$t7 | Temporaries, volatile |
| $16-$23 | $s0-$s7 | Temporaries, nonvolatile |
| $24-$25 | $t8-$t9 | Temporaries, volatile |
| $26,$27 | $k0,$k1 | Reserved for Operating System |
| $28 | $gp | Pointer to Global Static Memory |
| $29 | $sp | Stack Pointer |
| $30 | $fp | Frame Pointer |
| $31 | $ra | Function Call Return Address |
| 32-bit (386+) | 16-bit | 8-bit | Description |
| eax | ax | ah | ACCUMULATOR - Usually used for basic math, ax and al are the most common area for system call return values. ax is probably the most useful register. |
| al | |||
| ebx | bx | bh | BASE - Also used for a lot of the same operations as ax, bx has far fewer special functions. Returns of 32-bit numbers from system calls are often held in dx:bx with bx as the offset register. |
| bl | |||
| ecx | cx | ch | COUNTER - Also used for a lot of the same operations as ax, cx has fewer special functions. The main special function of cx is the fact that it is used as the loop counter for assembly loop and rep commands. |
| cl | |||
| edx | dx | dh | DATA - Also used for a lot of the same operations as ax, dx has far fewer special functions. Returns of 32-bit numbers from system calls are often held in dx:bx with dx as the base register. |
| dl | |||
| esp | sp | STACK POINTER - one of the most important pointer registers. It points to the offset of the stack in memory, and is therefore a crucial register to know about and use. One can usually find sp being used as the offset register for ss. | |
| ss | STACK SEGMENT - is another crucially important register, as it points to the base of the stack. One can usually find ss being used as the base register for sp. | ||
| ebp | bp | BASE POINTER - yet another pointer register, this one has a more general purpose. Its used for just about anything, although it is commonly used to measure an offset into the stack for some reason of another. | |
| cs | CODE SEGMENT - points to the location in memory of currently executing code. Most assemblers won't let you alter it... for a *very* good reason! | ||
| eip | ip | INSTRUCTION POINTER - yet another pointer register, this one is cs' partner in crime, marking the next instruction to execute. Again, most assemblers won't let you alter it. | |
| ds | DATA SEGMENT - Usually used to mark the location of data for some reason or another. | ||
| es | EXTRA SEGMENT - is one of the main registers used almost exclusively as a pointer. One can usually find es being used as the base register for di. | ||
| fs | EXTRA SEGMENT - is one of the main registers used almost exclusively as a pointer. I believe it is a later addition to the chip, existing on 386+ machines only. | ||
| gs | EXTRA SEGMENT - is one of the main registers used almost exclusively as a pointer. I believe it is a later addition to the chip, existing on 386+ machines only. | ||
| edi | di | DESTINATION INDEX - yet another pointer register, di by convention tends to mave a more specific purpose. It tends to be used to mark destination locations in memory. | |
| esi | si | SOURCE INDEX - yet another pointer register, si by convention tends to mave a more specific purpose. It tends to be used to mark source locations in memory. | |
| eflags | flags | Flags - Each bit of the flags
register has an important value. Sarting from the leftmost bit : 0 - Carry Flag 2 - Parity Flag 4 - Auxillary Carry Flag 6 - Zero Flag 7 - Sign Flag 8 - Trap Flag 9 - Interupt Enable Flag 10 - Direction flag 11 - Overflow Flag 12-13 - I/O Protection Level (286+) 14 - Nested Task Flag (286+) 16 - Resume Flag (386+) 17 - Virtual 8086 mode Flag (386+) 18 - Alignment Check Flag (386+) | |

| DOS ASM | MIPS |
| mov ax, [a] | lw $8, a |
| mov bx, [b] | lw $9, b |
| add ax, ax, bx | add $8 , $8, $9 |
| mov [c], ax | sw $8, c |
With some DOS ASM compilers, including my favorite, Tubo Pascal 7.0, you can cheat around all those operations by doing the following, though I don't believe that this is supported in the basic 8086 command set :

| DOS ASM Command | Name/Explaination | MIPS Command |
| add rx, sx, tx | Add : r = s + t | add $r, $s, $t |
| and rx, sx, tx | AND : r = s AND t | and $r, $s, $t |
| call proc | CALL PROCEDURE proc | jal proc |
| dec rx | DEC : r = r - 1 | addi $r, $r, -1 |
| div rx, sx, tx | Divide : r = s / t | div $r, $s, $t |
| inc rx | INC : r = r + 1 | addi $r, $r, 1 |
| je rx, sx, proc | JUMP if r = s | beq $r, $s, proc |
| jg rx, sx, proc | JUMP if r > s | bgt $r, $s, proc |
| jl rx, sx, proc | JUMP if r < s | blt $r, $s, proc |
| jge rx, sx, proc | JUMP if r => s | bge $r, $s, proc |
| jle rx, sx, proc | JUMP if r <= s | ble $r, $s, proc |
| jne rx, sx, proc | JUMP if r <> s | bne $r, $s, proc |
| mov rx, [x] | LOAD : r = x | lw $r,x |
| mov rx, sx | MOVE : r = s | move $r, $s |
| mul rx, sx, tx | Multiply : r = s * t | mul $r,$s, $t |
| neg rx | NEG : r = -r | neg $r |
| or rx, sx, tx | OR : r = s OR t | or $r, $s, $t |
| sete rx, sx, tx | SET r=1 if s = t | seq $r, $s, $t |
| setg rx, sx, tx | SET r=1 if s > t | sgt $r, $s, $t |
| setl rx, sx, tx | SET r=1 if s < t | slt $r, $s, $t |
| setge rx, sx, tx | SET r=1 if s => t | sge $r, $s, $t |
| setle rx, sx, tx | SET r=1 if s <= t | sle $r, $s, proc |
| setne rx, sx, tx | SET r=1 if s <> t | sne $r, $s, $t |
| mov [x], rx | STORE : x = r | sw $r,x |
| sub rx, sx, tx | Subtract : r = s - t | sub $r, $s, $t |
| xor rx, sx, tx | XOR : r = s XOR t | xor $r,$s, $t |
Well, those are the most important assembly commands, and as I get more time, more and more commands will be posted. As for now, I'll leave you with two sample shells for assembly programs, one for MIPS and another for DOS ASM.
| DOS ASM | MIPS |
| .model type .data -data- .code -insert code here- |
.data -data- .text -insert code here- |
Written in HTML
Last Edited on : 3/9/04