Computer organization and assembly language
Please help me with this.
I have to write line by line what each line of codes does.
CODE IS BELOW:
.model small
.386
.stack 100h
.data
msg1 db 13, 10, "Enter any number --> ", "$"
msg2 db "Enter an operation +,- * or / --> ",13, 10, "$"
msg3 db "The Operation is --> ", "$"
msg4 db "The result is --> ", "$"
By_base dd 21
by_10 dd 10 ; 32 bits variable with initial value = 10
sp_counter db 0 ; 8 bits variable with initial value of zero
disp_number dd 0 ; 32 bits variable with initial value = 0
disp_number2 dd 0
disp_number3 dd 0
op_type db 0
last_key dd 0 ; 32 bits variable with initial value of zero
remainder db 0
.code
main proc
mov ax,@data;set up datasegment
movds,ax
mov dx,offset msg1
call display_message
callm_keyin
calloperation
mov dx,offset msg1
calldisplay_message
callm_keyin
cmpop_type, "+"
jnz short skip_plus
callop_plus
skiP_plus:
cmp op_type, "-"
jnz short skip_minus
callop_minus
skip_minus:
cmp op_type, "*"
jnz short skip_mul
callop_mult
skip_mul:
cmp op_type, "/"
jnz short skip_div
call op_div
skip_div:
call m_display
mov ax, 4c00h
int 21h
operation proc
mov dx,offset msg2
rpt4:
call display_message
mov dx,offset msg3
call display_message
mov ah, 1
int 21h
cmp al, 30h
jns rpt4
mov op_type, al
ret
operation endp
m_display proc
mov dx,offset msg4
call display_message
mov eax, disp_number
mov sp_counter, 0
Base_lp:
LP1:
mov edx, 0
div By_Base
push dx
inc sp_counter
cmp eax, 0
jnz lp1
LP2:
pop dx
call display
dec sp_counter
jnz lp2
mov edx, -8
call display
mov edx, by_base
call display
mov edx, -7
call display
dec By_base
mov eax, disp_number
cmp By_base, 1
jnz Base_lp
ret
m_display endp
op_minus proc
mov eax, disp_number2
sub eax, disp_number3
mov disp_number, eax
ret
op_minus endp
op_div proc
mov eax, disp_number2
div disp_number3
mov disp_number, eax
mov remainder, dl
call display
call m_display
mov dl, -16
call display
mov dl, remainder
call display
mov dl, -1
call display
mov edx, disp_number3
call display
mov ax, 4c00h
int 21h
op_div endp
op_mult proc
mov eax, disp_number2
mul disp_number3
mov disp_number, eax
ret
op_mult endp
op_plus proc
mov eax, disp_number2
add eax, disp_number3
mov disp_number, eax
ret
op_plus endp
display proc
add dl, 30h
cmp dl, 3ah
jsshort skip_hex
add dl, 7
Skip_hex:
mov ah, 6
int 21h
ret
display endp
display_message proc
mov ah, 9 ; to display to screen the string pointed by the DX register.
int 21h
mov edx, 0
ret
display_message endp
m_keyin proc
MOV disp_number, 0
mov last_key, 0
LP_key:; location in the program label
mov eax, disp_number
mul by_10 ; eax = (eax) * 10
add eax, last_key
mov DISP_NUMBER, eax ; save it to the number to display
mov ah, 1 ; enables a single key entry
int 21h
AND eax, 000000ffh
cmp al, 13 ; compare the key entered to 13 i.e. ascii of CR
jzshort finkey ; if CR was pressed then exit the enter key routine
sub al, 30h ; remove the ascii from the number entered to get a pure number.
MOV LAST_KEY, EAX ; save the last digit entered
jmp lp_key ; unconditional jump to the enter key routine in a loop
finkey:
MOV eax, DISP_NUMBER
cmp DISP_NUMBER2,0
jnz short skip
MOV DISP_NUMBER2, EAX
skip:
MOV DISP_NUMBER3, EAX
ret
m_keyin endp
main endp
end main
Step by stepSolved in 2 steps with 1 images
- Using C++ Program: A palindrome is a word that is spelled the same way both forwards and backwards. For example, the word, 'racecar' is a palindrome. Using character arrays, write a program that prompts the user to enter a word from the keyboard and informs the user whether the word is a palindrome or not.arrow_forwardPython 3 NO IMPORT PICKLE Please check the picture and add one more function(def) and fix the error in the code. Write a program that keeps names and email addresses in a dictionary as key-value pairs. You Must create and use at least 5 meaningful functions. A function to display a menu A function to look up a person’s email address A function to add a new name and email address A function to change an email address A function to delete a name and email address. This is the Required Output example: Menu ---------------------------------------- 1. Look up an email address 2. Add a new name and email address 3. Change an existing email address 4. Delete a name and email address 5. Quit the program Enter your choice: 2 Enter name: John Enter email address: John@yahoo.com That name already exists Menu ---------------------------------------- 1. Look up an email address 2. Add a new name and email address 3. Change an existing email address 4. Delete a name and email address…arrow_forwardInstructions: You are strictly not allowed to use anything other than pointers and dynamic memory. One function should perform one functionality only. Task 1 Write a program in C++ that reads data from a file. Create dynamic memory according to the data. Now your task is to perform the following task. Row wise Sum Column wise Sum Diagonal wise Sum Example data.txt 4 5 1.6 10.2 33.7 99 20.5 3 44 50 96.1 2 8 9 4 74 50 99 19.1 Output: Sum row wise: 165, 191, 17, 242.1 Sum col wise: 127.6, 120.1, 228.8, 118.1, 20.5 Sum diagonal wise: Not Possible Note: You are restricted to use pointers and your function should be generic. Avoid memory wastage, memory leakage, dangling pointer. Use regrow or shrink concepts if required.arrow_forward
- Complete the missing code then compile, debug and test your program using the command lines below: c++ -o project1 project1.cpp <enter> ./project1 n m k <enter> Where n is the size of the stack, m is the modular of the real part and imagination part of a random complex number, and k is the number of elements displayed per line. In the main function, you need to Get the values n, m, and k from the command line. Declare a complex number stack of size n, generate n random complex numbers and push them into the stack. Meantime display all these numbers, k numbers per line. Display all elements of the stack, k elements per line. Create two random complex numbers c1 and c2, display c1, c2 and the results of the addition c1+c2, the subtraction c1-c2, the multiplication c1*c2, and the division c1/c2. #include <iostream> #include <cstdlib> #include <ctime> using namespace std; class Complex {…arrow_forwardCreate a c ++ program keeping in mind the concepts about Pointers (Pointers). Instructions: Write a program to find the maximum of a set of integers within an array. The program should ask the user to enter each of the values. At the end the program prints a pointer to point to the maximum value. The example is shown in the image Note create the program in c ++arrow_forwardc++languagearrow_forward
- 1. Write a C++ program that accepts an array of numbers and determines and displays the largest number. See sample output below. Use dynamic memory allocation. Enter array size: 5 Enter 5 numbers: 5.92 1.92 3.96 9.8 6.4 The largest number is 9.8arrow_forwardHow do you build a C++ program that asks the user to enter three integer values as input and stores the values into three different variables? Additionally, for each variable, create an integer pointer to dynamic memory and display the contents of the variables and pointers. Furthermore, be sure to use the new operator and delete operators to manage memory. Please and thank youarrow_forwardP1: this is data structure of algorithms subject and topic is all about Stack Applicationsarrow_forward
- Segmentation: Select all of the following statements that are true. In segmentation, a logical address always has a length of 32 bit. In order to translate logical into physical addresses, the memory management unit uses the segment part of the logical address to determine the start address in the segment table and adds the offset to this to get the physical address. In segmentation, the logical address consists of a segment part and an offset. The segment length is limited by the maximum possible segment number. When applying segmentation, processes are only allowed to access the memory within their segments. Segments can be assigned access rights and privilege levels.arrow_forward2 DO NOT COPY FROM OTHER WEBSITES Upvote guarenteed for a correct and detailed answer. Thank you!!!arrow_forward
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY