;;keyin.asm title keyin comment ~ this line is ignored Name: SSN: Section: Date: Assignment: ~ this remainder of this line is also ignored .nolist ;do not list the following in the output file include bios.inc ;include bios functions and macros include dos.inc ;include dos functions and macros .list ;list the remaining of the contents in the output file .model small ;declare executable size .586 ;486 instruction set .stack 100h ;declare the stack segment to be 256 characters long .data ;begin the data segment CR equ 0Ah LF equ 0Dh mess db CR,LF,"What day is it? " ;declare a character array messlen equ lengthof mess ;get the length of the character array mess mess2 db CR,LF,"I'm glad its " ;declare a character array mess2len equ lengthof mess2 ;get the length of the character array mess2 keybuff db 20,0,20 dup('*') ;declare a character array of length of twenty ;and initialize every entry to ' ' ;************************************************** ;Lab Assignment 2: part one! Yeah! ;************************************************** keylen db 1 ;create a variable 1 byte long, named keylen, to store the number of letters typed mess3 db CR,LF,"Number typed in: " ;declare a character array, named mess3, to hold a new message "Number typed in: " mess3len equ lengthof mess3 ;get the length of the character array mess3 .code ;begin the code segment main proc ;being procedure main .startup ;begin process execution @Cls ;clear the screen @Setcsrpos 0,0 ;set cursor to column 0, row 0 mov ah, 040h ;move value 040h into the high part of register AX mov bx, 1 ;move value 1 into register BX for the stdout device mov cx, messlen ;move the length of the variable mess into register CX lea dx, mess ;load effective address of variable mess into register DX int 21h ;interrupt OS and request attention to write a message out to a device call keyread ;call procedure keyread mov ah, 040h ;move value 040h into the high part of register AX mov bx, 1 ;move value 1 into register BX for the stdout device mov cx, mess2len ;move the length of the variable mess into register CX lea dx, mess2 ;load effective address of variable mess into register DX int 21h ;interrupt OS and request attention to write a message out to a device mov ah, 040h ;move value 040h into the high part of register AX mov bx, 1 ;move value 1 into register BX for the stdout device lea dx, keybuff+2 ;load effective address of variable keybuff into register DX mov cl, [keybuff+1] ;load the value stored at memory address [keybuff+1] into register Cl int 21h ;interrupt OS and request attention to write a message out to a device ;************************************************** ;Lab Assignment 2: part two! Yeah! ;************************************************** add cl, 030h ;convert the number of letters typed into ASCII code mov keylen, cl ;save the number of letters to variable keylen mov ah, 040h ;initialize the AX register for writing to device mov bx, 1 ;initialize the BX register for writing to stdout mov cx, mess3len ;initialize the CX register to the number of characters to print to screen of mess3 lea dx, mess3 ;initialize the DX register to hold the memory address of the string to print int 21h ;interrupt OS and request attention to write a message out to a device mov ah, 040h ;initialize the AX register for writing to device mov bx, 1 ;initialize the BX register for writing to stdout mov cx, 1 ;initialize the CX register to the number of characters to print to screen lea dx, keylen ;initialize the DX register to hold the memory address of the string to print int 21h ;interrupt OS and request attention to write a message out to a device .exit ;end process execution main endp ;end procedure main keyread proc ;begin procedure keyread lea dx, keybuff ;load effective address of keybuff into the DX register mov ah, 0ah ;mov 0ah into the high 8 bigs of register AX int 21h ;interrupt os and request attention to request input from stdin ret ;return the calling procedure keyread endp ;end procedure keyread end