Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

[Yasm] [ Ebe] The computation is done in Yasm using Ebe. If you any questions, please ask Here are the codes from Chapter 2 and

[Yasm] [ Ebe]

The computation is done in Yasm using Ebe. If you any questions, please ask

image text in transcribed

image text in transcribed

Here are the codes from Chapter 2 and Chapter 3. memory.asm and ch02.lst

image text in transcribed

image text in transcribed

Here are the examples from Chapter 3

image text in transcribed

image text in transcribed

image text in transcribed

The second laboratory exercise requires you to assign and transcribe different data types in yasmasm assembly language. Please create a file named memory.asm in EBE. Using the codes from Chapter 2 and 3, create a segment as .data in your file. Question 1- .data section. The first exercise requires you to code different numbers in the .data segment. There are generally four different types: db - byte (1 byte) dw - word (2 bytes) dd - double word (4 bytes) dq - quad word (8 bytes) The task is the following: 1. Choose an integer within this range [25, (27 1)]. Allocate this number using the three different types of db, dw and dd. Use labels a, b and c. 2. Choose a floating point number within this range [24, 26). Use at least three decimal points (non-zero values). Allocate this number using the dd type. Use label d. 3. Given the number 32452p, assign it using the minimum data type in base-16. Use label e. Question 2 - .bss section. The second exercise requires you to reserve different numbers in the .bss segment. 1. Reserve 10 words. Use label g. 2. Reserve an array of 50 bytes. Use label h. 3. Reserve an array of 15 double words. Use label i. Computation Use either the ebe interface or command line (makefile) to generate the machine code as memory.lst. In this file, you will have three fields (columns). The first columns is the mem- ory locations, the second columns is the values translated into base-16, however reversed. The third columns is the instructions itself. For each instruction in Question 1, convert the number into base-16 and verify it with col- umn 2. Save this computation in the file computation.doc. Please follow the example as in Chapter_3_example_03.pdf and show all working and explanation. Secondly, compute the memory displacement and verify it with column 1. Save this computa- tion in the file computation.doc. Please follow the example as in Chapter_3_example_03.pdf and show all working and explanation. Hat a X Command line hello.asm Downloads/CS311_Codes_Chapter3/CS311_Codes_Chapter3/memory.asm 1 2 3 a b 4 IU A OU U segment .data dd 4 dd 4.4 times 10 dd 0 dw 1, 2 db Oxfb db "hello world", 0 5 d ON Poo o o o e f g h i bis segment .bss resd 1 resd 10 resb 100 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 section .text global main ; let the linker know about main main: push mov sub rbp rbp, rsp rsp16 ; set up a strack frame for main ; let rbp point to the previous ssp ; leave some room for local variables ; and align stack to 16 byte boundary ; set rax to o for return value ; undo the stack manipulations , eax xor leave ret - cho2.Ist - Notepad File Edit Format View Help 620 621 622 623 624 625 626 627 628 1 2 00000000 00000000 3 00000004 0000803F 4 00000008 000080BF 5 0000000C 0000E03F 6 00000010 0000F542 7 00000014 00004401 8 00000018 0060F3C2 %endmacro %macro fpunalias 1-* %rep %0 %undef y%1 %undef x%1 %rotate 1 %endrep %endmacro segment .data dd 0.0 one dd 1.0 negi dd -1.0 a dd 1.75 b 122.5 d dd - 12.25 e dd - 121.6875 zero dd 0 Ln 1, Col 1 100% Windows (CRLF) UTF-8 Memory Example Mem Size Mem Translation Code 1 segment .data 2 00000000 04000000 a dd 4 3 00000004 CDCC8C40 b dd 4.4 4 00000008 00000000 times 10 dd o 5 00000030 01000200 d dw 1, 2 6 00000034 FB e db Oxfb db "hello world", o 7 00000035 68656C6C6F20776F72- f 7 0000003E 6C6400 Part 1 - Memory Translations Label a b Size (bytes) dd = 4 dd = 4 dd = 4 x 10 = 40 dw = 2 x 2 = 4 db = 1 Decimal 4 4.4 0 1,2 Hex (0x) 0000 0004 408C CCCD 0000 0000 0001 0002 FB Byte reversed 0400 0000 CDCC 8C40 0000 0000 0100 0200 FB d e Number = 4.4 Sign bit = 0 as this is positive Whole number = 4 = 0100 in base2 Fraction part = 0.4 0.4 x 2 = 0.8 = .0 0.8 x 2 = 1.6 = .01 0.6 x 2 = 1.2 = .011 0.2 x 2 = 0.4 = .0110 0.4 x 2 = 0.8 = .01100 becomes cyclic 0.8 x 2 = 1.6 = .011001 0.6 x 2 = 1.2 = .0110011 0.2 x 2 = 0.4 =.01100110 the bar indicates that this portion cycles So the final number can be given as: 100.011001100110011001100110 x 20 Which in scientific notation is: 1.00011001100110011001100110 x 22 Exponent is 2, therefore final exponent field is 127 + 2 = 129 = 1000 0001 The final bit field looks like this: 0 1 | 0|0|0|0|0|0 | 1 | 0|0|0 | 1 | 1 | 0 | 0 | 1 | 1 | 0|0|1|1|0|0|1| 1 | 0 | 0 | 1 | 1 | 0 | 1] Converting this to a base 16, requires to first split it into nibbles, and then convert each nibble to base 16: 0100 0000 1000 1100 1100 1100 1100 1101 4 0 8 C C C C D- this last nibble is rounded off Therefore, the final answer is: 0x408CCCCD Byte reversed - OxCDCC8C40 Part 2 - Memory Size Label a b Size (bytes) dd = 4 dd = 4 dd = 4 x 10 = 40 dw = 2 x 2 = 4 db = 1 Size (Hex) Rolling total 04 0000 0000 04 0000 0004 28 0000 0008 04 0000 0030 01 0000 0034 d Label c: 40 bytes = 0010 1000 in base-2 = 0x28 in base-16 0x28 + 0x08 = 0x30 (as 8 + 8 = 16, which is 0x10)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Database Programming With Visual C# .NET

Authors: Ying Bai

1st Edition

0470467274, 978-0470467275

More Books

Students also viewed these Databases questions