CSCI 3130: Exam 1

¡Supera tus tareas y exámenes ahora con Quizwiz!

What are the advantages of learning assembly language?

- It gives us a better understanding of how a processor, compiler, or language functions - Assembly is much faster than other types of languages - Some architectures don't have C compilers - Useful for writing compilers

How are comments recognized in assembly?

Comments can either be a # or they can be //

What does the following instruction do CMP $0, %rax JE done

Compares immediate memory 0 with rax and jumps to done if they are equal

What is computer organization?

Computer organization is focused on the details of how the hardware of a computer functions and how it interfaces with code or the machine.

Let's assume the following array "Arr" with 16 64-bit integers: Arr: .quad 7, 6, 2, 89, 3, 12, 66, 45, 12, 9, 8, 1, 9, 88, 90, 11 What is moved to the rax register based on mov Arr(,2,4), %rax

Invalid statement: 1st factor in moving element of array must be index register (i.e %r15, %r14, etc).

What does mov $message, %rax do?

Moves the address of variable message into register rax

What is an object file?

Object files are machine code output of a compiler or an assembler. Usually created after compiling code and holds data of whats in the code. Can be put in different formats.

What is opcode in x86_80?

Opcode is the operational code we use to give the machine instruction. In assembly we use mnemonic opcode, meaning we have abbreviated some of the english language to denote operations: ex MOV, MUL, SUB, etc.

What does the DIV Instruction do?

Takes one argument and divides RAX from the argument given. Quotient stored in RAX and remainder in RDX. Make sure to mov 0 into RDX before dividing. Otherwise you might be given a big random number.

What does the MUL instruction do?

Takes one argument and multiplies RAX by the the given argument. The value is returned in RAX.

What symbol is used to represent immediate/ constant values?

The $ symbol

What symbol is used for the registers?

The % symbol

Whats the difference between the text section and the data section in assembly?

The text definition is where the code is written. It is where functions would be defined, called, instructions are performed, and etc. The data section is for static data declarations to be used in the code. We would create variables, arrays, strings, etc.

Who is John Vincent Atanasoff

created the first digital computer

Who is George Boole?

developed Boolean algebra

What is the memory syntax of 4(%rax, %rdx,8)

rax plus 8 times whats in rdx plus 4

Let's assume %rcx = 5, and %rax = 3 What is stored in rax, rdx, and rcx after MUL %rcx

rax: 15 rdx: 0 rcx: 5

Let's assume %rcx = 5, and %rax = 3 What is stored in rax, rdx, and rcx after DIV %rcx

