diff --git a/bootloader1/boot.bin b/bootloader1/boot.bin new file mode 100644 index 0000000..2b5a663 Binary files /dev/null and b/bootloader1/boot.bin differ diff --git a/bootloader1/bootsect.img b/bootloader1/bootsect.img new file mode 100644 index 0000000..77c260e Binary files /dev/null and b/bootloader1/bootsect.img differ diff --git a/bootloader1/floppy.img b/bootloader1/floppy.img new file mode 100644 index 0000000..2b5a663 Binary files /dev/null and b/bootloader1/floppy.img differ diff --git a/counter/counter b/counter/counter new file mode 100755 index 0000000..dc3fc2d Binary files /dev/null and b/counter/counter differ diff --git a/counter/counter.o b/counter/counter.o new file mode 100644 index 0000000..9732ad5 Binary files /dev/null and b/counter/counter.o differ diff --git a/counter2/counter b/counter2/counter new file mode 100755 index 0000000..cbef914 Binary files /dev/null and b/counter2/counter differ diff --git a/counter2/counter.o b/counter2/counter.o new file mode 100644 index 0000000..009d497 Binary files /dev/null and b/counter2/counter.o differ diff --git a/gnu-asm/hello1/hello b/gnu-asm/hello1/hello new file mode 100755 index 0000000..51bb27a Binary files /dev/null and b/gnu-asm/hello1/hello differ diff --git a/gnu-asm/hello1/hello.o b/gnu-asm/hello1/hello.o new file mode 100644 index 0000000..761cdca Binary files /dev/null and b/gnu-asm/hello1/hello.o differ diff --git a/gnu-asm/hello1/hello.s b/gnu-asm/hello1/hello.s new file mode 100644 index 0000000..4b36a84 --- /dev/null +++ b/gnu-asm/hello1/hello.s @@ -0,0 +1,93 @@ +# hello.s +# +# Ask for the user's name, then print: +# Hello +# five times. + +.section .rodata + +prompt: + .ascii "What is your name? " +prompt_end: + +hello: + .ascii "Hello " +hello_end: + +newline: + .byte 10 # ASCII newline: '\n' + + +.section .bss + + .align 16 +name_buf: + .skip 64 # Reserve 64 bytes for the name + + +.section .text + + .global _start + +_start: + # write(STDOUT, prompt, prompt_length) + mov $1, %rax # syscall 1: write + mov $1, %rdi # file descriptor 1: stdout + lea prompt(%rip), %rsi # address of prompt + mov $(prompt_end - prompt), %rdx + syscall + + # read(STDIN, name_buf, 63) + xor %rax, %rax # syscall 0: read + xor %rdi, %rdi # file descriptor 0: stdin + lea name_buf(%rip), %rsi + mov $63, %rdx + syscall + + # RAX contains the number of bytes read. + # Exit if read returned zero or an error. + test %rax, %rax + jle exit + + # Save the length of the name in R12. + mov %rax, %r12 + + # Remove the trailing newline entered by the user. + lea name_buf(%rip), %rbx + cmpb $10, -1(%rbx,%r12) + jne repeat_setup + dec %r12 + +repeat_setup: + mov $5, %r13 # Loop counter + +repeat_loop: + # Write "Hello " + mov $1, %rax + mov $1, %rdi + lea hello(%rip), %rsi + mov $(hello_end - hello), %rdx + syscall + + # Write the user's name + mov $1, %rax + mov $1, %rdi + lea name_buf(%rip), %rsi + mov %r12, %rdx + syscall + + # Write newline + mov $1, %rax + mov $1, %rdi + lea newline(%rip), %rsi + mov $1, %rdx + syscall + + dec %r13 + jne repeat_loop + +exit: + # exit(0) + mov $60, %rax # syscall 60: exit + xor %rdi, %rdi # exit status 0 + syscall diff --git a/gnu-asm/hello1/hello.stripped b/gnu-asm/hello1/hello.stripped new file mode 100755 index 0000000..59fd318 Binary files /dev/null and b/gnu-asm/hello1/hello.stripped differ diff --git a/gnu-asm/hello1/run.sh b/gnu-asm/hello1/run.sh new file mode 100755 index 0000000..446b9a0 --- /dev/null +++ b/gnu-asm/hello1/run.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +as --64 -o hello.o hello.s +ld -o hello hello.o +cp hello hello.stripped +strip --strip-all hello.stripped +./hello.stripped +