CS 17 

MASM Code Segments

 

College Level Homework Assignments CS 15 Code  CS 17 Code CS 60 Code Discussion
Inputs
Final Schedule Email to Instructor  Student Sign-up Form

Table of Contents

1. MASM thanks to Mitchell Man Lai Sun

2. Links

3. CodeView

4. MASM613 thanks to Fern Saitowitz

5. ASCII codes  University of Indiana Knowledge Base

6. Payroll by Lazar

7. Masm, Link, Debug Script

8. 8086 PDF Instructions from John Dembinski

9.  2's Complement Arithmetic from Mitchell Man Lai Sun.

10. 16 and 32 bit and ASCII links from Neeru Raina

11. Supplemental text on MASM from Fern Saitowitz

12. Hexbar by Lazar

13. A86,  D86 Ascii links from  Noomen Bel Mechri

1. MASM

Hi professor,

I have found the MASM compiler. They are available on the Windows 98 Driver
Developer Kit. And while the whole file is 18+ Meg file, It can be
downloaded in parts. The URLs are:

    http://www.microsoft.com/ddk/download/98/BINS_DDK.EXE (2.45 MBytes)
    http://www.microsoft.com/ddk/download/98/98SETUP.EXE  (3.36 MBytes)

After downloading each file, execute them to extract the files.  Then
run the setup program.  MASM is the ml.exe file in the 98ddk/bin/win98
directory..

And this url has some info about it:

http://www.landfield.com/ftp/faqs/assembly-language/x86/microsoft

Considering that i have spent an hour looking for the tool that will benefit
the whole class, would you consider giving me a 5-point credit?

Wishing every good progress!
=)

Yours,
Mitchell Man Lai Sun
9/1/00
12:25am

Hi professor Lazar,

I have just spent another 2 hours trying to figure out how to get the
assembler from the 2 files i mentioned in my previous email and from the
internet. And at last I suceeded! To avoid my fellow classmates from wasting
their time doing the same stupid things i did, i have included the necessary
files for the compiler with this email.(NO VIRUS!!!)

The ML.exe & ML.err is the newest MASM, version 6.15. Also, I have included
the linker for the assembler, Link.exe & Mspdb50.dll. For creating 16-bit
dos files, one can use MASM v6.11d, (ML16.exe, ML16.err & Link16.exe). It
should be noted though, that after one has downloaded the zipped file, he
should save all the files with the "16" numbers in a seperate directory and
eliminate those "16"s from the file names, to avoid any possible problems.

Please refer to the following website for further reference:

http://www.davidparker.com/assembly.html
&
http://www.easystreet.com/~jkirwan/pctools.html

Another great (but illegal) way to get the rest of the help, inc, lib files
is to copy the whole directory from the SMC server, from H:\Masm611. It is
huge (>8mb), but with Winzip and disk spanning technique, one can take it
away with four 1.44 diskettes. But please be reminded that this is only a
suggested remedy and is not intended to encourage anyone to commit a crime.

Have a nice day!

Yours,
Mitchell Man Lai Sun
9/1/00, 4:15am

2. Links

Assembly Language:
http://www.cit.ac.nz/smac/asm/astart.htm

Here is also a great site for links to various Assembly language
tutorials and information.
http://www.nuvisionmiami.com/asmsources/index.html

Regards
Fern Saitowitz

From Omid Noorani:

Tutorials for beginners:
http://bobrich.lexitech.com/bg3.htm

A86/A386 assembler and D86/D386 debugger
http://eji.com/a86.zip


3. CodeView

Dear professor,

It's me again and I have found Codeview this time.

http://netcity3.web.hinet.net/UserData/masm1215/large_files/cv.zip

4. MASM613

Hi Mr Lazar,

Here is a perfectly legal site at which to download MASM 6.13.  It also
proved to be pretty easy to install.  The address is
http://www.nuvisionmiami.com/books/asm/files/downloadNewSetup.htm

Here is also a great site for links to various Assembly language
tutorials and information.
http://www.nuvisionmiami.com/asmsources/index.html

Regards
Fern Saitowitz

5. Chap1

Chap1

6. Payroll by Lazar

; PAYROLL BY CLIFF Lazar
; 9/3/00,9/4/00,9/5/00
;
DATA SEGMENT
NAMES DB 'JONES','SMITH','LAZAR','FORTH','FIFTH'
HOURS DW 10D,20D,30D,40D,50D
RATE DW 1,2,3,4,5
GROSS DW 5H DUP(?)
TAXES DW 5H DUP(?)
NET DW 5H DUP(?)
TAXRATE DB 10D
; TAXRATE IS 1/10TH
DATA ENDS
;DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
WORKING_STORAGE SEGMENT STACK ;9/5/00
DB 100H DUP(?)
WORKING_STORAGE ENDS
;WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW AX | BX | CX | DX
CODE SEGMENT
ASSUME CS:CODE,DS:DATA,SS:WORKING_STORAGE
PROGRAM_START:
MOV DS,DATA ; PUTS DATA ADDRESS IN DS

