college/Fall-2024/CS-3843/Assignments/10/Assignment.typ

145 lines
3.3 KiB
Plaintext

#show link: set text(blue)
#set text(font: "Calibri")
#show raw: set text(font: "Fira Code")
#set table.cell(breakable: false)
#set table(stroke: (x, y) => (
left: if x > 0 {
.1pt
},
top: if y == 1 {
0.5pt
} else if y > 1 {
0.1pt
},
))
#set page(margin: (y: .25in, x: .5in))
#let solve(solution) = {
block(
outset: 3pt,
inset: 3pt,
stroke: blue + .3pt,
fill: rgb(0, 149, 255, 15%),
radius: 4pt,
)[#solution]
}
#let solvein(solution) = {
let outset = 3pt
h(outset)
box(
outset: outset,
stroke: blue + .3pt,
fill: rgb(0, 149, 255, 15%),
radius: 4pt,
)[#solution]
}
#let note(content) = {
block(
outset: 3pt,
inset: 5pt,
stroke: luma(20%) + .3pt,
fill: luma(95%),
radius: 4pt,
)[#content]
}
#let notein(content) = {
let outset = 3pt
h(outset)
box(
outset: outset,
stroke: luma(20%) + .3pt,
fill: luma(95%),
radius: 4pt,
)[#content]
}
#align(center)[
= CS 3843 Computer Organization
HW 10\
#underline[Price Hiller] *|* #underline[zfp106]
]
#line(length: 100%, stroke: .25pt)
1. Given the 32-bit hex `0x4C4B4016`
What is the:
1. Least Significant Byte (LSB)
#solve[`0x16`]
2. Most Significant Byte (MSB)
#solve[`0x4C`]
2. Given the 32-bit hex `0x4C4B4016`, show the little-endian memory layout showing each byte in memory. Provide visualization.
#solve(
table(
columns: 2,
table.header([Byte Index], [Byte]),
[0], [`0x16`],
[1], [`0x40`],
[2], [`0x4B`],
[3], [`0x4C`],
),
)
3. If the `%rax` register is set to `0x0123456789ABCDEF`, what are the contents of the following registers in hex?
1. al
#solve[`0xEF`]
2. ax
#solve[`0xCDEF`]
3. eax
#solve[`0x89ABCDEF`]
4. rax
#solve[`0x0123456789ABCDEF`]
// #align(center + horizon, text(size: 3em, note[See Next Page]))
// #pagebreak()
4. For this value, `0xFEDCBA9876543210`, how this value will be stored in stack top location for x86-64 assembly language (hint: little-endian or big-endian). Explain and provide visualization
#solve[
#table(
align: center,
columns: (50%, 50%),
[
#underline[Little Endian]\
#solve(
table(
columns: 2,
table.header([Example Address], [Byte]),
[7], [`0xFE`],
[6], [`0xDC`],
[5], [`0xBA`],
[4], [`0x98`],
[3], [`0x76`],
[2], [`0x54`],
[1], [`0x32`],
[0], [`0x10`],
),
)
Little Endian stores the most significant byte at the at the highest memory address and the least significant byte at the lowest memory address.
],
[
#underline[Big Endian]\
#solve(
table(
columns: 2,
table.header([Example Address], [Byte]),
[7], [`0x10`],
[6], [`0x32`],
[5], [`0x54`],
[4], [`0x76`],
[3], [`0x98`],
[2], [`0xBA`],
[1], [`0xDC`],
[0], [`0xFE`],
),
)
Big Endian stores the most significant byte at the at the lowest memory address and the least significant byte at the highest memory address.
],
table.cell(colspan: 2, notein[x86-64 assembly is not _necessarily_ Little Endian. Technically it's possible for it to be Big Endian.])
)
]