Assignment 1: Printing integers Right now, the only printing we can do is of fixed strings,...
Fantastic news! We've Found the answer you've been seeking!
Question:
![Assignment 1: Printing integers Right now, the only printing we can do is of fixed strings, by using the](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/answers/2023/10/65205dfbef4d9_02765205dfbe7f61.jpg)
![Use the following template for your program: section .data BUFLEN: buffer: newline: db section .text global](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/answers/2023/10/65205dfd0b811_02965205dfd0673d.jpg)
![Output The output of f your program should look something like this: 00000000000000000010](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/answers/2023/10/65205dfdbbd11_02965205dfdb7209.jpg)
Transcribed Image Text:
Assignment 1: Printing integers Right now, the only printing we can do is of fixed strings, by using the write syscall. We'll extend this by writing our own code to print 64-bit unsigned integer values. This essentially involves converting a binary value to decimal, using the same procedure we used to convert to binary/hexadecimal: divide repeatedly by 10 and look at the remainders. Converting binary to decimal As with converting decimal to binary, we divide repeatedly (by 10 this time) and use the remainders for the digits. E.g., to convert 101101b to decimal: Binary 101101b 5 100b Ob Remainder Decimal 4 BUFLEN: buffer: section .data _5 45 45 We stop when we get to O. Digits are written in reverse, from the right end of the string. In order to perform the conversion, we will need to pre-allocate a string buffer big enough to hold all the digits of the biggest unsigned 64-bit integer, 18446744073709551615, 20 characters: Home equ times BUFLEN db 20 0 ; Buffer of 20 '\0's (We could also use the .bss section, which is specifically used for uninitialized space, since we don't really need to fill the buffer with Os.) Your code should assume that the value to be converted is stored in register rdi, and the file number to write to in register rsi; it should construct the character representation in the buffer and then call the write syscall to print it to the file number in rsi. Use the following template for your program: section .data BUFLEN: buffer: newline: db section .text global start _start: equ times BUFLEN db mov rsi, 1 mov rdi, 10 call print int mov rsi, 1 mov rdi, 186562354 call print-int mov rsi, 1 mov rdi, 0xdeadbeef12345678 call print int ; End program mov mov syscall print-int: ret rax, 60 rdi, 0 ; Your printing code here 20 0 10 ; Buffer of 20 '\0's ; Single newline ; = 16045690981402826360 decimal ; Return from print_int function Output The output of f your program should look something like this: 00000000000000000010 00000000000186562354 16045690981402826360 The leading Os on each number are fine. For a challenge, try to implement this using only loop for iteration (i.e., no jmp or jCC instructions). Assignment 1: Printing integers Right now, the only printing we can do is of fixed strings, by using the write syscall. We'll extend this by writing our own code to print 64-bit unsigned integer values. This essentially involves converting a binary value to decimal, using the same procedure we used to convert to binary/hexadecimal: divide repeatedly by 10 and look at the remainders. Converting binary to decimal As with converting decimal to binary, we divide repeatedly (by 10 this time) and use the remainders for the digits. E.g., to convert 101101b to decimal: Binary 101101b 5 100b Ob Remainder Decimal 4 BUFLEN: buffer: section .data _5 45 45 We stop when we get to O. Digits are written in reverse, from the right end of the string. In order to perform the conversion, we will need to pre-allocate a string buffer big enough to hold all the digits of the biggest unsigned 64-bit integer, 18446744073709551615, 20 characters: Home equ times BUFLEN db 20 0 ; Buffer of 20 '\0's (We could also use the .bss section, which is specifically used for uninitialized space, since we don't really need to fill the buffer with Os.) Your code should assume that the value to be converted is stored in register rdi, and the file number to write to in register rsi; it should construct the character representation in the buffer and then call the write syscall to print it to the file number in rsi. Use the following template for your program: section .data BUFLEN: buffer: newline: db section .text global start _start: equ times BUFLEN db mov rsi, 1 mov rdi, 10 call print int mov rsi, 1 mov rdi, 186562354 call print-int mov rsi, 1 mov rdi, 0xdeadbeef12345678 call print int ; End program mov mov syscall print-int: ret rax, 60 rdi, 0 ; Your printing code here 20 0 10 ; Buffer of 20 '\0's ; Single newline ; = 16045690981402826360 decimal ; Return from print_int function Output The output of f your program should look something like this: 00000000000000000010 00000000000186562354 16045690981402826360 The leading Os on each number are fine. For a challenge, try to implement this using only loop for iteration (i.e., no jmp or jCC instructions).
Expert Answer:
Answer rating: 100% (QA)
The images show an assignment that teaches how to print integers in assembly language specifically for 64bit unsigned integer values The exercise aims to extend printing capabilities from fixed string... View the full answer
Related Book For
Foundations of Financial Management
ISBN: 978-1259024979
10th Canadian edition
Authors: Stanley Block, Geoffrey Hirt, Bartley Danielsen, Doug Short, Michael Perretta
Posted Date:
Students also viewed these programming questions
-
Explain at least 3 ways Boccaccio would disagree with Horace. (the readings genealogy of the gentile" and "are poetica" Pick one level of Dante's Scheme for interpretation and explain, how his use of...
-
Lindsey Vonn sells real property for $315,000. The buyer pays $2,000 in property taxes that had accrued during the year while the property was still legally owned by Lindsey. In addition, Lindsey...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Factor by grouping. x 2 + 3x - 3y - xy
-
Name some exceptional companies whose founders were in their twenties when they launched the company?
-
Procedures that are used to keep track of an entity's financial transactions and to accumulate the results of its operations. a. Accounting b. Entity C. Financial accounting d. Bookkeeping . p....
-
The Seneca Childrens Fund (SCF) is a local charity that runs a summer camp for disadvantaged children. The funds board of directors has been working very hard in recent years to decrease the amount...
-
Petit Industries has $100,000 to invest. The company is trying to decide between two alternative uses of the funds. The alternatives are: The working capital needed for project B will be released at...
-
Chapman Company obtains 100 percent of Aborothy Company's stock on January 1, 2020. As of that date. Abernathy has the following a balance Debit Credit $ 54,100 $48,500 110,000 66,00 50.000 250.000...
-
Bright Sparks Electrical - Bank Register Report: Now that you have completed the journals for the month, you need to prepare the Bank Register Report in the template below. Not all general journals...
-
Archer, Maddie and Dillon became friends seven years ago when they travelled together to Indonesia on a surfing trip organised by a local travel company. At the time of the trip they were each taking...
-
ty: Calculating the WACC Excel Activity: Calculating the WACC Here is the condensed 2021 balance sheet for Skye Computer Company (in thousands of dollars) Current assets 2021 $2.000 Net fixed assets...
-
need help completing my one-month project. anyone willing help me. Ellipses Corp One Month Project Ellipses Corp is a small business that operates in Herndon, VA. The company is located at10 Period...
-
The Westchester Chamber of Commerce periodically sponsors public service seminars and programs. Currently, promotional plans are under way for this year's program. Advertising alternatives include...
-
Is classroom management something you worry about? If so, you are in good company. Many teachers worry about this topic. The teacher in this video shows many great classroom management strategies....
-
ProForm acquired 60 percent of ClipRite on June 30, 2020, for $780,000 in cash. Based on ClipRite's acquisition-date fair value, an unrecorded intangible of $560,000 was recognized and is being...
-
The following totals for the month of June were taken from the payroll register of Arcon Company: Salaries expense $ 14,600.00 Social security and Medicare taxes withheld 1,095.00 Income taxes...
-
Find a least expensive route, in monthly lease charges, between the pairs of computer centers in Exercise 11 using the lease charges given in Figure 2. a) Boston and Los Angeles b) New York and San...
-
AI Quick, president of a Toronto Stock Exchange-listed firm , is very short-term oriented and interested in the immediate consequences of his decisions. Assume Mr. Quick is considering a project that...
-
Calculate the price of a bond originally issued six years ago that pays semiannual interest at the rate of 12 percent and matures in nine years at $1,000. The market currently requires an 8 percent...
-
For Nix Corporation, what is the tax savings due to amortization expense?
-
We compute the value of the c2 statistic to be 6.58. Assuming that the conditions for inference are met, the P-value of our test is (a) greater than 0.20. (d) between 0.01 and 0.05. (b) between 0.10...
-
The conditions for carrying out the chi-square test in exercise T11.2 are I. Independent random samples from the populations of interest. II. All expected counts are at least 5. III. The population...
-
The category that contributes the largest component to the c2 statistic is (a) White. (c) Hispanic. (b) Black. (d) Other. (e) The answer cannot be determined because this is only a sample.
![Mobile App Logo](https://dsd5zvtm8ll6.cloudfront.net/includes/images/mobile/finalLogo.png)
Study smarter with the SolutionInn App