A collection of x86-64 assembly (GNU AS, AT&T syntax) programs written for a university Computer Architecture and Organization course. The programs cover low-level numeric computation, string/number parsing, and arithmetic on values larger than a single machine word — implemented directly with general purpose registers, the stack, and the x87 FPU.
Each program is self-contained, uses raw Linux syscalls or the C standard library for output, and is written in AT&T syntax for the GNU assembler.
- Linux, x86-64
- GNU Assembler (as) and linker
- gcc (for linking against libc, needed by programs that call printf)
| Script Name | Description |
|---|---|
| 01_recursive_factorial.s | Computes n! using a recursive function with stack-based argument passing; prints the result via printf |
| 02_hex_parser.s | Parses a hexadecimal string into its integer value by hand (digit validation + accumulation), then converts the result back to decimal and prints it via raw write syscalls |
| 03_fpu_precision_comparison.s | Computes two mathematically equivalent forms of the same function, |
| 04_bignum_multiplication.s | Multiplies two arbitrary-precision decimal numbers (given as ASCII digit strings) using manual long multiplication with carry propagation- numbers far exceed a single 64-bit register |
| 05_hex_multiplier.s | Parses two 128-bit hexadecimal numbers from ASCII input and multiplies them byte-by-byte with carry propagation into a 256-bit result buffer, printing the result in hex |
Programs that use raw syscalls only (_start entry point, no libc):
as 02_hex_parser.s -o hex_parser.o
ld hex_parser.o -o hex_parser
./hex_parserPrograms that call printf (main entry point, linked against libc):
gcc 01_recursive_factorial.s -o factorial
./factorial- Recursive function calls in assembly: stack frame setup, register save/restore across calls x87 FPU: floating-point stack (fld/fst/fadd/fsqrt), control word manipulation, precision/rounding
- Arbitrary-precision (bignum) arithmetic: manual long multiplication and carry propagation across byte/digit buffers
- Manual number-base conversion: ASCII hex/decimal parsing and formatting without library support Raw Linux syscalls (write, exit) vs. calling into libc (printf)- and the calling-convention differences between the two
- Numerical correctness awareness: recognizing and demonstrating floating-point catastrophic cancellation
A collection of 8051 assembly programs written for a microprocessor technology fundamentals course. The programs cover port-level I/O, character LCD driving, matrix keypad scanning, timer/interrupt-based signal generation, and interfacing with a memory-mapped real-time clock- all implemented directly against a lab trainer board. Each program is self-contained and written for a Keil-style 8051 macro assembler, targeting the memory-mapped LCD, keypad, RTC, LED and buzzer hardware used in the course lab.
- An 8051-family microcontroller, or a compatible 8051 simulator/trainer board
- An 8051 macro assembler that supports
MACRO/LOCAL/ENDMandEQU - Peripherals wired as on the course trainer board: character LCD (HD44780-style, busy-flag polling), 4x4 matrix keypad, RTC chip, LED/7-segment array and buzzer- all memory-mapped over the external data bus
| Script Name | Description |
|---|---|
| 01_led_digit_display.asm | Shows how a program can control a microcontroller's outputs. LEDs change state, a buzzer sounds, and a display shows text. First, digits 0–9 are read one by one from a table and shown on the display, stopping at an end marker. Then the display alternates between two patterns, and one output pin is switched on and off. A separate routine also flips a few individual LED bits on another port |
| 02_lcd_button_menu.asm | Sets up an LCD screen and shows how pressing buttons changes what's on it. The program checks buttons 1 to 4 one at a time; if a button isn't pressed, it moves on to the next one, and once all four are checked it starts over. When a button is pressed, the screen is cleared and a text message tied to that button is printed on it, character by character until an end marker. Then it goes back to checking the buttons again |
| 03_keypad_lcd_charset.asm | An expanded version of task 2, using a full keypad instead of four buttons. Each key types a character onto the LCD. Three special keys switch what the other keys type: * switches to lowercase letters (a–m), # switches to uppercase letters (A–M), and D switches to digits plus letters A–C. Pressing one of these swaps out the table of characters used by the other keys, so the same buttons can type different things depending on which set is active. The keypad starts on the * (lowercase) set by default |
| 04_digital_clock_keypad.asm | A digital clock, expanded with keypad controls: key A starts the clock, B stops it, C adds one hour, and D subtracts one hour. The screen, keypad and clock are all set up first. The program checks each of the four keypad rows in turn; if no key is pressed in a row, it moves on to the next one. The hour value is always kept between 0 and 23 |
| 05_keypad_piano_synth.asm | Turns the keypad into a simple piano. At the start, a table of sound codes is loaded, one for each key, along with the note's name (like "C1" or "CIS1"). The program keeps checking each keypad row for a pressed key. When a key is pressed, it plays the matching sound and shows the note's name on the screen. If the same key is still held down nothing changes; if it's released, the sound stops and the screen clears. If no key is pressed in a row, the program checks the next row |
| 06_rtc_calendar_display.asm | Builds on task 1 by adding checks that catch invalid times and dates- for example a minute over 59, a day over 31, or an hour over 23. Separate checks exist for hours, minutes, seconds, days and months, and each one runs whenever that value is read in. An invalid value gets reset to zero, except for day and month, which are set to 1 instead, since a date can't have a zero day or month |
These programs target the 8051 trainer board and toolchain used in the course lab rather than a generic Linux/GNU pipeline. Assemble each .asm file with the course's 8051 macro assembler (Keil µVision), then download the resulting HEX file to the trainer board, or run it in an 8051 simulator that emulates the memory-mapped LCD, keypad, RTC and LED peripherals used here.
- Memory-mapped I/O peripheral programming: driving a character LCD (busy-flag polling, control/data macros) entirely over the external memory (
MOVX) address space - Matrix keypad scanning: row-drive/column-read technique, "wait for release" debouncing, and runtime character-set remapping through lookup tables in external RAM
- Timer/interrupt-driven I/O: reprogramming Timer0 reload values from inside an ISR to generate variable-frequency square waves (piano tones) and fixed periodic ticks (clock seconds)
- BCD arithmetic and time/calendar logic: incrementing and rolling over hours, minutes, seconds, day, month and year fields, and validating externally-set values