MOV CX,10D ; FROM I=5 TO 1 2 BYTES/WORD
;SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS

START: MOV BX,OFFSET HOURS
ADD BX,DATA ; DATA+OFFSET
ADD BX,CX ; OFFSET PLUS I
MOV AX,[BX] ; AX HAS HOURS(I)
MOV BX,OFFSET RATE
ADD BX,DATA ; DATA+OFFSET
ADD BX,CX
MOV DX,[BX] ;DX HAS RATE(I)
MOV BX,OFFSET GROSS
ADD BX,DATA ; DATA+OFFSET
ADD BX,CX
MUL DX ;AX gets GROSS(I)

MOV [BX],AX ;store in [BX] the Gross(i)
;COMPUTE TAXES HERE
MOV DX,AX ;KEEP GROSS(I) IN DX
MOV BX,OFFSET TAXES
ADD BX,DATA ; DATA+OFFSET 9/7/00
ADD BX,CX
DIV TAXRATE ;AX HAS TAXES(I)=GROSS(I) /TAXRATE
MOV [BX],AL ;STO TAXES(I)
MOV BX,OFFSET NET ;PTR TO NET
ADD BX,DATA ; DATA+OFFSET
ADD BX,CX
SUB DX,AX ;DX=GROSS(I)-TAXES(I)
MOV [BX],DX ;STO IN NET(I)
DEC CX ; DEC 1 BYTE 2BYTES/WORD
LOOP START ;DEC'S CX AND JNZ START
CODE ENDS
END PROGRAM_START

 

7. Masm, Link, Debug Script

c:\masm613\bin\MASM /ZI c:\masm613\code\PAYROLL,,,,
c:\masm613\binr\LINK /CO c:\masm613\code\PAYROLL,,,,
rem c:\masm613\binr\CV c:\masm613\code\PAYROLL
debug c:\masm613\code\payroll.exe
8. 8086 PDF Instructions

Here are some pdf slides on the 8086 assembly language that I discovered on
the Internet. The slides seem to be well organized and I am sure they will
prove to be a valuable asset in learning the 8086 assembly language.
http://www.scs.carleton.ca/~sivarama/asm_book_web/instructor_slides.html

Here are some more pdf slides. Out of all the topics available on this page,
I found the "pentium notes" topic to be the most useful as of right now.
http://www-dse.doc.ic.ac.uk/~nd/architecture/

The Adobe Acrobat Reader is required to view these slides. There is a free
download for this program at:
http://www.adobe.com/products/acrobat/readstep2.html

Cheers!
John Dembinski

9. 2s Complement Arithmetic

Dear professor,

Below is an explanation of why did we fail to do the #4b problem with the
two's complement method:


When dealing with binary numbers, the textbook has suggested the Two's
complement method, of which one of the two implementations is by "exchanging
the 1(s) & 0(s) and add 1 to the result of the last process", to change a
certain binary number's sign.

It won't always work, though, if the number is not denoted in the "correct"
bits representations (i.e. 8 or 16 bits etc, multiple(s) of byte). Also, it
HAS TO BE signed in order to do that trick. I'll demonstrate 'why' with
examples:

1st: For the decimal number 5, it's binary equivalent is 101B. Simply
interchanging the digits doesn't give the answer, as we shall see (010B is
2D, not -5D)

2nd: If it is denoted in 8-bits data representation, 5D would be 00000101B
if it is represented in "signed" form (The most important digit, the
leftmost one, is set to be the NEGATIVE of its original 2 to the power 8
value). Running the Two's complement trick, one will get 11111011B, which is
precisely -5 in decimal. So it works if it is in 8-bits form and when it is
signed.

3rd: Let's see what will happen if it is unsigned: 00000101B will become
11111011B (=251D) after the method, surely the trick fails this time but
why?  Looking at what we have just done more closely, we will see that we
have  increased the number, giving it all those '2 to the power 8,7,6...'
and we don't have a reason to do so! So, whether the B-number is signed or
not is another criteria to determine if we can employ the method or not.

It may seem to be very obvious now, but i don't think a lot of my classmates
did pay their attention to this b4 I point this out. The problem we
attempted to solve b4 the class break failed because of the third reason:
The numbers are indeed in 8-bits format, but they are unsigned as specified
in the question, and we blindly tried to find it's negative cousin simply by
changing all the digits plus 1, and consequently it didn't work out to be
right..

It is something not described in the textbook (even though it's example is
shown in 8-bits & signed form) so i would like you to raise my fellow
classmates' attention about this.

Wishing every good progress!

Yours truly,
Mitchell Man Lai Sun.
9/8/00, 12:15am
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.

Share information about yourself, create your own public profile at
http://profiles.msn.com.

10. 16 and 32 bit and ASCII links

Hi Professor,
This will be very informative for the  students to know/REMEMBER  about the
ASCII,16 BIT, 32 BIT,REPRESENTATION OF DATA.
http://www.danbbs.dk/~erikoest/ascii0.htm,
http://www.uni-hohenheim.de/rz/sys/basics/csc102/ch4.html#ascii
http://webster.cs.ucr.edu/Page_asm/ArtofAssembly/CH01/CH01-1.html


regards
Neeru Raina

11. Supplemental text on MASM from Fern Saitowitz

Hi Mr Lazar,

Here is a website which I have found very useful for supplementing the
notes in the book, and am sure other students will benefit from
reviewing it.
http://webster.cs.ucr.edu/Page_asm/ArtofAssembly/ArtofAsm.html

Regards
Fern Saitowitz

12. Hexbar by Lazar

;              HEXBAR  BY CLIFF Lazar
;              9/11/00
;
DATA SEGMENT
        TYPEIT    DB 0DH,0AH,'Type hex char(Esc=stop):$'
        DISPLAYIT DB 0DH,0AH,'Here it comes          :$'
        TOO_LOW   DB ' Too Low!$'
        TOO_HIGH  DB ' Too High!$'
        INPUT_CHAR DB '#'
DATA ENDS
;DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
WORKING_STORAGE SEGMENT STACK    
	DB 100H DUP(?)
WORKING_STORAGE ENDS
;WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW  AX  |  BX  | CX  | DX
CODE SEGMENT
ASSUME CS:CODE,DS:DATA,SS:WORKING_STORAGE
PROGRAM_START:
        MOV AX,DATA
        MOV DS,AX                 ; PUTS DATA ADDRESS IN DS
OUTPUT_SCR1:
        MOV AH,9                  ; SCREEN STRING$ GOING FROM DX
        MOV DX, OFFSET TYPEIT 
        INT 21H                   ;Type hex char:
        INPUT_KB:
        MOV AH,1                 ; KB CHAR COMING TO AL
        INT 21H                  ; READ A CHAR
        MOV CL,AL                ;PUT THE COUNT INTO CL
        MOV INPUT_CHAR,AL        ; SAVE THE CHAR
CHECK_ESQ:
        CMP AL,01BH              ; check for Esc
        JZ DONE                  ;QUIT IF esc
CHECK_0_9:
        CMP AL,'0'              ; CHECK IF 0
        JZ OUTPUT_SCR1
        CMP AL,'1'              ; 
        JZ NUMS
        CMP AL,'2'              ; 
        JZ NUMS
        CMP AL,'3'              ; 
        JZ NUMS
        CMP AL,'4'              ; 
        JZ NUMS
        CMP AL,'5'              ; 
        JZ NUMS
        CMP AL,'6'              ; 
        JZ NUMS
        CMP AL,'7'              ; 
        JZ NUMS
        CMP AL,'8'              ; 
        JZ NUMS
        CMP AL,'9'              ; 
        JZ NUMS
        
CHECK_A_F:
        CMP AL,'A'              ; 
        JZ ABCDEF
        CMP AL,'B'              ; 
        JZ ABCDEF
        CMP AL,'C'              ; 
        JZ ABCDEF
        CMP AL,'D'              ; 
        JZ ABCDEF
        CMP AL,'E'              ; 
        JZ ABCDEF
        CMP AL,'F'              ; 
        JZ ABCDEF
TOOHIGH:
        MOV AH,9
        MOV DX,OFFSET TOO_HIGH
        INT 21H
        JMP OUTPUT_SCR1
ABCDEF:
        SUB CL,037H                ;CONVERT ASCII A-F TO NUMBER
        JMP OUTPUT_KB
NUMS:
        SUB CL,030H                ;CONVERT ASCII 0-9 TO NUMBER
OUTPUT_KB:
        MOV AH,9
        MOV DX, OFFSET DISPLAYIT  ;HERE COMES TO SCREEN
        INT 21H
        MOV AH,2                  ;DL CHAR GOING TO SCREEN...
LOAD_CHAR:
        MOV DL,INPUT_CHAR                ;PUT CHAR IN DL
START_OUTPUT:
        INT 21H
        LOOP START_OUTPUT         ;DEC'S CX AND JNZ START
RESTART: JMP OUTPUT_SCR1
DONE:
       MOV AX,4C00H
       INT 21H
CODE ENDS
END PROGRAM_START