# Assembly language 64 bit please ! An example file for set up ==========+ ;| Data Segment...

###### Question:

Assembly language 64 bit please !
An example file for set up
==========+
;| Data Segment BEGINS Here |
;+======================================================================+
segment .data
;Code this expression: sum = num1+num2
num1 dq 0 ;left operand of the addition operation
num2 dq 0 ;right operand of the addition operation
sum dq 0 ;will hold the computed Sum value
RetVal dq 0 ;Integer value RETURNED by function calls
;can be ignored or used as determined by the programmer
;Message string prompting for the keyboard input
;Terminal ,0 makes them string values
;Format string for printf() function call
Prompt4Input_fmt db 0x0a,0x0a, "%Enter the %number: ",0
First_str db "FIRST",0
Second_str db "SECOND",0
Indent15_str db " ",0
Results_fmt db 0x0a,0x0a,\
" Sum of %i + %i = %0i",0x0a,0x0a,0k
;Format string for scanf() function call
GetInteger_fmt db "%i",0
;+======================================================================+
;| Data Segment ENDS Here |
;+======================================================================+
;+======================================================================+
;| Code Segment BEGINS Here |
;+======================================================================+
segment .text
extern printf ;Reference "C" printf() function
extern scanf ;Reference "C" scanf() function
extern exit ;Reference "C" exit() function
main:
push rbp ;Save CURRENT RBP on the STACK
mov rbp, rsp ;Store the current RSP (stack pointer) register
;value in the RBP register
sub rsp, 40 ;MUST create room for at least the 4 possible
;parameters in a function call that are stored
;in dedicated registers (rcx,rdx,r8,r9).
;These stack locations are referred to as the
;'shadow stack space' occupying (32 bytes MINIMUM)
;on the program's stack at runtime.
; Save incoming registers on the stack
pushregs rbx,rsi,rdi,r10,r11,r12,r13,r14,r15

xor rax,rax ;Clear the RAX register to 0 before beginning
;Windows printf() register uses conventions...
;printf() akways has AT LEAST 1 PARAMATER....
; 'C' Parameter number: 1 2 3 4
; In 'C' syntax: printf("fmt string", val1,val2,val3);
;Up to 4 register parameters can be entered into registers
;using these SPECIFIC registers...
;Parm 1 2 3 4 processed from left to right
;in RCX, RDX, R8, R9 REGISTER ORDER
;Prompt for the first integer
lea rcx,[Prompt4Input_fmt] ;parameter 1 uses RCX
lea rdx,[Indent15_str] ;parameter 2 uses rdx
lea r8,[First_str] ;parameter 3 uses r8 (if needed)
call printf
;Get the FIRST number from the keyboard...
lea rcx,[GetInteger_fmt]
lea rdx,[num1] ;Label in DATA SEGMENT to receive the input
call scanf ;call the function, return value in RAX
mov qword [RetVal],rax ;save the return value
;Prompt for the second integer
lea rcx,[Prompt4Input_fmt] ;parameter 1 uses RCX
lea rdx,[Indent15_str] ;parameter 2 uses rdx
lea r8,[Second_str] ;parameter 3 uses r8 (if needed)
call printf
;Get the SECOND number from the keyboard...
lea rcx,[GetInteger_fmt]
lea rdx,[num2] ;Label in DATA SEGMENT to receive the input
call scanf ;call the function, return value in RAX
mov qword [RetVal],rax ;save the return value
;Compute the SUM of the two input values
xor rax,rax ;clear the Rax register to 0
mov rax,qword [num1] ;Load RAX with the first number
mov rax,qword [num2] ;Add the two values leaving the sum
;in RAX after the addition is completed
mov [sum],rax ;save the sum value in DATA SEGMENT memory
;Display the final results using printf()....
lea rcx,[Results_fmt] ;printf() format string Parameter 1
mov rdx,[num1] ;parameter 2 uses RDX
mov r8, [num2] ;parameter 3 uses r8
mov r9, [sum] ;parameter 4 uses r9
call printf
;Restores values of incoming registers that were saved on the stack by the pushregs macro
popregs rbx,rsi,rdi,r10,r11,r12,r13,r14,r15
add rsp,40 ;Revise stack to undo line 39
xor rcx,rcx ;0 return = success
call exit ;return control to the operating system

