module 5: Application, programming language, and translation Flashcards

(9 cards)

1
Q

Briefly describe the advantages of using assembly language.

A

Symbolic names - opposed to binary code or numeric addresses

error detection - syntax errors, invalid addressing modes

hardware optimization - can be tailors for hardware features

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are two main functions of an assembler

A

a program that converts assembly language programs to object code

allows programmers to use symbolic names

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a high-level language

what are the advantages of using one for programming? (2 advantages)

A

progamming language for human programmers

{
makes code portible
- not tied to a particular processor / instruction set/ architecture

abstracts away from the machine level details
- programmer does not need to know the processor hardware/ architecture/ components

problem oriented
- focus on program logic
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Briefly describe the functions of a compiler.

A

processes HLL program code and generates assembler code for the target processor

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Show with the aid of diagrams how conditional branches and unconditional jump statements are used to implement the following high-level programming constructs:

a. IF .. THEN .. ELSE conditional statement
b. WHILE loop
c. DO .. WHILE loop

A

(lol refer to slides i cant import images this shit ass, i remember that images used to be free)

short explanation tho:

JNZ (jump not zero) instruction would run and if there condition is True, then branch executed

conditional branch: when certain conditions are met

unconditional jump: executing code at another memory address.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Briefly explain (with the aid of diagrams) how data is stored and retrieved from a stack, including the role of the SP register.

A
  • last in, first out
  • pushing a location onto a stack, popping off the stack.
  • top of the stack address is stored in the stack pointer (SP)

image a stack of plates but you cannot take from the middle or bottom of the stack.

pushing:
* 3 words stored onto the stack:
Word A
then B
finally Word C
* Initially SP = address 0164h
* When Word A pushed:
SP automatically decremented to point to 0162h
Then Word A stored (little endian)
* Then Word B
* After Word C pushed:
SP will contain the address 015Eh
the new “top” of the stack
* Reverse process happens when ‘popping off’
data from stack.

popping:
* Reverse process happens when ‘popping off’
data from stack.
* E.g POP AX
* Top of stack data copied to register AX
* Then SP automatically incremented to point to 0160h
* the new “top” of the stack

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Explain the role of CALL and RETURN instruction when implementing subroutines and the role of the stack in the execution of these instructions.

A

a subroutine is is a sequence of instructions that perform a specific task (like a python function)

CALL:
- address after the next instruction (after call) is pushed onto stack
- so the CPU knows where to come back to after finishing the subroutine

RETURN:
- pops the address from the stack

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

List the advantages of using subroutines when writing programs.

A

Allows for efficient and logical coding:
- Commonly used functions can be embedded insubroutines and called repeatedly as needed
- Do need to repeat the code for a function over and over in the main program
- less errors

Allows for previously developed code to be used (removes redundancy)
- library functions e.g. <cmath></cmath>

Allows code written in a different platform / language to be linked
- provided interface/ parameter passing is correct

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Describe the function of a linker.

A

A linker is a program that combines various object files into a single executable file

◦ A program may call many subroutines that sit in various libraries

◦ The linker pulls in the required (called) library functions and creates a single executable (machine code) file that has all the required code.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly