Download the lab programs (Part A) zip file - apasm.zip (6 KB)
MASM
Download MASM (masm.zip)(175 KB)
This is a barebones version of MASM. It contains Microsoft Macro Assembler
Version 5.10 and Microsoft Segmented Executable Linker Version 5.31.009.
Download CodeView (cv.zip)(520KB)
This is the zip file containing all the files required to run codeview. I filtered
files in the masm611\bin directory till i got all the files that were only required
for the running of cv.exe. There are 10 dll's apart from the main exe which
are required.
ee*.dll are expression evaluators, em*.dll is the execution model, sh*.dll is
the symbol handler and tl*.dll is the transport layer.
Please let me know if you got an error while using cv.exe due to a missing file.
Download Debug (debug.zip)(14KB)
If you are using Windows 98/Me, debug.exe is builtin and is available in the
directory \windows\command. If you are using WinNT based OS'es you can download
this file, but i am not sure whether this will work on WinNT based systems.
Source Code :
1) Procedure to show the BCD (nibble-wise) Hexadecimal Representation of a
value on the console. Believe me, its not the easiest thing to do in ASM but
is really really handy.
show.asm
2) A procedure to convert a double word value into a decimal printable format
along with a program to show its use.
dwtodec.asm
dwuse.asm
3) Selection Sort selnsort.asm
4) Bubble Sort bubsort.asm
5) Insertion Sort inssort.asm
6) Linear Search lsearch.asm
Some of the above programs use the showb or showw routines in show.asm. So you need that file to run most of the other programs.
EMU8086 (22nd June 2004)
This is an integrated IDE/assembler/linker/debugger. Its really good to work with it since using debuggers like "debug" are time consuming and have a steep learning curve.
EMU8086 version 2.58 is the latest version as of now and its shareware version
can be downloaded from emu8086.com. This shows nag screens too many times and
you will get frustrated if you try to run a longish program or a program with
loops on it.
So you could download EMU8086 version 2.57 and then crack it. Download this
version from tucows.com by running a search there or by clicking here.
Then download the crack by clicking here. Click
here to get a key generator. Install the software
and then patch/crack it. Cracks for version 2.58 are not available on the internet
as of today. If you find a crack, please let me know.
For your information :
Version 2.58 Setup is 2,504,136 bytes (2.38 MB or 2445.4 KB) available as Emu8086Setup.exe
or SetupEmu8086.exe from emu8086.com.
Version 2.57 Setup is (3.09 MB or 3162.6 KB) available as SetupEmu8086-TUCOWS.exe
from TuCows.
My (somewhat detailed) explanation of the use of 8086 instruction AAA (ASCII
Adjust after Addition):
Before reading this, i suggest you read a text on how AAA works. This would
tell you why and how you might want to use AAA.
The AAA instruction is only useful when it follows an ADD instruction that
adds two unpacked ASCII BCD values for decimal digits '0' to '9' (whose hex
equivalents are between 30h and 39h both inclusive) and stores a byte result
in the AL register. An unpacked ASCII BCD value is a byte whose first 4 bits
are always 0011 (decimal digit 3) and the last 4 bits would be the binary conversion
of the decimal (base 10) digit.
A plain unpack BCD number is one that occupies 8 bits and whose 1st 4 bits are
0000, and the last 4 bits signify digits 0 to 9.
The AAA instruction adjusts the contents of the AL register to contain the correct 1-digit or 2-digit unpacked BCD result. Suppose you clear AH before running AAA, you will surely get the correct 2-digit unpacked BCD (not BCD ASCII) result in AX.
Suppose you take in two digits from the keyboard using a DOS interrupt. Say
you enter the digits '7' and '2' at the keyboard. Now you want to show the result
'9' on the keyboard which is the sum of the digits 7 and 2. So you say :
;assume AH is 00h
add AL,BL ;assuming that the 2 digits entered are in AL and BL
AAA
Before AAA, the digit '7' which is 37h is added to '2' which is 32h. So the result got is 69h. But you want the result to be just the value 9. So use AAA which would make AL 09h. Now the digit is used as a normal decimal digit for calculations. To print the digit, add 30h to the value of AL and then use the DOS interrupt.
You might say what is the use of that long drawn procedure. Why not just clear the higher nibble of AL and get done with it. So, consider this situation :
Suppose you want to add the two digits '7' and '5'. The result is obviously 12. You want this result in AX digitwise, that is 1 in AH and 2 in AL so that you can perform further decimal calculations easier. So you use AAA.
Here, before AAA, the result in AL is 37h + 35h which is 6Ch. So, since Ch > 9h, so AL is incremented by 6. So we have AL = 72h and AH is made 01h. Now the higher nibble of AL is cleared and AL becomes 02h.
So now AH has the value 1 and AL has the value 2 which signifies on the whole the number 12 digitwise. To print, as usual for every digit (byte) add 30h and call the DOS interrupt.
In case you are totally lost by now, just mug up this algorithm and use it in the final exam to calculate if asked.
Algorithm for AAA (which wouldn't use the term nibble anywhere) :
IF ((AL AND 0FH) > 9) OR (AF = 1) THEN AL = (AL + 6) AND 0FH; AH = AH + 1; AF = 1; CF = 1; ELSE CF = 0; AF = 0; FI;
Errors in Textbook
There were some errors in Advanced Microprocessors and Peripherals (Architecture, Programming and Interfacing) by A K Ray and K M Burchandi which is our prescribed textbook for MicroProcessors (4th Sem CSE, BE, VTU).
Here is a correct table for Jump Instructions:
Mnemonic | Meaning | Jump Condition |
---|---|---|
JA | Jump if Above | CF=0 and ZF=0 |
JAE | Jump if Above or Equal | CF=0 |
JB | Jump if Below | CF=1 |
JBE | Jump if Below or Equal | CF=1 or ZF=1 |
JC | Jump if Carry | CF=1 |
JCXZ | Jump if CX Zero | CX=0 |
JE | Jump if Equal | ZF=1 |
JG | Jump if Greater (signed) | ZF=0 and SF=OF |
JGE | Jump if Greater or Equal (signed) | SF=OF |
JL | Jump if Less (signed) | SF != OF |
JLE | Jump if Less or Equal (signed) | ZF=1 or SF != OF |
JMP | Unconditional Jump | unconditional |
JNA | Jump if Not Above | CF=1 or ZF=1 |
JNAE | Jump if Not Above or Equal | CF=1 |
JNB | Jump if Not Below | CF=0 |
JNBE | Jump if Not Below or Equal | CF=0 and ZF=0 |
JNC | Jump if Not Carry | CF=0 |
JNE | Jump if Not Equal | ZF=0 |
JNG | Jump if Not Greater (signed) | ZF=1 or SF != OF |
JNGE | Jump if Not Greater or Equal (signed) | SF != OF |
JNL | Jump if Not Less (signed) | SF=OF |
JNLE | Jump if Not Less or Equal (signed) | ZF=0 and SF=OF |
JNO | Jump if Not Overflow (signed) | OF=0 |
JNP | Jump if No Parity | PF=0 |
JNS | Jump if Not Signed (signed) | SF=0 |
JNZ | Jump if Not Zero | ZF=0 |
JO | Jump if Overflow (signed) | OF=1 |
JP | Jump if Parity | PF=1 |
JPE | Jump if Parity Even | PF=1 |
JPO | Jump if Parity Odd | PF=0 |
JS | Jump if Signed (signed) | SF=1 |
JZ | Jump if Zero | ZF=1 |
The below diagram of the pin configuration is there in the text. Its here because it looks cool.
----------------------------------------------------------------- | | | | | Intel | | | | 88888 000 88888 666 | | 8 8 0 0 8 8 6 | | 8 8 0 0 0 8 8 6 | | 88888 0 0 0 88888 666666 | | 8 8 0 0 0 8 8 6 6 | | 8 8 0 0 8 8 6 6 | | 88888 000 88888 66666 | | | | | | | | | | | | | | | | _________ _________ | | _| \__/ |_ | | GND |_|1 40|_| Vcc | | _| |_ | | <--> AD14 |_|2 39|_| AD15 <--> | | _| |_ | | <--> AD13 |_|3 38|_| A16/S3 --> | | _| |_ | | <--> AD12 |_|4 37|_| A17/S4 --> | | _| |_ | | <--> AD11 |_|5 36|_| A18/S5 --> | | _| |_ | | <--> AD10 |_|6 35|_| A19/S6 --> | | _| |_ ___ | | <--> AD9 |_|7 34|_| BHE/S7 --> | | _| |_ __ | | <--> AD8 |_|8 33|_| MN/MX <-- | | _| |_ | | <--> AD7 |_|9 32|_| RD --> | | _| |_ __ ___ | | <--> AD6 |_|10 8086 31|_| RQ/GT0,HOLD <-->| | _| |_ __ ___ | | <--> AD5 |_|11 30|_| RQ/GT1,HOLD <-->| | _| |_ ____ __ | | <--> AD4 |_|12 29|_| LOCK,WR --> | | _| |_ __ __ | | <--> AD3 |_|13 28|_| S2,M/IO --> | | _| |_ __ _ | | <--> AD2 |_|14 27|_| S1,DT/R --> | | _| |_ __ ___ | | <--> AD1 |_|15 26|_| S0,DEN --> | | _| |_ | | <--> AD0 |_|16 25|_| QS0,ALE --> | | _| |_ ____ | | --> NMI |_|17 24|_| QS1,INTA --> | | _| |_ ____ | | --> INTR |_|18 23|_| TEST <-- | | _| |_ | | --> CLK |_|19 22|_| READY <-- | | _| |_ | | GND |_|20 21|_| RESET <-- | | |______________________| | | | | | | | -----------------------------------------------------------------
Sources :
http://www.manualy.sk/
http://www.mikesarcade.com/
http://www.online.ee/
http://www.emu8086.com/
Various Oher Websites
Advanced Microprocessors and Peripherals (Architecture, Programming and Interfacing)
by A K Ray and K M Burchandi
( Ninth Reprint 2004)