Question

In: Computer Science

ACTIVITY #1: Defining Strings √ Write an assembly program that display your name, your id, and...

ACTIVITY #1: Defining Strings
√ Write an assembly program that display your name, your id, and your college name on the screen.
√ Remember: the format of the assembly program should be like this.
TITLE your title (FileName.asm)
.MODEL FLAT
.386
.STACK 64
.DATA
str1 DB "My name: Essam Alnatsheh",13,10,'$'
.CODE
main PROC
mov ax,@data
mov ds,ax

mov ah,09h
mov dx, offset str1
int 21h

​mov ah,4Ch​​ ; terminate process
​mov al,0​​ ; return code
​int 21h
main ENDP
END main

Question 1: What is the purpose of:
mov ax,@data
mov ds,ax
Answer:



√ Ask the instructor to evaluate your code.
√ Enter, assemble, link, and run your program to be sure it’s correct.
√ Write your code in this space.

ACTIVITY #2: Using the DUP Operator
Question 3: Write an Assembly program that display your name and your nationality as two lines on the screen. Using the DUP operator, display a line of '**- - - - -**- - - - -' before and after the previous text. Use interrupts (21h) to display the string values and use it to terminate the program.
Ask the instructor to evaluate your code and write your code in this space.

ACTIVITY #3: Using x86 Registers
Question 4: Write an Assembly program that subtracts three integers (defined as byte variables and with values 9, 5, and 3) using only 8-bit registers. Insert int 21h statements to display the result’s value using ASCII code and use it to terminate the program.

Solutions

Expert Solution

Question 1

student.asm

.MODEL FLAT

.STACK 64
.DATA
   str1 DB "My Name : Essam Alnatsheh",13,10,'$'
   str2 DB "My id : CSE123",13,10,'$'
   str3 DB "My College Name: IIT Chennai,India",13,10,'$'
.CODE
   main PROC
   mov ax,@data
   mov ds,ax

   mov ah,09h
   mov dx, offset str1
   int 21h
  
   mov ah,09h
   mov dx, offset str2
   int 21h
  
   mov ah,09h
   mov dx, offset str3
   int 21h

mov ah,4Ch ; terminate process
   mov al,0 ; return code
   int 21h
   main ENDP
END main

Reason for instructions

mov ax,@data
mov ds,ax

8086 programs are stored in different segments in memory.The different segments are DATA SEGMENT, CODE SEGMENT, STACK SEGMENT and EXTRA SEGMENT.Purpose of each segments are
DATA SEGMENT: where variables,arrays and constants are stored[data for the program is stored]
CODE SEGMENT : where binary code of executable instructions are stored
STACK SEGMENT: where content of stack are stored
EXTRA SEGMENT.:It is also used for storing data

There are four segment registers CS,DS,SS and ES are used for handling these segments. Each of these registers are initialized with base address of corresponding segment.
CS segment register: for handling CODE SEGMENT
DS segment register: for handling DATA SEGMENT
SS segment register: for handling STACK SEGMENT
ES segment register: for handling EXTRA SEGMENT

In our program instructions
mov ax,@data
mov ds,ax

loads base address of DATA SEGMENT to ax register and then DS register stored with the value of ax(base address of DATA SEGMENT). A segment register cannot be loaded an address directly. so we use these two instruction.

Output 1

Question 3

student1.asm

.MODEL FLAT

.STACK 64
.DATA
   str1 DB "My Name : Essam Alnatsheh",13,10,'$'
   str2 DB "My Nationalit : United State of America",13,10,'$'
   msg1 DB 2 dup('*'),'$'   
   msg2 DB 5 dup('- '),'$'
   msg3 DB 13,10,'$'
.CODE
   main PROC
   mov ax,@data
   mov ds,ax

   mov ah,09h
   mov dx, offset msg1
   int 21h
  
   mov ah,09h
   mov dx, offset msg2
   int 21h
  
   mov ah,09h
   mov dx, offset msg1
   int 21h
  
   mov ah,09h
   mov dx, offset msg2
   int 21h   
  
   mov ah,09h
   mov dx, offset msg3
   int 21h
  
   mov ah,09h
   mov dx, offset str1
   int 21h
  
  
   mov ah,09h
   mov dx, offset str2
   int 21h
  
   mov ah,09h
   mov dx, offset msg1
   int 21h
     
   mov ah,09h
   mov dx, offset msg2
   int 21h
  
   mov ah,09h
   mov dx, offset msg1
   int 21h
  
   mov ah,09h
   mov dx, offset msg2
   int 21h
  
   mov ah,09h
   mov dx, offset msg3
   int 21h   
  