;+======================================================================+
;| Code Segment ENDS Here |
;+======================================================================+
1. Declare a quad-word (64 bits) variable (i.e. Label) in the DATA segment of the source code. This Labes will store an INTEGER NUMBER value entered by the user at runtime using the "C scan function 2. Declare a FORMAT string for use with the "C" scanf0 function that will accept exactly ONE INTEGER value using the %i FORMAT SPECIFIER. 3. Declare a FORMAT string for use by the "C" printf) function that PROMPTS the user to enter the INTEGER value. Choose YOUR OWN prompt message text for this step. 4. Declare a FORMAT string for use with the "C" printfO function to display the folowing string "The ORGINAL INTEGER [ %ì ] represented in HEADECİMAL notation is [ or The two format specifier "placeholders" will each be replaced by the INTEGER value entered by the user at runtime into the Label declared in Step 1 5. Use the PROMPT string from Step 3 with printf) to instruct the user to enter a single INTEGER value using the keyboard. After the prompt message is displayed in Step 5, "call" the scanf) using the FORMAT string created in Step 2. Store the input value into the Label you declared in Step 1 6. 7. When the number has been entered and stored in memory in the Label created in Step 1, use the "C" printf() function to display the ORIGINAL NUMBER as an INTEGER type AND ASLO as a HEXADECIMAL NUMBER by using the FORMAT string created in Step 4 AND the Label from Step 1 to provide the TWO DATA values for the %i and %X printf() FORMAT SPECİFIERS 8. REPEAT (L.e. DUPLICATE) the code instructions you created for Step S, Step 6 and Step 7for EACH of following numbers ONE at a time: 15, 37, 109, 352, 5296

#### Similar Solved Questions

##### Two boats leave a ramp traveling in opposite directions
Two boats leave a ramp traveling in opposite directions.The second boat is 10 miles per hour faster than the first. After 3 hours they are 150 miles apart. Find the speeds of the boats....
##### What is the domain and range of f(x)=4?
What is the domain and range of f(x)=4?...
##### The state of stress at a point is shown on the element. (a) Determine the principal...
The state of stress at a point is shown on the element. (a) Determine the principal stress at the point. Specify the associated orientation and indicate the results on an element at the point. (b) Determine the maximum in-plane shear stress at the point. Specify the associated orientation and indica...
##### How do you graph f(x)=-2/x using holes, vertical and horizontal asymptotes, x and y intercepts?
How do you graph f(x)=-2/x# using holes, vertical and horizontal asymptotes, x and y intercepts?...
##### In one dimension Mech COnscretion of moment HW-62 3. Two astronauts A and B. narticipate in...
in one dimension Mech COnscretion of moment HW-62 3. Two astronauts A and B. narticipate in three collision experiments in a weightless, friction environment. In each experiment, astronaut B is initially at rest, and astronaut A has an initial momentum of 20 kg-m/s to the right. (The velocities of t...
...
##### What are some of the disadvantages to the exclusive use of synthetic fertilizers to replenish soil nutrients?
What are some of the disadvantages to the exclusive use of synthetic fertilizers to replenish soil nutrients?...
##### 1 (Ch 1 - Ch 3) Required information The following information applies to the questions displayed...
1 (Ch 1 - Ch 3) Required information The following information applies to the questions displayed below. Tamar Co. manufactures a single product in one department. All direct materials are added at the beginning of the manufacturing process. Conversion costs are added evenly throughout the process. ...
##### QUESTION 18 Convection in the mantle of the Earth is responsible for which of these phenomena?...
QUESTION 18 Convection in the mantle of the Earth is responsible for which of these phenomena? The slowing of the Earth's rotation. Earth's magnetic field. Tsunamis Continental drift. QUESTION 19 Venus and Earth have many volcanoes, however the causes for those volcanoes are different. Hot m...
Myers Company uses a flodba budget for manufacturing overhead based on direct labor hours. Variable manufacturing overhead costs per direct labor hour are as follows: Indirect labor Indirect matcrials $1.20 0.80 Utilities 0.20 Fixed overhead costs per month are Supervision$3,900. Depreciation $2,00... 1 answer ##### Using method of joints, determine the force in each member of the truss and state if... Using method of joints, determine the force in each member of the truss and state if the members are in tension or compression. Assume the truss have no weight. (50%) 3 kN —3m— 3n 2 KN 1 12 m 4 m 0)... 1 answer ##### 4 Alumni dengan selama ini Tele--en onder mense 4. A firm's long-run total cost curve is... 4 Alumni dengan selama ini Tele--en onder mense 4. A firm's long-run total cost curve is TCQ)= 40 Q-10Q' + Overwh output does the production function exhibit economies of scale? Over what range does it exhibit diseconomies of scale? At what quantity is minimum efficient scale?... 1 answer ##### Please help complete these CROSSWORD PUZZLE QUESTIONS ON Digestion 11: Phases of Gastric Activity. THANK YOU... Please help complete these CROSSWORD PUZZLE QUESTIONS ON Digestion 11: Phases of Gastric Activity. THANK YOU Name Digestion II: Phases of tGastric Activity Moments earlier, before your first bite, as you began to unwrap your Tastykake, its sweet aroma wafting to olfactory receptors in your nasal cav... 1 answer ##### Crisp Cookware's common stock is expected to pay a dividend of$2 a share at the...
Crisp Cookware's common stock is expected to pay a dividend of $2 a share at the end of this year (D1 =$2.00); its beta is 0.9. The risk-free rate is 5.3% and the market risk premium is 5%. The dividend is expected to grow at some constant rate, gL, and the stock currently sells for \$40 a share...