;Kira Swab ;Assembly Language Programming ;February 2001 .model small .stack 100h .data linone db "This course will introduce you to the Intel architecture and to the assembly language used on the PC's.", 0ah, 0dh db "Emphasis will be placed on how the machine accomplishes its actions at the register level and the implications", 0ah, 0dh db "that these methods have on programming the machine. Additional discussions will involve the relationship of", 0ah, 0dh db "assembly language to higher-level language, the use of system services provided by the BIOS and DOS, the use", 0ah, 0dh db "of macro libraries, and the process of linking. We will also look at interrupt handling by DOS. This", 0dh, 0ah db "assembly language program counts the approxiamate number of words and lines in a portion of text", 0dh, 0ah db "Counting in the manner suggested above does not necessarily produce an accurate count for words or lines - ", 0dh, 0ah lintwo db "there are only 17 words above. Dont let this bother you, just count the words and lines as indicated.", 0dh, 0ah lines dw ? words dw ? .code main proc begin: mov ax, @data mov ds, ax ;set up DS (data segment) mov lines, 0 ;initialize line count mov words, 0 ;initialize word count mov ax, offset lintwo ;get offset of beginning of lintwo text mov bx, offset linone ;get offset of beginning of linone text sub ax, bx ;subtract to find value (bytes) of text mov si, offset linone ;uses si to point to first value of linone mov cx, ax ;set counter = # of values(bytes) top: mov dl, [si] ;uses address to put value into register cmp dl, 20h ;compares value to a space je wcount ;if equal, jumps to add to word cmp dl, 0ah ;compares value to a linefeed je wcount ;if equal, jumps to add to word cmp dl, 0dh ;compares value to a carriage return je lcount ;if equal, jumps to add to line spot: inc si loop top jmp done wcount: inc words ;increases word count jmp spot lcount: inc lines ;increases line count jmp spot done: inc lines inc words mov ax, 4c00h int 21h ;exit to DOS command main endp end main