rax: 3 rcx:5 rdx: random number (Caused FPE because tried to divide 3/5, can't divide integers like this)

What is the register convention to passing arguments to standard functions

rdi, rsi, rdx, rcx, r8, r9

The .quad reserves how many bits of memory?

8

What would each of the terms below allocate in memory? .ascii .byte .word .long .quad .double

.ascii will allocate a byte for a char type, can be multiple characters .byte will allocate a byte for integer types .word will allocate 2 bytes for an integer type. .long will allocate 4 bytes for long integer types .quad allocates 8 bytes for long long integer types .double will allocate 8 bytes for a double floating point value

What GNU assembler keyword is used to make an assembly function visible to foreign codes?

.global

What is the .global keyword used for in assembly?

.global is used in assembly when the code is being accessed by an outside language like c++/c/fortran etc.

How many general purpose registers are there and what are their names?

16 registers: rax, rbx, rcx, rdx, rdi, rsi, rbp, rsp, r8, r9, r10, r11, r12, r13, r14, r15

What is abstraction in programming languages?

Abstraction is how far removed a language is from the physical hardware of a computer. A language with a higher abstraction is farther removed from the hardware and can do more with less instruction (Python, C++, C). A language with a lower level of abstraction has to do more in terms of placing components, using the hardware, and other components that make the machine run.

Why are NAND and NOR gates considered universal gates?

Because they could be used to create any type of logic circut.

Who is Claude Shannon?

Father of the information and digital age, proved all digital circuits could be described using Boolean algebra.

Let's assume the following array "Arr" with 16 64-bit integers: Arr: .quad 7, 6, 2, 89, 3, 12, 66, 45, 12, 9, 8, 1, 9, 88, 90, 11 What is moved to the rax register based on mov Arr(16)

Gives a compile error, not two arguments for mov instruction and (16) is junk

What is the difference between a high level language and a low level language?

High level languages have a high level of abstraction from hardware, meaning you don't need to know how to place components, you are just able to use them to get a desired outcome. Low level languages have low abstraction from hardware, meaning you need to know how to place the components where they need to be and how to utilize them in order to get the desired outcome

What is computer architecture?

The computer architecture focuses more on how the hardware is used. It's what the programmer needs to know about so that they can use the system effectively.

What is the memory syntax of (, %rax, %rdx)

The product of the data in rax and rdx

What does the following instructions do: DIV %rcx

This divides rax/rcx and will store the quotient in rax and the remainder in rdx. (VERY IMPORTANT to 0 out rdx or else it will give you a really big number. rdx could have random value so its best to do that)

What is the MOV instruction?

This instruction moves data between two different places, can be used to move immediate memory into registers or store registers into other registers, etc.

What does the following instruction do MUL %rcx

This instruction multiplies whatever is in rcx by rax and stores the result in rdx:rax

What does ADD instruction do?

This instruction takes two arguments and adds the two numbers together. must remember to use parenthesis if adding a number within a reference address.

What does the SUB Instruction do

This instruction takes two arguments and subtracts the two numbers together. must remember to use parenthesis if using a number within a reference address. Also make the higher number second to avoid negative number. EX: mov $3, %rax mov $1, %rdx sub %rdx, %rax

What does mov $rdi, %rax do?

This is an invalid instruction, the rdi register should be denoted by the % sign

Why do you need to make rax 0 before calling the c built function printf?

This is because rax specifies how many SSE registers (for floating point values) are being used in the function. Normally when we call it we aren't using any so we must mov 0 into it.

Why should you make register rdx 0 before division?

This is because the div instruction uses both registers rax and rdx. So if you divide something and rdx is not zeroed out, it will give you a big number that you don't want.

What does mov %rax, $message do

This is invalid as the address for message is constant and cant be changed. it should be MOV %rax, (message)

What is the memory syntax of 8(%rax)

This is the data of rax plus 8 (any number outside parenthesis of address means add number to it)

What is the memory syntax of (%rax, %rdx)

This means the sum of the data in rax and rdx (Sum together registers when inside same parenthesis)

What does mov (message), %rdi do?

This moves the data in the address message to rdi

Whats the meaning of the memory syntax 0x506

This shows a hex address of 0506

Let's assume the following array "Arr" with 16 64-bit integers: Arr: .quad 7, 6, 2, 89, 3, 12, 66, 45, 12, 9, 8, 1, 9, 88, 90, 11 What is moved to the rax register based on mov Arr, %rax

This stores the address of the array into rax

What does the following instruction do SUB %rdx, %rax

This subtracts rax - rdx (only the value stored in rax and rdx, if an address must specify the data in the registers)

What happens to RAX and RDX after the multiply instruction?

When the MUL instruction is called, whatever register is multiplied is stored in rax and rdx (it can store up to 128 bits).

What is the difference between system function calls and standard function calls?

With a system function call, the function is provided by the OS. You move all of the parameters in the specified parameters then use the syscall instruction to execute the function. The convention used is: rdi, rsi, rdx, r10, r8, r9. System call number goes in rax. For a standard function call, the function is defined in the .text section and is invoked using the the call instruction. The convention for this type of function is rdi, rsi, rdx, rcx, r8, r9.

Let's assume the following array "Arr" with 16 64-bit integers: Arr: .quad 7, 6, 2, 89, 3, 12, 66, 45, 12, 9, 8, 1, 9, 88, 90, 11 What is moved to the rax register based on mov Arr(1,4,2), %rax

invalid statement: Should only be two arguments in parentheses, register index and factor scale

What GNU assembler instruction is used to call an os system function call?

syscall

What instruction performs system calls

syscall


Conjuntos de estudio relacionados

The Social Construction of Difference-Race, Class, Gender, and sexuality

View Set

Ch. 11 The Cardiovascular system

View Set

BIOS/UEFI 3.10.9 Practice Questions, 3.9.6 Practice Questions Troubleshooting Memory, 3.8.8 Practice Questions Memory Installation, 3.8.8 Practice Questions Memory Installation

View Set

Cognitive Psychology - Conscious Thought, Unconscious Thought

View Set

Architecture State Assessment Review 1

View Set

Life practice questions (florida)All of the following provisions must be included in group life insurance policies issued in this state EXCEPT:

View Set