mov ah,4Ch ; terminate process
   mov al,0 ; return code
   int 21h
   main ENDP
END main

Output 2

Question 4

student3.asm

.MODEL FLAT

.STACK 64
.DATA
   num DB 9,5,3
   msg DB "Result=",'$'
  
.CODE
   main PROC
   mov ax,@data
   mov ds,ax

  
   mov si, offset num
   mov dl,[si]   
   inc si
   sub dl,[si]
   inc si
   sub dl,[si]
   push dx
     
   mov ah,09h
   mov dx, offset msg
   int 21h
  
   pop dx
   add dl,30h
   mov ah,02h
   int 21h   

mov ah,4Ch ; terminate process
   mov al,0 ; return code
   int 21h
   main ENDP
END main

Output 4


Related Solutions

Using c++, write a program that will display your name as a void function then will...
Using c++, write a program that will display your name as a void function then will perform the following by user-defined functions: a. to compute for the sum of two numbers (n1, n2) using function.
Write a C++ program to display toy name
Write a C++ program to display toy name
Description: Write and test a MASM program to perform the following tasks: 1. Display your name...
Description: Write and test a MASM program to perform the following tasks: 1. Display your name and program title on the output screen. 2. Display instructions for the user. 3. Prompt the user to enter two numbers. 4. Calculate the sum, difference, product, (integer) quotient and remainder of the numbers. 5. Display a terminating message. Requirements: 1. The main procedure must be divided into sections:  introduction  get the data  calculate the required values  display the results...
Part 1 Write a program that displays a frame containing two labels that display your name,...
Part 1 Write a program that displays a frame containing two labels that display your name, one for your first name and one for your last. Experiment with the size of the window to see the labels change their orientation to each other. USE FIRST NAME: Aya LAST NAME: KAYED. SEND THE CODE IN THE EXACT FORMAT FOR JAVA ECLIPSE. I WILL COPY AND PASTE THE CODE SO I CAN RUN IT. Part 2 Propose and solve your own digital...
Program Description Write and test a MASM program to perform the following tasks: Display your name...
Program Description Write and test a MASM program to perform the following tasks: Display your name and program title on the output screen. Display instructions for the user. Prompt the user to enter three numbers (A, B, C) in descending order. Calculate and display the sum and differences: (A+B, A-B, A+C, A-C, B+C, B-C, A+B+C). Display a closing message. Program Requirements The program must be fully documented and laid out according to the CS271 Style Guide. This includes a complete...
Assembly Language Coding Using MARS (MIPS) 1)Write a program that prints your name in a Triangle....
Assembly Language Coding Using MARS (MIPS) 1)Write a program that prints your name in a Triangle. (NAME = John Doe) 2)Write a Program that intializes X to 10, Y to 20 and Z to -50, adds X and Y and Z and prints the following the value of each variable, for example value of x is 10 as well as the result of the addition.
Write an assembly program that displays the following two options: 1. Display the current date. 2....
Write an assembly program that displays the following two options: 1. Display the current date. 2. Enter a date for a meeting and display remaining days. If the user selects the first option, the program should display the current date in dd/mm/yyyy format. If the user selects the second option, the program asks the user to enter a date for a meeting within year 2020 (in decimal) in dd/mm format. The program then calculates and displays the number of days...
Please write in x86 Assembly language on Visual Studio Write a program to compare two strings...
Please write in x86 Assembly language on Visual Studio Write a program to compare two strings in locations str1 and str2. Initialize str1 to Computer and initialize str2 to Compater. Assume Str1 holds the correct spelling and str2 may have an incorrect spelling. Use string instructions to check if str2 is correct and if not correct the mistake in str2.
Write an 8051-assembly language program for the interfacing of ADC0804 and LM35 to display the room...
Write an 8051-assembly language program for the interfacing of ADC0804 and LM35 to display the room temperature on 16x2 LCD (10marks) please note that the program should be interfacing with ADC0804.
Write an assembly language program that prints your first name in the output. Use immediate addressing...
Write an assembly language program that prints your first name in the output. Use immediate addressing with a hexadecimal constant to designate the operand of CHARO for each letter of your name. Comment each line except STOP and END. Cut and paste the Assembler Listing into your document and paste a screen shot of the Output area of the Pep8. Use the name "Kevin" as example Assembler Listing Screen Shot of Output area of the Pep8 program
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT