Difference between revisions of "LU-MOP-en"

From DiLab
Jump to: navigation, search
(xx.01.22)
(19.12.2023)
 
(55 intermediate revisions by the same user not shown)
Line 6: Line 6:
[[#Assignments | Assignments]] |
[[#Assignments | Assignments]] |
[[#Resources | Resources]] |
[[#Resources | Resources]] |
[[#{{CURRENTDAY2}}.{{CURRENTMONTH}}.{{CURRENTYEAR}}. | Today <small>(if there is a class)</small>]]
[[#{{CURRENTDAY2}}.{{CURRENTMONTH}}.{{CURRENTYEAR}} | Today <small>(if there is a class)</small>]]
</big>
</big>

'''Course: Assembly Programming'''
'''Course: Assembly Programming'''





=Calendar=
=Calendar=
Line 22: Line 20:
|- style='vertical-align: top;'
|- style='vertical-align: top;'
|
|
====14.09.21====
====19.09.2023====
|
|
{| width='100%' style='background-color:#ddd;'
{| width='100%' style='background-color:#ddd;'
Line 33: Line 31:
|- style='vertical-align: top;'
|- style='vertical-align: top;'
|
|
====21.09.21====
====19.09.2023====
|
|
{| width='100%' style='background-color:#ddd;'
{| width='100%' style='background-color:#ddd;'
Line 41: Line 39:


|
|
'''Quiz 1'''

Decimal, binary, octal and hexadecimal systems.


|- style='vertical-align: top;'
|- style='vertical-align: top;'
|
|


====28.09.21====
====26.09.2023====
|
|
{| width='100%' style='background-color:#ddd;'
{| width='100%' style='background-color:#ddd;'
Line 56: Line 51:


|
|
'''Quiz 2'''
'''Quiz 1'''


Decimal, binary, octal and hexadecimal systems.
Two's complement.


|- style='vertical-align: top;'
|- style='vertical-align: top;'
|
|


====05.10.21====
====03.10.2023====
|
|
{| width='100%' style='background-color:#ddd;'
{| width='100%' style='background-color:#ddd;'
Line 71: Line 66:


|
|
'''Quiz 2''' (rescheduled to next week)
Two's complement.

Lab:


Developing and testing a simple Assembly program. Using cross-compilation tools. Introduction to the Make system.
Developing and testing a simple Assembly program. Using cross-compilation tools. Introduction to the Make system.
Line 76: Line 75:
|- style='vertical-align: top;'
|- style='vertical-align: top;'
|
|

====12.10.21====
====10.10.2023====
|
|
{| width='100%' style='background-color:#ddd;'
{| width='100%' style='background-color:#ddd;'
Line 84: Line 84:


|
|
'''Quiz 2'''

Two's complement.


Announced: '''HW1''' - Arithmetic progression
Announced: '''HW1''' - Arithmetic progression
|- style='vertical-align: top;'
|- style='vertical-align: top;'
|
|


====19.10.21====
====17.10.2023====
|
|
{| width='100%' style='background-color:#ddd;'
{| width='100%' style='background-color:#ddd;'
Line 96: Line 101:


|
|
Practicing tracing the code (on "paper")

Evaluating and following the code "on paper".


|- style='vertical-align: top;'
|- style='vertical-align: top;'
|
|


====26.10.21====
====24.10.2023====
|
|
{| width='100%' style='background-color:#ddd;'
{| width='100%' style='background-color:#ddd;'
Line 111: Line 115:
|
|


Code comprehension practice.
'''Quiz 3'''


Code comprehension.

* '''Due''' '''HW1''' - Arithmetic progression
* Announced: '''HW2''' - Matrix multiplication
* Announced: '''HW2''' - Matrix multiplication


Line 121: Line 122:
|
|


====02.11.21====
====31.10.2023====
|
|
{| width='100%' style='background-color:#ddd;'
{| width='100%' style='background-color:#ddd;'
Line 129: Line 130:


|
|
* '''Quiz 3''' - Code comprehension (moved)

* '''Due''' '''HW1''' - Arithmetic progression




|- style='vertical-align: top;'
|- style='vertical-align: top;'
|
|

====09.11.21====
====07.11.2023====
|
|
{| width='100%' style='background-color:#ddd;'
{| width='100%' style='background-color:#ddd;'
Line 141: Line 146:


|
|


* '''Due''' '''HW2''' - Matrix multiplication


|- style='vertical-align: top;'
|- style='vertical-align: top;'
|
|

====12.11.21====
====14.11.2023====
|
|
{| width='100%' style='background-color:#ddd;'
{| width='100%' style='background-color:#ddd;'
Line 155: Line 158:


|
|
* '''Quiz 3''' - Code comprehension
* '''Due''' '''HW2''' - Matrix multiplication


|- style='vertical-align: top;'
|- style='vertical-align: top;'
|
|

====16.11.21====
====21.11.2023====
|
|
{| width='100%' style='background-color:#ddd;'
{| width='100%' style='background-color:#ddd;'
Line 168: Line 174:


|
|
* Assignment '''Proj''' - Project
* Assignment '''Proj''' - Project choice


|- style='vertical-align: top;'
|- style='vertical-align: top;'
|
|

====23.11.21====
====28.11.2023====
|
|
{| width='100%' style='background-color:#ddd;'
{| width='100%' style='background-color:#ddd;'
Line 182: Line 189:
* '''Due''' '''M1P1''' - Midterm 1 programming task 1, tested
* '''Due''' '''M1P1''' - Midterm 1 programming task 1, tested
* '''Due''' '''M1P2''' - Midterm 1 programming task 2, tested
* '''Due''' '''M1P2''' - Midterm 1 programming task 2, tested
<!--

-->



|- style='vertical-align: top;'
|- style='vertical-align: top;'
|
|


====30.11.21====
====05.12.2023====
|
|
{| width='100%' style='background-color:#ddd;'
{| width='100%' style='background-color:#ddd;'
Line 196: Line 203:


|
|
Due: Choice: Written exam vs. programming project (in eStudijas)

|- style='vertical-align: top;'
|- style='vertical-align: top;'
|
|


====07.12.21====
====12.12.2023====
|
|
{| width='100%' style='background-color:#ddd;'
{| width='100%' style='background-color:#ddd;'
Line 206: Line 213:
|}
|}
Execution time for instructions. Case study for code optimization. Leveraging the documentation and specification of instructions. Reordering the code. Unrolling loops. Taking advantage of branch prediction. Cache memory and the code performance.
Execution time for instructions. Case study for code optimization. Leveraging the documentation and specification of instructions. Reordering the code. Unrolling loops. Taking advantage of branch prediction. Cache memory and the code performance.

Documentation: [http://download.intel.com/design/intelxscale/27347302.pdf Intel XScale R Core Developer’s Manual].

The section and focus:
* A.2.1.2 — Processor execution pipe diagram. Instruction and data flow description.
* 10.4 — Instruction execution time. For example, multiplication vs. addition.
* 5 — Branch prediction mechanism
* 4 and 6 — Cache memory. Instruction cache and Data cache.
* A.3–A.5 — Optimizations as suggested by Intel.


|
|


|- style='vertical-align: top;'
Review of the course topics
|
* '''Due By midnight''' '''Proj''' - Project

====12.12.2023====
|
{| width='100%' style='background-color:#ddd;'
|<big>'''Systems on chip (SoC)'''</big>
|}

* Datasheets
* Memory map
* Communications protocols (RS232, USB, SPI, I2C, 1-wire, CAN)
* Peripherals
* Watchdog timer
* Bootstraping

Case study:
* Atmega328P MCU ([https://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-7810-Automotive-Microcontrollers-ATmega328P_Datasheet.pdf datasheet])
* [https://www.elprocus.com/avr-atmega8-microcontroller-architecture-applications/ Atmega8 architecture description]

'''Review of the course topics'''

|


|- style='vertical-align: top;'
|- style='vertical-align: top;'
|
|


====05.01.22====
====02.01.2024====
12:30
12:30
|
|
Line 226: Line 263:


|
|
* '''Due''' '''ExamP1''' - Exam programming task, tested
* '''Due''' by the end of the day: '''ExP1''' - Exam programming task, tested

|}
|}


=Assignments=
=Assignments=
* Homeworks and other assignments are available from e-Studijas
=Resources=

*[https://www.cs.colby.edu/maxwell/courses/tutorials/maketutor/ A simple Makefile tutorial]
{{MCU_resources}}
* [https://developers.redhat.com/blog/2021/04/30/the-gdb-developers-gnu-debugger-tutorial-part-1-getting-started-with-the-debugger GDB getting started tutorial]

Latest revision as of 12:18, 18 December 2023

Shortcuts: Calendar | Assignments | Resources | Today (if there is a class)

Course: Assembly Programming

Calendar

Date Topic, content Deliverables

19.09.2023

Introduction

Microprocessors and microcontrollers. Applications. Architectures. Coourse outline.

19.09.2023

Hexadecimal arithmetic

Representation of non-negative numbers in hardware, registers and memory. Decimal, binary, octal, and hexadecimal systems. Converting between the systems.

26.09.2023

Two's complement

Representing negative numbers in hardware. Register size, and why it is important. Methods for encoding negative numbers: packed, signed, bias, one's complement and two's complement. Converting between the value and two's complement in binary and hexadecimal systems.

Quiz 1

Decimal, binary, octal and hexadecimal systems.

03.10.2023

Processor architecture

Architecture of a processor. Registers, register file, ALU, datapath. CISC vs. RISC architectures. x86 architecture as CISC representative. ARM architecture as RISC. Instruction encoding.

Quiz 2 (rescheduled to next week) Two's complement.

Lab:

Developing and testing a simple Assembly program. Using cross-compilation tools. Introduction to the Make system.

10.10.2023

Computing environment

Environment and tools for compiling and debugging Assembly programs. Compiler, preprocessor, assembly, linker, loader, debugger. Cross-compilation and toolchains. Emulators and virtual machines.

Quiz 2

Two's complement.


Announced: HW1 - Arithmetic progression

17.10.2023

ARM Assembly and arithmetic

Introduction to ARM Assembly language and programming. Instruction types. Arithmetic instructions. MOV, ADD, SUB. MVN, ADC, SBC, RSB, RSC. Barrel Shifter.

Practicing tracing the code (on "paper")

24.10.2023

Flow control and tests

Flow control in Assembly. Branch instructions. B, BL, BX, BLX. Working directly with PC register. CPSR flags. Condition field. Bit operations. AND, ORR, EOR, BIC, shift and rotation. CMP, CMN, TST, TEQ. Fast flags and the S postfix.

Code comprehension practice.

  • Announced: HW2 - Matrix multiplication

31.10.2023

Memory instructions

Reading and writing data to memory. Memory access instructions. STR, LDR, STRB, STRH, LDRB, LDRH, LDRSB, LDRSH. Addressing modes: offset, pre-indexed and post-indexed. Using barrel shifter with addressing. Data alignment in memory.

  • Quiz 3 - Code comprehension (moved)
  • Due HW1 - Arithmetic progression


07.11.2023

Calling subroutines and interfacing with C

Variable types in C: static, automatic and dynamic. Calling subroutines and parameter passing conventions. Parameters and return value. Stack and registers. Saving the registers, the context. Loading and storing multiple registers: LDM, STM. Interfacing between Assembly and C.

14.11.2023

Symbols

Symbol encoding in hardware and software. Code tables. ASCII. EBCDIC. ISO code tables. Foreign letter symbols. UTF-8, UTF-16. Strings in C and memory. Converting values to symbols and strings.

  • Quiz 3 - Code comprehension
  • Due HW2 - Matrix multiplication

21.11.2023

Midterm

Data representation in memory. Assembly code comprehension. Two programming tasks.

  • Assignment Proj - Project choice

28.11.2023

Expressions and Macro commands

Expressions in Assembly. Operators in expressions. Constants. Assigning values to symbols. Directives: .set, .equiv, .eqv. Conditional compilation. Directives .if, .ifdef, .endif., ifb, .ifc, .ifeqs. More conditionals .ifeq, .ifge, .ifne and others. Macro commands: .macro, .endm., .rept. Recursive macros. Local macros. Macros across sections.

  • Due M1P1 - Midterm 1 programming task 1, tested
  • Due M1P2 - Midterm 1 programming task 2, tested

05.12.2023

Inline Assembly

Including Assembly in C code. Inline code and Assembly code operands. Tasks for the compiler, linker and loader. Dynamic loaders and libraries.

Due: Choice: Written exam vs. programming project (in eStudijas)

12.12.2023

Optimizations

Execution time for instructions. Case study for code optimization. Leveraging the documentation and specification of instructions. Reordering the code. Unrolling loops. Taking advantage of branch prediction. Cache memory and the code performance.

Documentation: Intel XScale R Core Developer’s Manual.

The section and focus:

  • A.2.1.2 — Processor execution pipe diagram. Instruction and data flow description.
  • 10.4 — Instruction execution time. For example, multiplication vs. addition.
  • 5 — Branch prediction mechanism
  • 4 and 6 — Cache memory. Instruction cache and Data cache.
  • A.3–A.5 — Optimizations as suggested by Intel.

12.12.2023

Systems on chip (SoC)
  • Datasheets
  • Memory map
  • Communications protocols (RS232, USB, SPI, I2C, 1-wire, CAN)
  • Peripherals
  • Watchdog timer
  • Bootstraping

Case study:

Review of the course topics

02.01.2024

12:30

Exam

Data representation in memory. Assembly code comprehension. Multiple choice questions and a programming task.

  • Due by the end of the day: ExP1 - Exam programming task, tested

Assignments

  • Homeworks and other assignments are available from e-Studijas

Resources

Tutorials

Make

GDB

Remote debugging example

Debugging myprog with a parameter 10.

  • First, start the qemu emulator, providing the communications port (12345), and run it in background (&).
    • Before you do this, make sure that the port is not in use by anyone or anything.
  • Then start the gdb-multiarch with the name of the program and
  • Use the gdb command "remote target" with address (localhost) and the port (12345).
  • Finally start the program execution with "continue". Perhaps, you may want to set some breakpoints before that.
$ qemu-arm -L /usr/arm-linux-gnueabi -g 12345 myprog 10 &
$ gdb-multiarch myprog
    (gdb) target remote localhost:12345
    (gdb) continue

A few essential GDB commands

GDB command Shortcut Description
run Run the program from the beginning
continue c Continue (or start) the execution of the program
step s Execute the current line from the source. If there is a function call, step into it.

This command can have a parameter n that tells how many steps to make.

next n Execute the current line from the source. If there is a function call, stop after running it.

This command can have a parameter n that tells how many steps to make.

break <x> b <x>

Set a "breakpoint" to <x>, where <x> could be:

  • line_number in the current source code file
  • filename:line_number
  • function_name
  • filename:function_name
  • *address
  • ...and many others
list l Shows the source code (lines). Could be followed by a function_name or file:line_number
info registers i r Prints all registers and their values. Can be followed by one or more register names.
set step mode on Set running mode such that "step" will enter the code that has no debug information available.

Using "off" instead of "on" resets this mode.

ARM

Xscale

Insights