├── asm_slides ├── bourbon │ ├── settings │ │ ├── _px-to-em.scss │ │ ├── _asset-pipeline.scss │ │ └── _prefixer.scss │ ├── css3 │ │ ├── _appearance.scss │ │ ├── _user-select.scss │ │ ├── _calc.scss │ │ ├── _backface-visibility.scss │ │ ├── _hyphens.scss │ │ ├── _filter.scss │ │ ├── _font-feature-settings.scss │ │ ├── _placeholder.scss │ │ ├── _perspective.scss │ │ ├── _image-rendering.scss │ │ ├── _hidpi-media-query.scss │ │ ├── _transform.scss │ │ ├── _font-face.scss │ │ ├── _text-decoration.scss │ │ ├── _selection.scss │ │ ├── _keyframes.scss │ │ ├── _columns.scss │ │ ├── _linear-gradient.scss │ │ ├── _background-image.scss │ │ ├── _radial-gradient.scss │ │ ├── _animation.scss │ │ ├── _background.scss │ │ └── _border-image.scss │ ├── functions │ │ ├── _is-number.scss │ │ ├── _assign-inputs.scss │ │ ├── _is-size.scss │ │ ├── _is-length.scss │ │ ├── _contains-falsy.scss │ │ ├── _px-to-rem.scss │ │ ├── _strip-units.scss │ │ ├── _px-to-em.scss │ │ ├── _tint.scss │ │ ├── _shade.scss │ │ ├── _contains.scss │ │ ├── _is-light.scss │ │ ├── _transition-property-name.scss │ │ ├── _unpack.scss │ │ └── _modular-scale.scss │ ├── helpers │ │ ├── _shape-size-stripper.scss │ │ ├── _gradient-positions-parser.scss │ │ ├── _radial-positions-parser.scss │ │ ├── _linear-angle-parser.scss │ │ ├── _convert-units.scss │ │ ├── _render-gradients.scss │ │ ├── _linear-side-corner-parser.scss │ │ ├── _font-source-declaration.scss │ │ ├── _linear-gradient-parser.scss │ │ ├── _str-to-num.scss │ │ └── _radial-gradient-parser.scss │ └── addons │ │ ├── _clearfix.scss │ │ ├── _border-width.scss │ │ ├── _margin.scss │ │ ├── _padding.scss │ │ ├── _border-style.scss │ │ ├── _font-stacks.scss │ │ ├── _word-wrap.scss │ │ ├── _border-color.scss │ │ ├── _ellipsis.scss │ │ ├── _hide-text.scss │ │ ├── _retina-image.scss │ │ ├── _border-radius.scss │ │ ├── _size.scss │ │ ├── _position.scss │ │ ├── _timing-functions.scss │ │ ├── _prefixer.scss │ │ └── _buttons.scss ├── images │ ├── sse04.jpg │ ├── simd_ex.bmp │ ├── eflags-intel2.jpg │ ├── fpu_data_regs.jpg │ ├── fpu_equation.png │ ├── fpu_outline.jpg │ ├── page_tables2.png │ ├── fpu_biased_table.jpg │ ├── section_1_pointers.jpg │ ├── section_2_counter.jpeg │ ├── section_5_mem_map.png │ ├── section_5_syscall.png │ ├── section_2_bitops_and.jpg │ ├── section_2_bitops_or.jpg │ ├── section_2_bitops_or.png │ ├── section_2_bitops_xor.jpg │ ├── section_2_div_table.jpg │ ├── section_2_mul_table.jpg │ ├── section_2_bitops_shl_1.jpg │ ├── section_2_bitops_shr_1.jpg │ ├── section_3_call_ret_pt1.jpg │ ├── section_3_call_ret_pt2.jpg │ ├── section_1_register_table.jpg │ ├── section_2_stack_diagram_1.jpg │ ├── section_2_stack_diagram_2.jpg │ ├── section_2_stack_diagram_3.jpg │ ├── section_2_twos_complement_p1.jpg │ ├── section_1_pointers_third_stage.jpg │ └── section_1_pointers_second_stage.jpg ├── .sass-cache │ ├── 38704e119825eab06d67932e741a26f980643aee │ │ ├── _size.scssc │ │ ├── _margin.scssc │ │ ├── _buttons.scssc │ │ ├── _clearfix.scssc │ │ ├── _ellipsis.scssc │ │ ├── _hide-text.scssc │ │ ├── _padding.scssc │ │ ├── _position.scssc │ │ ├── _prefixer.scssc │ │ ├── _triangle.scssc │ │ ├── _word-wrap.scssc │ │ ├── _font-stacks.scssc │ │ ├── _text-inputs.scssc │ │ ├── _border-color.scssc │ │ ├── _border-radius.scssc │ │ ├── _border-style.scssc │ │ ├── _border-width.scssc │ │ ├── _retina-image.scssc │ │ └── _timing-functions.scssc │ ├── acfcadf8c05b58b01051d736f0395f77eef376f8 │ │ └── asm.scssc │ ├── b544c2945eb6124aef22e96121e18cd7e42f1f16 │ │ ├── _tint.scssc │ │ ├── _shade.scssc │ │ ├── _unpack.scssc │ │ ├── _contains.scssc │ │ ├── _is-length.scssc │ │ ├── _is-light.scssc │ │ ├── _is-number.scssc │ │ ├── _is-size.scssc │ │ ├── _px-to-em.scssc │ │ ├── _strip-units.scssc │ │ ├── _assign-inputs.scssc │ │ ├── _contains-falsy.scssc │ │ ├── _modular-scale.scssc │ │ └── _transition-property-name.scssc │ ├── 2a8f65206aa6ecb0bc1c1ba1bcb99e5ee2d1cc96 │ │ ├── _filter.scssc │ │ ├── _animation.scssc │ │ ├── _columns.scssc │ │ ├── _flex-box.scssc │ │ ├── _font-face.scssc │ │ ├── _hyphens.scssc │ │ ├── _keyframes.scssc │ │ ├── _selection.scssc │ │ ├── _transform.scssc │ │ ├── _background.scssc │ │ ├── _perspective.scssc │ │ ├── _placeholder.scssc │ │ ├── _transition.scssc │ │ ├── _border-image.scssc │ │ ├── _background-image.scssc │ │ ├── _image-rendering.scssc │ │ ├── _linear-gradient.scssc │ │ ├── _radial-gradient.scssc │ │ ├── _hidpi-media-query.scssc │ │ ├── _font-feature-settings.scssc │ │ ├── _backface-visibility.scssc │ │ ├── _appearance.scssc │ │ └── _user-select.scssc │ ├── 05454418d5045e2814f4edb016bae0724c83a33a │ │ ├── _bourbon.scssc │ │ └── _bourbon-deprecated-upcoming.scssc │ ├── 8af52963e8cebe332142b9f9bb53a1a78320ebfb │ │ ├── _str-to-num.scssc │ │ ├── _convert-units.scssc │ │ ├── _render-gradients.scssc │ │ ├── _directional-values.scssc │ │ ├── _linear-angle-parser.scssc │ │ ├── _radial-arg-parser.scssc │ │ ├── _font-source-declaration.scssc │ │ ├── _linear-gradient-parser.scssc │ │ ├── _linear-positions-parser.scssc │ │ ├── _radial-gradient-parser.scssc │ │ ├── _radial-positions-parser.scssc │ │ ├── _gradient-positions-parser.scssc │ │ └── _linear-side-corner-parser.scssc │ └── 3a8503476eb5763ba1a284dc68e3bbb7f36fb2a3 │ │ ├── _asset-pipeline.scssc │ │ └── _px-to-em.scssc ├── stylesheets └── asm.scss ├── demos ├── syscall_demos │ ├── mmap_demo │ │ └── example.txt │ ├── write_exit │ │ └── src │ │ │ ├── build.sh │ │ │ ├── main.c │ │ │ └── write.nasm │ ├── threads_demo │ │ └── src │ │ │ ├── build.sh │ │ │ ├── threads.nasm │ │ │ └── main.c │ └── dup2_demo │ │ └── main.c ├── debug_demo │ ├── pure_c │ │ ├── src │ │ │ ├── build.sh │ │ │ └── main.c │ │ └── debug_me_c │ └── with_asm │ │ ├── run_me │ │ └── src │ │ ├── build.sh │ │ ├── run.nasm │ │ └── main.c ├── struc_locals │ ├── build.sh │ ├── main.c │ └── run.nasm ├── memory_demo │ ├── lea_demo │ │ ├── run_demo │ │ └── src │ │ │ ├── build.sh │ │ │ ├── leadm.nasm │ │ │ └── main.c │ └── mov_demo │ │ ├── run_me │ │ └── src │ │ ├── build.sh │ │ ├── movin.nasm │ │ └── main.c ├── CmdLine │ └── crt.nasm ├── opcodes_demo │ └── main.c ├── redirection_demos │ └── fork_output.c └── Dirent │ └── main.c ├── tex ├── .DS_Store ├── introduction │ ├── .DS_Store │ ├── section_2_bitops_or.tex │ ├── section_2_bitops_and.tex │ ├── section_1_pointers.tex │ ├── section_2_bitops_shl_1.tex │ ├── section_2_bitops_shr_1.tex │ ├── fpu_data_regs.tex │ ├── section_1_pointers_third_stage.tex │ ├── section_1_pointers_second_stage.tex │ ├── section_2_bitops_xor.tex │ ├── section_1_register_table.tex │ ├── section_2_twos_complement_p1.tex │ ├── section_2_mul_table.tex │ ├── fpu_biased_table.tex │ ├── section_2_div_table.tex │ ├── section_2_stack.tex │ ├── section_3_call_ret_pt1.tex │ ├── section_5_syscall.tex │ ├── section_2_stack_diag_2.tex │ ├── section_2_stack_diag_3.tex │ ├── section_3_call_ret_pt2.tex │ ├── fpu_outline.tex │ └── section_3_eflags_layout.tex └── fpu_equation.tex ├── handouts ├── GDB Cheat Sheet.pdf ├── Assembly Cheat Sheet.pdf ├── sample-gdbinit └── lab_instructions.txt ├── labs ├── Lab6 │ ├── help.nasm │ ├── CMakeLists.txt │ ├── main.cpp │ └── Lab6.nasm ├── CRT │ ├── main.c │ ├── CMakeLists.txt │ ├── crt.nasm │ └── more_defs.inc ├── WinFunctions │ ├── WinAsmWeek2 │ │ ├── .vs │ │ │ └── WinAsm │ │ │ │ └── v14 │ │ │ │ └── .suo │ │ ├── Setup.txt │ │ ├── Monday │ │ │ └── Monday.vcxproj.filters │ │ ├── Thursday │ │ │ ├── Thursday.vcxproj.filters │ │ │ └── thursday.nasm │ │ ├── Tuesday │ │ │ ├── Tuesday.vcxproj.filters │ │ │ └── tuesday.nasm │ │ └── Wednesday │ │ │ ├── Wednesday.vcxproj.filters │ │ │ └── wednesday.nasm │ └── ASM │ │ ├── WinLab1 │ │ ├── WinLab1.nasm │ │ ├── WinLab1.vcxproj.filters │ │ └── main.cpp │ │ └── ASM │ │ ├── ASM.vcxproj.filters │ │ └── WinLab.nasm ├── Lab1 │ ├── CMakeLists.txt │ └── main.cpp ├── Lab2 │ ├── CMakeLists.txt │ ├── Lab2.nasm │ └── main.cpp ├── Lab3 │ ├── CMakeLists.txt │ ├── main.cpp │ └── Lab3.nasm ├── Lab4 │ ├── CMakeLists.txt │ ├── main.cpp │ └── Lab4.nasm ├── Lab5 │ └── CMakeLists.txt ├── Lab7 │ ├── CMakeLists.txt │ ├── main.cpp │ └── Lab7.nasm ├── Lab8 │ ├── CMakeLists.txt │ ├── main.cpp │ └── Lab8.nasm ├── Lab9 │ ├── CMakeLists.txt │ ├── main.cpp │ └── Lab9.nasm ├── Lab10 │ ├── CMakeLists.txt │ ├── Lab10.nasm │ └── main.cpp ├── Lab11 │ ├── CMakeLists.txt │ ├── main.cpp │ └── Lab11.nasm ├── Lab12 │ ├── CMakeLists.txt │ ├── Lab12.nasm │ └── main.cpp ├── Lab13 │ ├── CMakeLists.txt │ ├── quicksort.c │ └── insertion_sort.c └── Solutions │ ├── Lab11_s2.nasm │ ├── Lab11.nasm │ ├── WinLabsWeek2_Solutions │ ├── tuesday.nasm │ ├── thursday.nasm │ └── wednesday.nasm │ └── Lab12.nasm ├── compiled_slides ├── section_one_intro.zip ├── ex_section_fp_simd.zip ├── section_five_syscalls.zip ├── section_four_hardware.zip ├── section_two_basic_ops.zip ├── section_six_syscalls_pt2.zip └── section_three_control_flow.zip └── Review Questions ├── Review Questions - Day 1.docx ├── Review Questions - Day 2.docx └── Review Questions - Day 3.docx /asm_slides/bourbon/settings/_px-to-em.scss: -------------------------------------------------------------------------------- 1 | $em-base: 16px !default; 2 | -------------------------------------------------------------------------------- /demos/syscall_demos/mmap_demo/example.txt: -------------------------------------------------------------------------------- 1 | Lorem ipsum test file etc 2 | -------------------------------------------------------------------------------- /tex/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambray/ASM-Course/HEAD/tex/.DS_Store -------------------------------------------------------------------------------- /demos/debug_demo/pure_c/src/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | gcc -g main.c -o run_me_c 4 | -------------------------------------------------------------------------------- /asm_slides/images/sse04.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambray/ASM-Course/HEAD/asm_slides/images/sse04.jpg -------------------------------------------------------------------------------- /tex/introduction/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambray/ASM-Course/HEAD/tex/introduction/.DS_Store -------------------------------------------------------------------------------- /asm_slides/images/simd_ex.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambray/ASM-Course/HEAD/asm_slides/images/simd_ex.bmp -------------------------------------------------------------------------------- /demos/struc_locals/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | nasm -g -f elf64 run.nasm 4 | gcc main.c run.o -g -o run_me 5 | -------------------------------------------------------------------------------- /handouts/GDB Cheat Sheet.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambray/ASM-Course/HEAD/handouts/GDB Cheat Sheet.pdf -------------------------------------------------------------------------------- /demos/debug_demo/with_asm/run_me: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambray/ASM-Course/HEAD/demos/debug_demo/with_asm/run_me -------------------------------------------------------------------------------- /asm_slides/images/eflags-intel2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambray/ASM-Course/HEAD/asm_slides/images/eflags-intel2.jpg -------------------------------------------------------------------------------- /asm_slides/images/fpu_data_regs.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambray/ASM-Course/HEAD/asm_slides/images/fpu_data_regs.jpg -------------------------------------------------------------------------------- /asm_slides/images/fpu_equation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambray/ASM-Course/HEAD/asm_slides/images/fpu_equation.png -------------------------------------------------------------------------------- /asm_slides/images/fpu_outline.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambray/ASM-Course/HEAD/asm_slides/images/fpu_outline.jpg -------------------------------------------------------------------------------- /asm_slides/images/page_tables2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambray/ASM-Course/HEAD/asm_slides/images/page_tables2.png -------------------------------------------------------------------------------- /demos/debug_demo/pure_c/debug_me_c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambray/ASM-Course/HEAD/demos/debug_demo/pure_c/debug_me_c -------------------------------------------------------------------------------- /demos/debug_demo/with_asm/src/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | nasm -g -f elf64 run.nasm 4 | gcc main.c run.o -g -o run_me 5 | -------------------------------------------------------------------------------- /demos/memory_demo/lea_demo/run_demo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambray/ASM-Course/HEAD/demos/memory_demo/lea_demo/run_demo -------------------------------------------------------------------------------- /demos/memory_demo/mov_demo/run_me: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambray/ASM-Course/HEAD/demos/memory_demo/mov_demo/run_me -------------------------------------------------------------------------------- /handouts/Assembly Cheat Sheet.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambray/ASM-Course/HEAD/handouts/Assembly Cheat Sheet.pdf -------------------------------------------------------------------------------- /labs/Lab6/help.nasm: -------------------------------------------------------------------------------- 1 | bits 64 2 | 3 | global get_flags 4 | 5 | get_flags: 6 | pushfq 7 | pop rax 8 | ret 9 | -------------------------------------------------------------------------------- /compiled_slides/section_one_intro.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambray/ASM-Course/HEAD/compiled_slides/section_one_intro.zip -------------------------------------------------------------------------------- /demos/memory_demo/mov_demo/src/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | nasm -f elf64 -g movin.nasm 4 | gcc -g main.c movin.o -o run_me 5 | -------------------------------------------------------------------------------- /labs/CRT/main.c: -------------------------------------------------------------------------------- 1 | 2 | #define BREAKPOINT asm("int3") 3 | 4 | int main() 5 | { 6 | 7 | return 0; 8 | } 9 | 10 | -------------------------------------------------------------------------------- /asm_slides/images/fpu_biased_table.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambray/ASM-Course/HEAD/asm_slides/images/fpu_biased_table.jpg -------------------------------------------------------------------------------- /asm_slides/images/section_1_pointers.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambray/ASM-Course/HEAD/asm_slides/images/section_1_pointers.jpg -------------------------------------------------------------------------------- /asm_slides/images/section_2_counter.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambray/ASM-Course/HEAD/asm_slides/images/section_2_counter.jpeg -------------------------------------------------------------------------------- /asm_slides/images/section_5_mem_map.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambray/ASM-Course/HEAD/asm_slides/images/section_5_mem_map.png -------------------------------------------------------------------------------- /asm_slides/images/section_5_syscall.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambray/ASM-Course/HEAD/asm_slides/images/section_5_syscall.png -------------------------------------------------------------------------------- /compiled_slides/ex_section_fp_simd.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambray/ASM-Course/HEAD/compiled_slides/ex_section_fp_simd.zip -------------------------------------------------------------------------------- /demos/memory_demo/lea_demo/src/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | nasm -f elf64 -g leadm.nasm 4 | gcc -g main.c leadm.o -o run_demo 5 | -------------------------------------------------------------------------------- /asm_slides/images/section_2_bitops_and.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambray/ASM-Course/HEAD/asm_slides/images/section_2_bitops_and.jpg -------------------------------------------------------------------------------- /asm_slides/images/section_2_bitops_or.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambray/ASM-Course/HEAD/asm_slides/images/section_2_bitops_or.jpg -------------------------------------------------------------------------------- /asm_slides/images/section_2_bitops_or.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambray/ASM-Course/HEAD/asm_slides/images/section_2_bitops_or.png -------------------------------------------------------------------------------- /asm_slides/images/section_2_bitops_xor.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambray/ASM-Course/HEAD/asm_slides/images/section_2_bitops_xor.jpg -------------------------------------------------------------------------------- /asm_slides/images/section_2_div_table.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambray/ASM-Course/HEAD/asm_slides/images/section_2_div_table.jpg -------------------------------------------------------------------------------- /asm_slides/images/section_2_mul_table.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambray/ASM-Course/HEAD/asm_slides/images/section_2_mul_table.jpg -------------------------------------------------------------------------------- /compiled_slides/section_five_syscalls.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambray/ASM-Course/HEAD/compiled_slides/section_five_syscalls.zip -------------------------------------------------------------------------------- /compiled_slides/section_four_hardware.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambray/ASM-Course/HEAD/compiled_slides/section_four_hardware.zip -------------------------------------------------------------------------------- /compiled_slides/section_two_basic_ops.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambray/ASM-Course/HEAD/compiled_slides/section_two_basic_ops.zip -------------------------------------------------------------------------------- /demos/syscall_demos/write_exit/src/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | nasm -f elf64 -g write.nasm 4 | gcc -g main.c write.o -o write_stuff 5 | -------------------------------------------------------------------------------- /asm_slides/images/section_2_bitops_shl_1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambray/ASM-Course/HEAD/asm_slides/images/section_2_bitops_shl_1.jpg -------------------------------------------------------------------------------- /asm_slides/images/section_2_bitops_shr_1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambray/ASM-Course/HEAD/asm_slides/images/section_2_bitops_shr_1.jpg -------------------------------------------------------------------------------- /asm_slides/images/section_3_call_ret_pt1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambray/ASM-Course/HEAD/asm_slides/images/section_3_call_ret_pt1.jpg -------------------------------------------------------------------------------- /asm_slides/images/section_3_call_ret_pt2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambray/ASM-Course/HEAD/asm_slides/images/section_3_call_ret_pt2.jpg -------------------------------------------------------------------------------- /compiled_slides/section_six_syscalls_pt2.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambray/ASM-Course/HEAD/compiled_slides/section_six_syscalls_pt2.zip -------------------------------------------------------------------------------- /Review Questions/Review Questions - Day 1.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambray/ASM-Course/HEAD/Review Questions/Review Questions - Day 1.docx -------------------------------------------------------------------------------- /Review Questions/Review Questions - Day 2.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambray/ASM-Course/HEAD/Review Questions/Review Questions - Day 2.docx -------------------------------------------------------------------------------- /Review Questions/Review Questions - Day 3.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambray/ASM-Course/HEAD/Review Questions/Review Questions - Day 3.docx -------------------------------------------------------------------------------- /asm_slides/bourbon/css3/_appearance.scss: -------------------------------------------------------------------------------- 1 | @mixin appearance($value) { 2 | @include prefixer(appearance, $value, webkit moz ms o spec); 3 | } 4 | -------------------------------------------------------------------------------- /asm_slides/images/section_1_register_table.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambray/ASM-Course/HEAD/asm_slides/images/section_1_register_table.jpg -------------------------------------------------------------------------------- /asm_slides/images/section_2_stack_diagram_1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambray/ASM-Course/HEAD/asm_slides/images/section_2_stack_diagram_1.jpg -------------------------------------------------------------------------------- /asm_slides/images/section_2_stack_diagram_2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambray/ASM-Course/HEAD/asm_slides/images/section_2_stack_diagram_2.jpg -------------------------------------------------------------------------------- /asm_slides/images/section_2_stack_diagram_3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambray/ASM-Course/HEAD/asm_slides/images/section_2_stack_diagram_3.jpg -------------------------------------------------------------------------------- /compiled_slides/section_three_control_flow.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambray/ASM-Course/HEAD/compiled_slides/section_three_control_flow.zip -------------------------------------------------------------------------------- /demos/memory_demo/lea_demo/src/leadm.nasm: -------------------------------------------------------------------------------- 1 | bits 64 2 | 3 | global calc_address 4 | 5 | calc_address: 6 | lea rax, [rdi+0x10] 7 | ret 8 | -------------------------------------------------------------------------------- /demos/syscall_demos/threads_demo/src/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | nasm -f elf64 -g threads.nasm 4 | gcc -g main.c threads.o -o threads_demo 5 | -------------------------------------------------------------------------------- /asm_slides/bourbon/css3/_user-select.scss: -------------------------------------------------------------------------------- 1 | @mixin user-select($value: none) { 2 | @include prefixer(user-select, $value, webkit moz ms spec); 3 | } 4 | -------------------------------------------------------------------------------- /asm_slides/images/section_2_twos_complement_p1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambray/ASM-Course/HEAD/asm_slides/images/section_2_twos_complement_p1.jpg -------------------------------------------------------------------------------- /labs/WinFunctions/WinAsmWeek2/.vs/WinAsm/v14/.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambray/ASM-Course/HEAD/labs/WinFunctions/WinAsmWeek2/.vs/WinAsm/v14/.suo -------------------------------------------------------------------------------- /asm_slides/images/section_1_pointers_third_stage.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambray/ASM-Course/HEAD/asm_slides/images/section_1_pointers_third_stage.jpg -------------------------------------------------------------------------------- /asm_slides/bourbon/css3/_calc.scss: -------------------------------------------------------------------------------- 1 | @mixin calc($property, $value) { 2 | #{$property}: -webkit-calc(#{$value}); 3 | #{$property}: calc(#{$value}); 4 | } 5 | -------------------------------------------------------------------------------- /asm_slides/images/section_1_pointers_second_stage.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambray/ASM-Course/HEAD/asm_slides/images/section_1_pointers_second_stage.jpg -------------------------------------------------------------------------------- /asm_slides/bourbon/css3/_backface-visibility.scss: -------------------------------------------------------------------------------- 1 | @mixin backface-visibility($visibility) { 2 | @include prefixer(backface-visibility, $visibility, webkit spec); 3 | } 4 | -------------------------------------------------------------------------------- /handouts/sample-gdbinit: -------------------------------------------------------------------------------- 1 | set disassembly-flavor intel 2 | set step-mode on 3 | tui enable 4 | layout asm 5 | layout regs 6 | winheight asm +3 7 | winheight regs -2 8 | refresh 9 | -------------------------------------------------------------------------------- /asm_slides/bourbon/css3/_hyphens.scss: -------------------------------------------------------------------------------- 1 | @mixin hyphens($hyphenation: none) { 2 | // none | manual | auto 3 | @include prefixer(hyphens, $hyphenation, webkit moz ms spec); 4 | } 5 | -------------------------------------------------------------------------------- /asm_slides/bourbon/css3/_filter.scss: -------------------------------------------------------------------------------- 1 | @mixin filter($function: none) { 2 | // [ 3 | @include prefixer(perspective, $depth, webkit moz spec); 4 | } 5 | 6 | @mixin perspective-origin($value: 50% 50%) { 7 | @include prefixer(perspective-origin, $value, webkit moz spec); 8 | } 9 | -------------------------------------------------------------------------------- /demos/debug_demo/with_asm/src/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | extern int run_me(char*); 5 | 6 | 7 | int main(int argc, char** argv, char** envp) 8 | { 9 | int tmp = run_me(envp[0]); 10 | 11 | printf("Length is: %d, vs %d\n", tmp, strlen(envp[0])); 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /asm_slides/bourbon/functions/_is-number.scss: -------------------------------------------------------------------------------- 1 | @charset "UTF-8"; 2 | 3 | /// Checks for a valid number. 4 | /// 5 | /// @param {Number} $value 6 | /// 7 | /// @require {function} contains 8 | 9 | @function is-number($value) { 10 | @return contains("0" "1" "2" "3" "4" "5" "6" "7" "8" "9" 0 1 2 3 4 5 6 7 8 9, $value); 11 | } 12 | -------------------------------------------------------------------------------- /asm_slides/bourbon/functions/_assign-inputs.scss: -------------------------------------------------------------------------------- 1 | @function assign-inputs($inputs, $pseudo: null) { 2 | $list: (); 3 | 4 | @each $input in $inputs { 5 | $input: unquote($input); 6 | $input: if($pseudo, $input + ":" + $pseudo, $input); 7 | $list: append($list, $input, comma); 8 | } 9 | 10 | @return $list; 11 | } 12 | -------------------------------------------------------------------------------- /demos/memory_demo/mov_demo/src/movin.nasm: -------------------------------------------------------------------------------- 1 | bits 64 2 | 3 | global movin 4 | 5 | movin: 6 | push rbp 7 | mov rbp, rsp 8 | mov rax, [rdi] ; copy the value to rax 9 | mov rcx, [rsi] ; get the value into rcx 10 | mov [rdi], rcx ; now we swap 11 | mov [rsi], rax ; again 12 | pop rbp 13 | ret 14 | 15 | -------------------------------------------------------------------------------- /asm_slides/bourbon/settings/_prefixer.scss: -------------------------------------------------------------------------------- 1 | @charset "UTF-8"; 2 | 3 | /// Global variables to enable or disable vendor prefixes 4 | 5 | $prefix-for-webkit: true !default; 6 | $prefix-for-mozilla: true !default; 7 | $prefix-for-microsoft: true !default; 8 | $prefix-for-opera: true !default; 9 | $prefix-for-spec: true !default; 10 | -------------------------------------------------------------------------------- /demos/memory_demo/mov_demo/src/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern int movin(int* a, int* b); 4 | 5 | int main(int argc, char** argv, char** envp) 6 | { 7 | int t1 = 10; 8 | int t2 = 20; 9 | printf("Before: %d, %d\n", t1, t2); 10 | int val = movin(&t1, &t2); 11 | printf("Result: %d, %d\n", t1, t2); 12 | 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /asm_slides/bourbon/helpers/_shape-size-stripper.scss: -------------------------------------------------------------------------------- 1 | @function _shape-size-stripper($shape-size) { 2 | $shape-size-spec: null; 3 | @each $value in $shape-size { 4 | @if ($value == "cover") or ($value == "contain") { 5 | $value: null; 6 | } 7 | $shape-size-spec: "#{$shape-size-spec} #{$value}"; 8 | } 9 | @return $shape-size-spec; 10 | } 11 | -------------------------------------------------------------------------------- /labs/CRT/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.2) 2 | project(CRT C CXX ASM) 3 | 4 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -nostdlib -g") 5 | set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -g") 6 | 7 | enable_language(ASM_NASM) 8 | file(GLOB LAB_ASM_FILES "*.nasm") 9 | file(GLOB LAB_CPP_FILES "*.c") 10 | 11 | add_executable(crtproj ${LAB_ASM_FILES} ${LAB_CPP_FILES}) 12 | -------------------------------------------------------------------------------- /asm_slides/bourbon/functions/_is-size.scss: -------------------------------------------------------------------------------- 1 | @charset "UTF-8"; 2 | 3 | /// Checks for a valid CSS size. 4 | /// 5 | /// @param {String} $value 6 | /// 7 | /// @require {function} contains 8 | /// @require {function} is-length 9 | 10 | @function is-size($value) { 11 | @return is-length($value) 12 | or contains("fill" "fit-content" "min-content" "max-content", $value); 13 | } 14 | -------------------------------------------------------------------------------- /demos/struc_locals/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | extern int run_me(int, char*, int); 6 | 7 | void my_function(void) 8 | { 9 | 10 | printf("Made it here!\n"); 11 | } 12 | 13 | int main(int argc, char** argv, char** envp) 14 | { 15 | int tmp = run_me(10, envp[0], 20); 16 | 17 | printf("tmp: %d\n", tmp); 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /demos/syscall_demos/write_exit/src/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern void write_stuff(char*); 4 | extern void exit_prog(int); 5 | 6 | int main(int argc, char** argv, char** envp) 7 | { 8 | write_stuff("We get to this point.\n"); 9 | write_stuff("And to this point.\n"); 10 | exit_prog(-1); 11 | write_stuff("But not to here!\n"); 12 | 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /asm_slides/bourbon/functions/_is-length.scss: -------------------------------------------------------------------------------- 1 | @charset "UTF-8"; 2 | 3 | /// Checks for a valid CSS length. 4 | /// 5 | /// @param {String} $value 6 | 7 | @function is-length($value) { 8 | @return type-of($value) != "null" and (str-slice($value + "", 1, 4) == "calc" 9 | or index(auto inherit initial 0, $value) 10 | or (type-of($value) == "number" and not(unitless($value)))); 11 | } 12 | -------------------------------------------------------------------------------- /labs/Lab1/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.2) 2 | project(Lab1 C CXX ASM) 3 | enable_language(ASM_NASM) 4 | 5 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g") 6 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g") 7 | set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -g") 8 | 9 | file(GLOB LAB_ASM_FILES "*.nasm") 10 | file(GLOB LAB_CPP_FILES "*.cpp") 11 | 12 | add_executable(lab1 ${LAB_ASM_FILES} ${LAB_CPP_FILES}) 13 | -------------------------------------------------------------------------------- /labs/Lab2/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.2) 2 | project(Lab2 C CXX ASM) 3 | 4 | enable_language(ASM_NASM) 5 | 6 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g") 7 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g") 8 | set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -g") 9 | 10 | file(GLOB LAB_ASM_FILES "*.nasm") 11 | file(GLOB LAB_CPP_FILES "*.cpp") 12 | 13 | add_executable(lab2 ${LAB_ASM_FILES} ${LAB_CPP_FILES}) 14 | -------------------------------------------------------------------------------- /labs/Lab3/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.2) 2 | project(Lab3 C CXX ASM) 3 | 4 | enable_language(ASM_NASM) 5 | 6 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g") 7 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g") 8 | set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -g") 9 | 10 | file(GLOB LAB_ASM_FILES "*.nasm") 11 | file(GLOB LAB_CPP_FILES "*.cpp") 12 | 13 | add_executable(lab3 ${LAB_ASM_FILES} ${LAB_CPP_FILES}) 14 | -------------------------------------------------------------------------------- /labs/Lab4/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.2) 2 | project(Lab4 C CXX ASM) 3 | 4 | enable_language(ASM_NASM) 5 | 6 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g") 7 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g") 8 | set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -g") 9 | 10 | file(GLOB LAB_ASM_FILES "*.nasm") 11 | file(GLOB LAB_CPP_FILES "*.cpp") 12 | 13 | add_executable(lab4 ${LAB_ASM_FILES} ${LAB_CPP_FILES}) 14 | -------------------------------------------------------------------------------- /labs/Lab5/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.2) 2 | project(Lab5 C CXX ASM) 3 | 4 | enable_language(ASM_NASM) 5 | 6 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g") 7 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g") 8 | set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -g") 9 | 10 | file(GLOB LAB_ASM_FILES "*.nasm") 11 | file(GLOB LAB_CPP_FILES "*.cpp") 12 | 13 | add_executable(lab5 ${LAB_ASM_FILES} ${LAB_CPP_FILES}) 14 | -------------------------------------------------------------------------------- /labs/Lab6/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.2) 2 | project(Lab6 C CXX ASM) 3 | 4 | enable_language(ASM_NASM) 5 | 6 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g") 7 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g") 8 | set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -g") 9 | 10 | file(GLOB LAB_ASM_FILES "*.nasm") 11 | file(GLOB LAB_CPP_FILES "*.cpp") 12 | 13 | add_executable(lab6 ${LAB_ASM_FILES} ${LAB_CPP_FILES}) 14 | -------------------------------------------------------------------------------- /labs/Lab7/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.2) 2 | project(Lab7 C CXX ASM) 3 | 4 | enable_language(ASM_NASM) 5 | 6 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g") 7 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g") 8 | set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -g") 9 | 10 | file(GLOB LAB_ASM_FILES "*.nasm") 11 | file(GLOB LAB_CPP_FILES "*.cpp") 12 | 13 | add_executable(lab7 ${LAB_ASM_FILES} ${LAB_CPP_FILES}) 14 | -------------------------------------------------------------------------------- /labs/Lab8/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.2) 2 | project(Lab8 C CXX ASM) 3 | 4 | enable_language(ASM_NASM) 5 | 6 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g") 7 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g") 8 | set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -g") 9 | 10 | file(GLOB LAB_ASM_FILES "*.nasm") 11 | file(GLOB LAB_CPP_FILES "*.cpp") 12 | 13 | add_executable(lab8 ${LAB_ASM_FILES} ${LAB_CPP_FILES}) 14 | -------------------------------------------------------------------------------- /labs/Lab9/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.2) 2 | project(Lab9 C CXX ASM) 3 | 4 | enable_language(ASM_NASM) 5 | 6 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g") 7 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g") 8 | set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -g") 9 | 10 | file(GLOB LAB_ASM_FILES "*.nasm") 11 | file(GLOB LAB_CPP_FILES "*.cpp") 12 | 13 | add_executable(lab9 ${LAB_ASM_FILES} ${LAB_CPP_FILES}) 14 | -------------------------------------------------------------------------------- /labs/Lab10/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.2) 2 | project(Lab10 C CXX ASM) 3 | 4 | enable_language(ASM_NASM) 5 | 6 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g") 7 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g") 8 | set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -g") 9 | 10 | file(GLOB LAB_ASM_FILES "*.nasm") 11 | file(GLOB LAB_CPP_FILES "*.cpp") 12 | 13 | add_executable(lab10 ${LAB_ASM_FILES} ${LAB_CPP_FILES}) 14 | -------------------------------------------------------------------------------- /labs/Lab11/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.2) 2 | project(Lab11 C CXX ASM) 3 | 4 | enable_language(ASM_NASM) 5 | 6 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g") 7 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g") 8 | set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -g") 9 | 10 | file(GLOB LAB_ASM_FILES "*.nasm") 11 | file(GLOB LAB_CPP_FILES "*.cpp") 12 | 13 | add_executable(lab11 ${LAB_ASM_FILES} ${LAB_CPP_FILES}) 14 | -------------------------------------------------------------------------------- /labs/Lab12/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.2) 2 | project(Lab12 C CXX ASM) 3 | 4 | enable_language(ASM_NASM) 5 | 6 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g") 7 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g") 8 | set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -g") 9 | 10 | file(GLOB LAB_ASM_FILES "*.nasm") 11 | file(GLOB LAB_CPP_FILES "*.cpp") 12 | 13 | add_executable(lab12 ${LAB_ASM_FILES} ${LAB_CPP_FILES}) 14 | -------------------------------------------------------------------------------- /labs/Lab13/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.2) 2 | project(Lab13 C CXX ASM) 3 | 4 | enable_language(ASM_NASM) 5 | 6 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g") 7 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g") 8 | set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -g") 9 | 10 | file(GLOB LAB_ASM_FILES "*.nasm") 11 | file(GLOB LAB_CPP_FILES "*.cpp") 12 | 13 | add_executable(lab13 ${LAB_ASM_FILES} ${LAB_CPP_FILES}) 14 | -------------------------------------------------------------------------------- /asm_slides/bourbon/css3/_image-rendering.scss: -------------------------------------------------------------------------------- 1 | @mixin image-rendering ($mode:auto) { 2 | 3 | @if ($mode == crisp-edges) { 4 | -ms-interpolation-mode: nearest-neighbor; // IE8+ 5 | image-rendering: -moz-crisp-edges; 6 | image-rendering: -o-crisp-edges; 7 | image-rendering: -webkit-optimize-contrast; 8 | image-rendering: crisp-edges; 9 | } 10 | 11 | @else { 12 | image-rendering: $mode; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /asm_slides/bourbon/functions/_contains-falsy.scss: -------------------------------------------------------------------------------- 1 | @charset "UTF-8"; 2 | 3 | /// Checks if a list does not contains a value. 4 | /// 5 | /// @access private 6 | /// 7 | /// @param {List} $list 8 | /// The list to check against. 9 | /// 10 | /// @return {Bool} 11 | 12 | @function contains-falsy($list) { 13 | @each $item in $list { 14 | @if not $item { 15 | @return true; 16 | } 17 | } 18 | 19 | @return false; 20 | } 21 | -------------------------------------------------------------------------------- /asm_slides/bourbon/functions/_px-to-rem.scss: -------------------------------------------------------------------------------- 1 | // Convert pixels to rems 2 | // eg. for a relational value of 12px write rem(12) 3 | // Assumes $em-base is the font-size of 4 | 5 | @function rem($pxval) { 6 | @if not unitless($pxval) { 7 | $pxval: strip-units($pxval); 8 | } 9 | 10 | $base: $em-base; 11 | @if not unitless($base) { 12 | $base: strip-units($base); 13 | } 14 | @return ($pxval / $base) * 1rem; 15 | } 16 | -------------------------------------------------------------------------------- /labs/CRT/crt.nasm: -------------------------------------------------------------------------------- 1 | bits 64 2 | 3 | %include "defs.inc" 4 | %include "more_defs.inc" 5 | 6 | 7 | global _start ; Expose _start for linking 8 | extern main ; Implemented in main.c 9 | 10 | 11 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 12 | ;; Entry Point ;; 13 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 14 | _start: 15 | mov rcx, [rsp] 16 | mov rsi, [rsp + 8] 17 | mov rdi, [rsp + 16] 18 | mov r8, [rsp + 24] 19 | int3 20 | ret 21 | -------------------------------------------------------------------------------- /asm_slides/bourbon/functions/_strip-units.scss: -------------------------------------------------------------------------------- 1 | @charset "UTF-8"; 2 | 3 | /// Strips the unit from a number. 4 | /// 5 | /// @param {Number (With Unit)} $value 6 | /// 7 | /// @example scss - Usage 8 | /// $dimension: strip-units(10em); 9 | /// 10 | /// @example css - CSS Output 11 | /// $dimension: 10; 12 | /// 13 | /// @return {Number (Unitless)} 14 | 15 | @function strip-units($value) { 16 | @return ($value / ($value * 0 + 1)); 17 | } 18 | -------------------------------------------------------------------------------- /demos/CmdLine/crt.nasm: -------------------------------------------------------------------------------- 1 | bits 64 2 | 3 | %include "defs.inc" 4 | %include "more_defs.inc" 5 | 6 | 7 | global _start ; Expose _start for linking 8 | extern main ; Implemented in main.c 9 | 10 | 11 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 12 | ;; Entry Point ;; 13 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 14 | _start: 15 | mov rcx, [rsp] 16 | mov rsi, [rsp + 8] 17 | mov rdi, [rsp + 16] 18 | mov r8, [rsp + 24] 19 | int3 20 | ret 21 | -------------------------------------------------------------------------------- /asm_slides/bourbon/functions/_px-to-em.scss: -------------------------------------------------------------------------------- 1 | // Convert pixels to ems 2 | // eg. for a relational value of 12px write em(12) when the parent is 16px 3 | // if the parent is another value say 24px write em(12, 24) 4 | 5 | @function em($pxval, $base: $em-base) { 6 | @if not unitless($pxval) { 7 | $pxval: strip-units($pxval); 8 | } 9 | @if not unitless($base) { 10 | $base: strip-units($base); 11 | } 12 | @return ($pxval / $base) * 1em; 13 | } 14 | -------------------------------------------------------------------------------- /demos/memory_demo/lea_demo/src/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | struct example { 5 | unsigned long d1; 6 | unsigned long d2; 7 | char buf[25]; 8 | }; 9 | 10 | extern char* calc_address(struct example* tmp); 11 | 12 | int main(int argc, char** argv) 13 | { 14 | struct example x = {0}; 15 | strncpy(x.buf, "Test string!", 24); 16 | 17 | char* tmp = calc_address(&x); 18 | printf("%s\n", tmp); 19 | 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /tex/fpu_equation.tex: -------------------------------------------------------------------------------- 1 | \documentclass{standalone} 2 | \usepackage{tikz} 3 | \usetikzlibrary{positioning} 4 | 5 | \begin{document} 6 | \begin{tikzpicture}[/.style={ 7 | text width=12cm 8 | }] 9 | 10 | 11 | \node (n1) [label={\it Significand}] {$1.3785$}; 12 | \node (n3) [right = of n1]{x}; 13 | \node (n2) [label={\it Radix }, right= of n3] {$10^{3}$}; 14 | \node (n4) [right= of n2]{{\it Exponent} }; 15 | \draw[->] (n4.west) -- (n2.east); 16 | 17 | \end{tikzpicture} 18 | \end{document} -------------------------------------------------------------------------------- /demos/struc_locals/run.nasm: -------------------------------------------------------------------------------- 1 | bits 64 2 | 3 | extern my_function 4 | extern exit 5 | 6 | global run_me 7 | 8 | struc Locals 9 | .First resd 1 10 | .Second resq 1 11 | .Third resd 1 12 | endstruc 13 | 14 | run_me: 15 | push rbp 16 | mov rbp, rsp 17 | sub rsp, 0x10 18 | mov [rbp - 4 - Locals.First], edi 19 | mov [rbp - 8 - Locals.Second], rsi 20 | mov [rbp - 4 - Locals.Third], edx 21 | xor rax, rax 22 | mov eax, [rbp - 4 - Locals.First] 23 | add rsp, 0x10 24 | pop rbp 25 | ret 26 | -------------------------------------------------------------------------------- /demos/syscall_demos/dup2_demo/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | 8 | int main(int argc, char** argv, char** envp) 9 | { 10 | if (argc < 2) 11 | return 0; 12 | 13 | int fd = open(argv[1], O_WRONLY | O_CREAT); 14 | if(fd == -1) 15 | return -1; 16 | 17 | dup2(fd, STDOUT_FILENO); 18 | 19 | for(int i = 0; envp[i] != NULL; ++i) 20 | printf("%s\n", envp[i]); 21 | 22 | close(fd); 23 | 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /tex/introduction/section_2_bitops_or.tex: -------------------------------------------------------------------------------- 1 | \documentclass{standalone} 2 | \usepackage{tikz} 3 | \usepackage{tabularx} 4 | \usepackage{colortbl} 5 | \usepackage{booktabs} 6 | 7 | \begin{document} 8 | \begin{tikzpicture} 9 | 10 | \node (tbl) { 11 | \begin{tabularx}{.6\textwidth}{cXrcc} 12 | \arrayrulecolor{purple} 13 | \textbf{Set} & \textbf{Binary} \\ 14 | \toprule 15 | First & 01010011 \\ 16 | \midrule 17 | Second & 01001010 \\ 18 | \midrule 19 | Result & 01011011 \\ 20 | \end{tabularx} 21 | }; 22 | 23 | \end{tikzpicture} 24 | \end{document} -------------------------------------------------------------------------------- /asm_slides/bourbon/css3/_hidpi-media-query.scss: -------------------------------------------------------------------------------- 1 | // HiDPI mixin. Default value set to 1.3 to target Google Nexus 7 (http://bjango.com/articles/min-device-pixel-ratio/) 2 | @mixin hidpi($ratio: 1.3) { 3 | @media only screen and (-webkit-min-device-pixel-ratio: $ratio), 4 | only screen and (min--moz-device-pixel-ratio: $ratio), 5 | only screen and (-o-min-device-pixel-ratio: #{$ratio}/1), 6 | only screen and (min-resolution: round($ratio * 96dpi)), 7 | only screen and (min-resolution: $ratio * 1dppx) { 8 | @content; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /tex/introduction/section_2_bitops_and.tex: -------------------------------------------------------------------------------- 1 | \documentclass{standalone} 2 | \usepackage{tikz} 3 | \usepackage{tabularx} 4 | \usepackage{colortbl} 5 | \usepackage{booktabs} 6 | 7 | \begin{document} 8 | \begin{tikzpicture} 9 | 10 | \node (tbl) { 11 | \begin{tabularx}{.6\textwidth}{cXrcc} 12 | \arrayrulecolor{purple} 13 | \textbf{Set} & \textbf{Binary} \\ 14 | \toprule 15 | First & 01010011 \\ 16 | \midrule 17 | Second & 01000010 \\ 18 | \midrule 19 | Result & 01000010 \\ 20 | \end{tabularx} 21 | }; 22 | 23 | \end{tikzpicture} 24 | \end{document} -------------------------------------------------------------------------------- /tex/introduction/section_1_pointers.tex: -------------------------------------------------------------------------------- 1 | \documentclass{standalone} 2 | \usepackage{tikz} 3 | \usetikzlibrary{positioning} 4 | 5 | \begin{document} 6 | \begin{tikzpicture}[ 7 | n_st/.style={ 8 | rectangle, 9 | minimum size=8mm, 10 | very thick, 11 | draw=red!50!black!50, 12 | top color=white, 13 | bottom color=red!50!black!20, 14 | rounded corners=3mm, 15 | }] 16 | 17 | \node(reg)[n_st][label=rax]{0xc0ffee}; 18 | \node(mem)[n_st,right=of reg][label=0xc0ffee]{100}; 19 | \path (reg) edge[->] (mem); 20 | \end{tikzpicture} 21 | \end{document} 22 | -------------------------------------------------------------------------------- /asm_slides/bourbon/helpers/_gradient-positions-parser.scss: -------------------------------------------------------------------------------- 1 | @function _gradient-positions-parser($gradient-type, $gradient-positions) { 2 | @if $gradient-positions 3 | and ($gradient-type == linear) 4 | and (type-of($gradient-positions) != color) { 5 | $gradient-positions: _linear-positions-parser($gradient-positions); 6 | } 7 | @else if $gradient-positions 8 | and ($gradient-type == radial) 9 | and (type-of($gradient-positions) != color) { 10 | $gradient-positions: _radial-positions-parser($gradient-positions); 11 | } 12 | @return $gradient-positions; 13 | } 14 | -------------------------------------------------------------------------------- /tex/introduction/section_2_bitops_shl_1.tex: -------------------------------------------------------------------------------- 1 | \documentclass{standalone} 2 | \usepackage{tikz} 3 | \usepackage{tabularx} 4 | \usepackage{colortbl} 5 | \usepackage{booktabs} 6 | 7 | \begin{document} 8 | \begin{tikzpicture} 9 | 10 | \node (tbl) { 11 | \begin{tabularx}{.6\textwidth}{cXrcc} 12 | \arrayrulecolor{purple} 13 | \textbf{Decimal} & \textbf{Binary} & \textbf{State} \\ 14 | \toprule 15 | 1 & 00000001 & Initial \\ 16 | \midrule 17 | 2 & 00000010 & shl rax, 1 \\ 18 | \midrule 19 | 16 & 00010000 & shl rax, 3 \\ 20 | \end{tabularx} 21 | }; 22 | 23 | \end{tikzpicture} 24 | \end{document} -------------------------------------------------------------------------------- /tex/introduction/section_2_bitops_shr_1.tex: -------------------------------------------------------------------------------- 1 | \documentclass{standalone} 2 | \usepackage{tikz} 3 | \usepackage{tabularx} 4 | \usepackage{colortbl} 5 | \usepackage{booktabs} 6 | 7 | \begin{document} 8 | \begin{tikzpicture} 9 | 10 | \node (tbl) { 11 | \begin{tabularx}{.6\textwidth}{cXrcc} 12 | \arrayrulecolor{purple} 13 | \textbf{Decimal} & \textbf{Binary} & \textbf{State} \\ 14 | \toprule 15 | 32 & 00100000 & Initial \\ 16 | \midrule 17 | 16 & 00010000 & shr rax, 1 \\ 18 | \midrule 19 | 1 & 00000001 & shr rax, 4 \\ 20 | \end{tabularx} 21 | }; 22 | 23 | \end{tikzpicture} 24 | \end{document} -------------------------------------------------------------------------------- /asm_slides/bourbon/css3/_transform.scss: -------------------------------------------------------------------------------- 1 | @mixin transform($property: none) { 2 | // none | 3 | @include prefixer(transform, $property, webkit moz ms o spec); 4 | } 5 | 6 | @mixin transform-origin($axes: 50%) { 7 | // x-axis - left | center | right | length | % 8 | // y-axis - top | center | bottom | length | % 9 | // z-axis - length 10 | @include prefixer(transform-origin, $axes, webkit moz ms o spec); 11 | } 12 | 13 | @mixin transform-style($style: flat) { 14 | @include prefixer(transform-style, $style, webkit moz ms o spec); 15 | } 16 | -------------------------------------------------------------------------------- /asm_slides/bourbon/addons/_clearfix.scss: -------------------------------------------------------------------------------- 1 | @charset "UTF-8"; 2 | 3 | /// Provides an easy way to include a clearfix for containing floats. 4 | /// 5 | /// @link http://cssmojo.com/latest_new_clearfix_so_far/ 6 | /// 7 | /// @example scss - Usage 8 | /// .element { 9 | /// @include clearfix; 10 | /// } 11 | /// 12 | /// @example css - CSS Output 13 | /// .element::after { 14 | /// clear: both; 15 | /// content: ""; 16 | /// display: table; 17 | /// } 18 | 19 | @mixin clearfix { 20 | &::after { 21 | clear: both; 22 | content: ""; 23 | display: table; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /asm_slides/bourbon/functions/_tint.scss: -------------------------------------------------------------------------------- 1 | @charset "UTF-8"; 2 | 3 | /// Mixes a color with white. 4 | /// 5 | /// @param {Color} $color 6 | /// 7 | /// @param {Number (Percentage)} $percent 8 | /// The amount of white to be mixed in. 9 | /// 10 | /// @example scss - Usage 11 | /// .element { 12 | /// background-color: tint(#6ecaa6, 40%); 13 | /// } 14 | /// 15 | /// @example css - CSS Output 16 | /// .element { 17 | /// background-color: #a8dfc9; 18 | /// } 19 | /// 20 | /// @return {Color} 21 | 22 | @function tint($color, $percent) { 23 | @return mix(#fff, $color, $percent); 24 | } 25 | -------------------------------------------------------------------------------- /asm_slides/bourbon/functions/_shade.scss: -------------------------------------------------------------------------------- 1 | @charset "UTF-8"; 2 | 3 | /// Mixes a color with black. 4 | /// 5 | /// @param {Color} $color 6 | /// 7 | /// @param {Number (Percentage)} $percent 8 | /// The amount of black to be mixed in. 9 | /// 10 | /// @example scss - Usage 11 | /// .element { 12 | /// background-color: shade(#ffbb52, 60%); 13 | /// } 14 | /// 15 | /// @example css - CSS Output 16 | /// .element { 17 | /// background-color: #664a20; 18 | /// } 19 | /// 20 | /// @return {Color} 21 | 22 | @function shade($color, $percent) { 23 | @return mix(#000, $color, $percent); 24 | } 25 | -------------------------------------------------------------------------------- /asm_slides/bourbon/css3/_font-face.scss: -------------------------------------------------------------------------------- 1 | @mixin font-face( 2 | $font-family, 3 | $file-path, 4 | $weight: normal, 5 | $style: normal, 6 | $asset-pipeline: $asset-pipeline, 7 | $file-formats: eot woff2 woff ttf svg) { 8 | 9 | $font-url-prefix: font-url-prefixer($asset-pipeline); 10 | 11 | @font-face { 12 | font-family: $font-family; 13 | font-style: $style; 14 | font-weight: $weight; 15 | 16 | src: font-source-declaration( 17 | $font-family, 18 | $file-path, 19 | $asset-pipeline, 20 | $file-formats, 21 | $font-url-prefix 22 | ); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /asm_slides/bourbon/helpers/_radial-positions-parser.scss: -------------------------------------------------------------------------------- 1 | @function _radial-positions-parser($gradient-pos) { 2 | $shape-size: nth($gradient-pos, 1); 3 | $pos: nth($gradient-pos, 2); 4 | $shape-size-spec: _shape-size-stripper($shape-size); 5 | 6 | $pre-spec: unquote(if($pos, "#{$pos}, ", null)) 7 | unquote(if($shape-size, "#{$shape-size},", null)); 8 | $pos-spec: if($pos, "at #{$pos}", null); 9 | 10 | $spec: "#{$shape-size-spec} #{$pos-spec}"; 11 | 12 | // Add comma 13 | @if ($spec != " ") { 14 | $spec: "#{$spec},"; 15 | } 16 | 17 | @return $pre-spec $spec; 18 | } 19 | -------------------------------------------------------------------------------- /tex/introduction/fpu_data_regs.tex: -------------------------------------------------------------------------------- 1 | \documentclass{standalone} 2 | \usepackage{tikz} 3 | \usepackage{tabularx} 4 | \usepackage{booktabs} 5 | 6 | \begin{document} 7 | \begin{tikzpicture}[tab_style/.style={ 8 | draw=blue!50!black!50, 9 | top color=white, 10 | bottom color=blue!50!black!50, 11 | rounded corners=1mm, 12 | text width=12cm, 13 | align=center 14 | }] 15 | 16 | \node[tab_style] (tbl) { 17 | \begin{tabularx}{.6\textwidth}{cXrccc} 18 | \textbf{Sign} & \textbf{Exponent} & \textbf{Significand} \\ 19 | \toprule 20 | bit 79 & bits 64-79 & bits 0-64 \\ 21 | \end{tabularx} 22 | }; 23 | 24 | \end{tikzpicture} 25 | \end{document} -------------------------------------------------------------------------------- /tex/introduction/section_1_pointers_third_stage.tex: -------------------------------------------------------------------------------- 1 | \documentclass{standalone} 2 | \usepackage{tikz} 3 | \usetikzlibrary{positioning} 4 | 5 | \begin{document} 6 | \begin{tikzpicture}[ 7 | n_st/.style={ 8 | rectangle, 9 | minimum size=8mm, 10 | very thick, 11 | draw=red!50!black!50, 12 | top color=white, 13 | bottom color=red!50!black!20, 14 | rounded corners=3mm, 15 | }] 16 | 17 | \node(rax)[n_st][label=rax]{0xc0ffee}; 18 | \node(mem)[n_st,right=of rax][label=0xc0ffee]{100}; 19 | \node(rcx)[n_st][label=rcx,below left= of mem]{100}; 20 | \path (rax) edge[->] (mem); 21 | \end{tikzpicture} 22 | \end{document} 23 | -------------------------------------------------------------------------------- /asm_slides/bourbon/functions/_contains.scss: -------------------------------------------------------------------------------- 1 | @charset "UTF-8"; 2 | 3 | /// Checks if a list contains a value(s). 4 | /// 5 | /// @access private 6 | /// 7 | /// @param {List} $list 8 | /// The list to check against. 9 | /// 10 | /// @param {List} $values 11 | /// A single value or list of values to check for. 12 | /// 13 | /// @example scss - Usage 14 | /// contains($list, $value) 15 | /// 16 | /// @return {Bool} 17 | 18 | @function contains($list, $values...) { 19 | @each $value in $values { 20 | @if type-of(index($list, $value)) != "number" { 21 | @return false; 22 | } 23 | } 24 | 25 | @return true; 26 | } 27 | -------------------------------------------------------------------------------- /tex/introduction/section_1_pointers_second_stage.tex: -------------------------------------------------------------------------------- 1 | \documentclass{standalone} 2 | \usepackage{tikz} 3 | \usetikzlibrary{positioning} 4 | 5 | \begin{document} 6 | \begin{tikzpicture}[ 7 | n_st/.style={ 8 | rectangle, 9 | minimum size=8mm, 10 | very thick, 11 | draw=red!50!black!50, 12 | top color=white, 13 | bottom color=red!50!black!20, 14 | rounded corners=3mm, 15 | }] 16 | 17 | \node(rax)[n_st][label=rax]{0xc0ffee}; 18 | \node(mem)[n_st,right=of rax][label=0xc0ffee]{100}; 19 | \node(rcx)[n_st][label=rcx,below left= of mem]{0xc0ffee}; 20 | \path (rax) edge[->] (mem); 21 | \path (rcx) edge[->] (mem); 22 | \end{tikzpicture} 23 | \end{document} 24 | -------------------------------------------------------------------------------- /tex/introduction/section_2_bitops_xor.tex: -------------------------------------------------------------------------------- 1 | \documentclass{standalone} 2 | \usepackage{tikz} 3 | \usepackage{tabularx} 4 | \usepackage{colortbl} 5 | \usepackage{booktabs} 6 | 7 | \begin{document} 8 | \begin{tikzpicture} 9 | 10 | \node (tbl) { 11 | \begin{tabularx}{.65\textwidth}{cXrcc} 12 | \arrayrulecolor{purple} 13 | \textbf{Assembly} & \textbf{First Value} & \textbf{Second Val} & \textbf{Result} \\ 14 | \toprule 15 | xor rax, rax & 01010011 & 01010011 & 00000000 \\ 16 | \midrule 17 | xor rax, rcx & 01000010 & 01001010 & 00001000 \\ 18 | \midrule 19 | xor rcx, rax & 01001010 & 00001000 & 01000010 \\ 20 | \end{tabularx} 21 | }; 22 | 23 | \end{tikzpicture} 24 | \end{document} -------------------------------------------------------------------------------- /demos/syscall_demos/write_exit/src/write.nasm: -------------------------------------------------------------------------------- 1 | bits 64 2 | 3 | ; the write syscall number 4 | %define sys_write 1 5 | %define sys_exit 60 6 | %define stdout 1 ; stdout 7 | 8 | global write_stuff, exit_prog 9 | 10 | get_len: 11 | xor rax, rax 12 | mov rcx, -1 13 | repne scasb 14 | not rcx 15 | dec rcx 16 | xchg rax, rcx 17 | ret 18 | 19 | write_stuff: 20 | push rdi 21 | call get_len ; get our string length 22 | pop rsi ; param 2: buffer to write 23 | mov rdx, rax ; param 3: length 24 | mov rax, sys_write 25 | mov rdi, stdout 26 | syscall 27 | ret 28 | 29 | exit_prog: 30 | mov rax, sys_exit 31 | syscall 32 | -------------------------------------------------------------------------------- /tex/introduction/section_1_register_table.tex: -------------------------------------------------------------------------------- 1 | \documentclass{standalone} 2 | \usepackage{tikz} 3 | \usepackage{tabularx} 4 | \usepackage{colortbl} 5 | \usepackage{booktabs} 6 | 7 | \begin{document} 8 | \begin{tikzpicture} 9 | 10 | \node (tbl) { 11 | \begin{tabularx}{.6\textwidth}{cXrcc} 12 | \arrayrulecolor{purple} 13 | \textbf{64 bit} & \textbf{32 bit} & \textbf{16 bit} & \textbf{8 bit - h/l} \\ 14 | \toprule 15 | rax & eax & ax & ah/al \\ 16 | \midrule 17 | rcx & ecx & cx & ch/cl \\ 18 | \midrule 19 | rdx & edx & dx & dh/dl \\ 20 | \midrule 21 | rdi & edi & N/A & N/A \\ 22 | \midrule 23 | rsi & esi & N/A & N/A 24 | \end{tabularx} 25 | }; 26 | 27 | \end{tikzpicture} 28 | \end{document} -------------------------------------------------------------------------------- /asm_slides/bourbon/functions/_is-light.scss: -------------------------------------------------------------------------------- 1 | @charset "UTF-8"; 2 | 3 | /// Programatically determines whether a color is light or dark. 4 | /// 5 | /// @link http://robots.thoughtbot.com/closer-look-color-lightness 6 | /// 7 | /// @param {Color (Hex)} $color 8 | /// 9 | /// @example scss - Usage 10 | /// is-light($color) 11 | /// 12 | /// @return {Bool} 13 | 14 | @function is-light($hex-color) { 15 | $-local-red: red(rgba($hex-color, 1)); 16 | $-local-green: green(rgba($hex-color, 1)); 17 | $-local-blue: blue(rgba($hex-color, 1)); 18 | $-local-lightness: ($-local-red * 0.2126 + $-local-green * 0.7152 + $-local-blue * 0.0722) / 255; 19 | 20 | @return $-local-lightness > 0.6; 21 | } 22 | -------------------------------------------------------------------------------- /demos/opcodes_demo/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | unsigned char bytes[] = { 0xcc, 0xb8, 0x01, 0x00, 0x00, 0x00, 0xc3 }; 6 | 7 | int main(int argc, char** argv) 8 | { 9 | void* buffer = NULL; 10 | int(*rettrue)() = NULL; 11 | 12 | if (NULL == (buffer = mmap(NULL, sizeof(bytes), PROT_EXEC | PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, 0, 0))) { 13 | printf("Failed to allocate our buffer!\n"); 14 | return -1; 15 | } 16 | 17 | memcpy(buffer, bytes, sizeof(bytes)); 18 | 19 | rettrue = (int(*)())buffer; 20 | 21 | (rettrue()) ? printf("It returned true!\n") : printf("It didnt' return true :(\n"); 22 | 23 | munmap(buffer, sizeof(buffer)); 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /labs/Lab4/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | extern "C" size_t first_func(void); 6 | extern "C" size_t second_func(void); 7 | extern "C" size_t value = 30; 8 | 9 | #define EQ(x,y)\ 10 | do { if(x == y) printf("[*] Success! Values are equal!\n"); \ 11 | else printf("[x] Test Failed! Value %zu does not match value %zu!\n", x, y); } while(0) 12 | 13 | int main(int argc, char** argv) 14 | { 15 | 16 | printf("Preparing to run first function (stack allocation)\n"); 17 | EQ((size_t)0x10, first_func()); 18 | 19 | printf("Preparing to run second function (register preservation)\n"); 20 | EQ((size_t)1, second_func()); 21 | EQ((size_t)3, value); 22 | return 0; 23 | } -------------------------------------------------------------------------------- /asm_slides/bourbon/css3/_text-decoration.scss: -------------------------------------------------------------------------------- 1 | @mixin text-decoration($value) { 2 | // || || 3 | @include prefixer(text-decoration, $value, moz); 4 | } 5 | 6 | @mixin text-decoration-line($line: none) { 7 | // none || underline || overline || line-through 8 | @include prefixer(text-decoration-line, $line, moz); 9 | } 10 | 11 | @mixin text-decoration-style($style: solid) { 12 | // solid || double || dotted || dashed || wavy 13 | @include prefixer(text-decoration-style, $style, moz webkit); 14 | } 15 | 16 | @mixin text-decoration-color($color: currentColor) { 17 | // currentColor || 18 | @include prefixer(text-decoration-color, $color, moz); 19 | } 20 | -------------------------------------------------------------------------------- /asm_slides/bourbon/addons/_border-width.scss: -------------------------------------------------------------------------------- 1 | @charset "UTF-8"; 2 | 3 | /// Provides a quick method for targeting `border-width` on specific sides of a box. Use a `null` value to “skip” a side. 4 | /// 5 | /// @param {Arglist} $vals 6 | /// List of arguments 7 | /// 8 | /// @example scss - Usage 9 | /// .element { 10 | /// @include border-width(1em null 20px); 11 | /// } 12 | /// 13 | /// @example css - CSS Output 14 | /// .element { 15 | /// border-bottom-width: 20px; 16 | /// border-top-width: 1em; 17 | /// } 18 | /// 19 | /// @require {mixin} directional-property 20 | /// 21 | /// @output `border-width` 22 | 23 | @mixin border-width($vals...) { 24 | @include directional-property(border, width, $vals...); 25 | } 26 | -------------------------------------------------------------------------------- /asm_slides/bourbon/addons/_margin.scss: -------------------------------------------------------------------------------- 1 | @charset "UTF-8"; 2 | 3 | /// Provides a quick method for targeting `margin` on specific sides of a box. Use a `null` value to “skip” a side. 4 | /// 5 | /// @param {Arglist} $vals 6 | /// List of arguments 7 | /// 8 | /// @example scss - Usage 9 | /// .element { 10 | /// @include margin(null 10px 3em 20vh); 11 | /// } 12 | /// 13 | /// @example css - CSS Output 14 | /// .element { 15 | /// margin-bottom: 3em; 16 | /// margin-left: 20vh; 17 | /// margin-right: 10px; 18 | /// } 19 | /// 20 | /// @require {mixin} directional-property 21 | /// 22 | /// @output `margin` 23 | 24 | @mixin margin($vals...) { 25 | @include directional-property(margin, false, $vals...); 26 | } 27 | -------------------------------------------------------------------------------- /asm_slides/bourbon/addons/_padding.scss: -------------------------------------------------------------------------------- 1 | @charset "UTF-8"; 2 | 3 | /// Provides a quick method for targeting `padding` on specific sides of a box. Use a `null` value to “skip” a side. 4 | /// 5 | /// @param {Arglist} $vals 6 | /// List of arguments 7 | /// 8 | /// @example scss - Usage 9 | /// .element { 10 | /// @include padding(12vh null 10px 5%); 11 | /// } 12 | /// 13 | /// @example css - CSS Output 14 | /// .element { 15 | /// padding-bottom: 10px; 16 | /// padding-left: 5%; 17 | /// padding-top: 12vh; 18 | /// } 19 | /// 20 | /// @require {mixin} directional-property 21 | /// 22 | /// @output `padding` 23 | 24 | @mixin padding($vals...) { 25 | @include directional-property(padding, false, $vals...); 26 | } 27 | -------------------------------------------------------------------------------- /asm_slides/bourbon/addons/_border-style.scss: -------------------------------------------------------------------------------- 1 | @charset "UTF-8"; 2 | 3 | /// Provides a quick method for targeting `border-style` on specific sides of a box. Use a `null` value to “skip” a side. 4 | /// 5 | /// @param {Arglist} $vals 6 | /// List of arguments 7 | /// 8 | /// @example scss - Usage 9 | /// .element { 10 | /// @include border-style(dashed null solid); 11 | /// } 12 | /// 13 | /// @example css - CSS Output 14 | /// .element { 15 | /// border-bottom-style: solid; 16 | /// border-top-style: dashed; 17 | /// } 18 | /// 19 | /// @require {mixin} directional-property 20 | /// 21 | /// @output `border-style` 22 | 23 | @mixin border-style($vals...) { 24 | @include directional-property(border, style, $vals...); 25 | } 26 | -------------------------------------------------------------------------------- /asm_slides/bourbon/addons/_font-stacks.scss: -------------------------------------------------------------------------------- 1 | @charset "UTF-8"; 2 | 3 | /// Georgia font stack. 4 | /// 5 | /// @type List 6 | 7 | $georgia: "Georgia", "Cambria", "Times New Roman", "Times", serif; 8 | 9 | /// Helvetica font stack. 10 | /// 11 | /// @type List 12 | 13 | $helvetica: "Helvetica Neue", "Helvetica", "Roboto", "Arial", sans-serif; 14 | 15 | /// Lucida Grande font stack. 16 | /// 17 | /// @type List 18 | 19 | $lucida-grande: "Lucida Grande", "Tahoma", "Verdana", "Arial", sans-serif; 20 | 21 | /// Monospace font stack. 22 | /// 23 | /// @type List 24 | 25 | $monospace: "Bitstream Vera Sans Mono", "Consolas", "Courier", monospace; 26 | 27 | /// Verdana font stack. 28 | /// 29 | /// @type List 30 | 31 | $verdana: "Verdana", "Geneva", sans-serif; 32 | -------------------------------------------------------------------------------- /asm_slides/bourbon/addons/_word-wrap.scss: -------------------------------------------------------------------------------- 1 | @charset "UTF-8"; 2 | 3 | /// Provides an easy way to change the `word-wrap` property. 4 | /// 5 | /// @param {String} $wrap [break-word] 6 | /// Value for the `word-break` property. 7 | /// 8 | /// @example scss - Usage 9 | /// .wrapper { 10 | /// @include word-wrap(break-word); 11 | /// } 12 | /// 13 | /// @example css - CSS Output 14 | /// .wrapper { 15 | /// overflow-wrap: break-word; 16 | /// word-break: break-all; 17 | /// word-wrap: break-word; 18 | /// } 19 | 20 | @mixin word-wrap($wrap: break-word) { 21 | overflow-wrap: $wrap; 22 | word-wrap: $wrap; 23 | 24 | @if $wrap == break-word { 25 | word-break: break-all; 26 | } @else { 27 | word-break: $wrap; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /tex/introduction/section_2_twos_complement_p1.tex: -------------------------------------------------------------------------------- 1 | \documentclass{standalone} 2 | \usepackage{tikz} 3 | \usepackage{tabularx} 4 | \usepackage{colortbl} 5 | \usepackage{booktabs} 6 | 7 | \begin{document} 8 | \begin{tikzpicture}[tab_style/.style={ 9 | draw=blue!50!black!50, 10 | top color=white, 11 | bottom color=blue!50!black!50, 12 | rounded corners=1mm 13 | }] 14 | 15 | \node[tab_style](tbl) { 16 | \begin{tabularx}{.6\textwidth}{cXrcc} 17 | \arrayrulecolor{purple} 18 | \textbf{Decimal} & \textbf{Positive (bin)} & \textbf{Negative (binary)}\\ 19 | \toprule 20 | 1 & 0001 & 1111 \\ 21 | \midrule 22 | 2 & 0010 & 1110 \\ 23 | \midrule 24 | 3 & 0011 & 1101 \\ 25 | \midrule 26 | 4 & 0100 & 1100 27 | \end{tabularx} 28 | }; 29 | 30 | \end{tikzpicture} 31 | \end{document} 32 | -------------------------------------------------------------------------------- /tex/introduction/section_2_mul_table.tex: -------------------------------------------------------------------------------- 1 | \documentclass{standalone} 2 | \usepackage{tikz} 3 | \usepackage{tabularx} 4 | \usepackage{colortbl} 5 | \usepackage{booktabs} 6 | 7 | \begin{document} 8 | \begin{tikzpicture}[tab_style/.style={ 9 | draw=blue!50!black!50, 10 | top color=white, 11 | bottom color=blue!50!black!50, 12 | rounded corners=1mm 13 | }] 14 | 15 | \node[tab_style](tbl) { 16 | \begin{tabularx}{.6\textwidth}{cXrcc} 17 | \arrayrulecolor{purple} 18 | \textbf{Operand Size} & \textbf{First Source} & \textbf{Destination} \\ 19 | \toprule 20 | byte & al & ax \\ 21 | \midrule 22 | word & ax & dx:ax \\ 23 | \midrule 24 | dword & eax & edx:eax \\ 25 | \midrule 26 | qword & rax & rdx:rax 27 | \end{tabularx} 28 | }; 29 | 30 | \end{tikzpicture} 31 | \end{document} 32 | -------------------------------------------------------------------------------- /asm_slides/bourbon/addons/_border-color.scss: -------------------------------------------------------------------------------- 1 | @charset "UTF-8"; 2 | 3 | /// Provides a quick method for targeting `border-color` on specific sides of a box. Use a `null` value to “skip” a side. 4 | /// 5 | /// @param {Arglist} $vals 6 | /// List of arguments 7 | /// 8 | /// @example scss - Usage 9 | /// .element { 10 | /// @include border-color(#a60b55 #76cd9c null #e8ae1a); 11 | /// } 12 | /// 13 | /// @example css - CSS Output 14 | /// .element { 15 | /// border-left-color: #e8ae1a; 16 | /// border-right-color: #76cd9c; 17 | /// border-top-color: #a60b55; 18 | /// } 19 | /// 20 | /// @require {mixin} directional-property 21 | /// 22 | /// @output `border-color` 23 | 24 | @mixin border-color($vals...) { 25 | @include directional-property(border, color, $vals...); 26 | } 27 | -------------------------------------------------------------------------------- /tex/introduction/fpu_biased_table.tex: -------------------------------------------------------------------------------- 1 | \documentclass{standalone} 2 | \usepackage{tikz} 3 | \usepackage{tabularx} 4 | \usepackage{booktabs} 5 | 6 | \begin{document} 7 | 8 | \begin{tikzpicture}[tab_style/.style={ 9 | draw=blue!50!black!50, 10 | top color=white, 11 | bottom color=blue!50!black!50, 12 | rounded corners=1mm, 13 | text width=12cm, 14 | align=center 15 | }] 16 | 17 | \node[tab_style] { 18 | \begin{tabularx}{.8\textwidth}{cXrccc} 19 | \textbf{Parameter} & \textbf{Single} & \textbf{Double} & \textbf{Extended} \\ 20 | \toprule 21 | Total Size & 32 & 64 & 80 &\\ 22 | \midrule 23 | Significand Size & 23 & 53 & 63 &\\ 24 | \midrule 25 | Exponent Size & 8 & 11 & 15 &\\ 26 | \midrule 27 | Exponent Bias & 127 & 1023 & 16383 &\\ 28 | 29 | \end{tabularx} 30 | }; 31 | 32 | \end{tikzpicture} 33 | \end{document} -------------------------------------------------------------------------------- /tex/introduction/section_2_div_table.tex: -------------------------------------------------------------------------------- 1 | \documentclass{standalone} 2 | \usepackage{tikz} 3 | \usepackage{tabularx} 4 | \usepackage{colortbl} 5 | \usepackage{booktabs} 6 | 7 | \begin{document} 8 | \begin{tikzpicture}[tab_style/.style={ 9 | draw=blue!50!black!50, 10 | top color=white, 11 | bottom color=blue!50!black!50, 12 | rounded corners=1mm 13 | }] 14 | 15 | \node[tab_style](tbl) { 16 | \begin{tabularx}{.8\textwidth}{cXrcc} 17 | \arrayrulecolor{purple} 18 | \textbf{Maximum} & \textbf{Dividend} & \textbf{Quotient} & \textbf{Remainder} \\ 19 | \toprule 20 | byte/word & ax & al & ah \\ 21 | \midrule 22 | word/dword & dx:ax & ax & dx \\ 23 | \midrule 24 | dword/qword & edx:eax & eax & edx \\ 25 | \midrule 26 | dqword/qword & rdx:rax & rax & rdx 27 | \end{tabularx} 28 | }; 29 | 30 | \end{tikzpicture} 31 | \end{document} 32 | -------------------------------------------------------------------------------- /asm_slides/bourbon/addons/_ellipsis.scss: -------------------------------------------------------------------------------- 1 | @charset "UTF-8"; 2 | 3 | /// Truncates text and adds an ellipsis to represent overflow. 4 | /// 5 | /// @param {Number} $width [100%] 6 | /// Max-width for the string to respect before being truncated 7 | /// 8 | /// @example scss - Usage 9 | /// .element { 10 | /// @include ellipsis; 11 | /// } 12 | /// 13 | /// @example css - CSS Output 14 | /// .element { 15 | /// display: inline-block; 16 | /// max-width: 100%; 17 | /// overflow: hidden; 18 | /// text-overflow: ellipsis; 19 | /// white-space: nowrap; 20 | /// word-wrap: normal; 21 | /// } 22 | 23 | @mixin ellipsis($width: 100%) { 24 | display: inline-block; 25 | max-width: $width; 26 | overflow: hidden; 27 | text-overflow: ellipsis; 28 | white-space: nowrap; 29 | word-wrap: normal; 30 | } 31 | -------------------------------------------------------------------------------- /asm_slides/bourbon/functions/_transition-property-name.scss: -------------------------------------------------------------------------------- 1 | // Return vendor-prefixed property names if appropriate 2 | // Example: transition-property-names((transform, color, background), moz) -> -moz-transform, color, background 3 | //************************************************************************// 4 | @function transition-property-names($props, $vendor: false) { 5 | $new-props: (); 6 | 7 | @each $prop in $props { 8 | $new-props: append($new-props, transition-property-name($prop, $vendor), comma); 9 | } 10 | 11 | @return $new-props; 12 | } 13 | 14 | @function transition-property-name($prop, $vendor: false) { 15 | // put other properties that need to be prefixed here aswell 16 | @if $vendor and $prop == transform { 17 | @return unquote('-'+$vendor+'-'+$prop); 18 | } 19 | @else { 20 | @return $prop; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /tex/introduction/section_2_stack.tex: -------------------------------------------------------------------------------- 1 | \documentclass{standalone} 2 | \usepackage{tikz} 3 | \usetikzlibrary{matrix} 4 | 5 | \begin{document} 6 | \begin{tikzpicture} 7 | 8 | \matrix (m) [matrix of nodes, nodes in empty cells, 9 | column sep=0, row sep=0, 10 | column 1/.style={}, 11 | column 2/.style={nodes={text width=8cm,align=center}}, 12 | column 3/.style={nodes={minimum width=5mm}}] { 13 | 0x0000 &RSP &\\ 14 | 0x0008 &0x0000&\\ 15 | 0x0010 &0x0000&\\ 16 | 0x0018 &RBP &\\ 17 | }; 18 | 19 | \draw (m-1-2.north west) rectangle (m-4-2.south east); 20 | \draw (m-1-2.north east) rectangle (m-4-3.south east); 21 | \draw (m-4-2.north west) rectangle (m-4-2.south east); 22 | \draw (m-4-2.north east) rectangle (m-4-3.south east); 23 | 24 | \foreach \x in {1, 2} { 25 | \draw (m-\x-2.south west) -- (m-\x-3.south east); 26 | }; 27 | 28 | \end{tikzpicture} 29 | \end{document} -------------------------------------------------------------------------------- /asm_slides/bourbon/functions/_unpack.scss: -------------------------------------------------------------------------------- 1 | @charset "UTF-8"; 2 | 3 | /// Converts shorthand to the 4-value syntax. 4 | /// 5 | /// @param {List} $shorthand 6 | /// 7 | /// @example scss - Usage 8 | /// .element { 9 | /// margin: unpack(1em 2em); 10 | /// } 11 | /// 12 | /// @example css - CSS Output 13 | /// .element { 14 | /// margin: 1em 2em 1em 2em; 15 | /// } 16 | 17 | @function unpack($shorthand) { 18 | @if length($shorthand) == 1 { 19 | @return nth($shorthand, 1) nth($shorthand, 1) nth($shorthand, 1) nth($shorthand, 1); 20 | } @else if length($shorthand) == 2 { 21 | @return nth($shorthand, 1) nth($shorthand, 2) nth($shorthand, 1) nth($shorthand, 2); 22 | } @else if length($shorthand) == 3 { 23 | @return nth($shorthand, 1) nth($shorthand, 2) nth($shorthand, 3) nth($shorthand, 2); 24 | } @else { 25 | @return $shorthand; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /asm_slides/bourbon/addons/_hide-text.scss: -------------------------------------------------------------------------------- 1 | /// Hides the text in an element, commonly used to show an image. Some elements will need block-level styles applied. 2 | /// 3 | /// @link http://zeldman.com/2012/03/01/replacing-the-9999px-hack-new-image-replacement 4 | /// 5 | /// @example scss - Usage 6 | /// .element { 7 | /// @include hide-text; 8 | /// } 9 | /// 10 | /// @example css - CSS Output 11 | /// .element { 12 | /// overflow: hidden; 13 | /// text-indent: 101%; 14 | /// white-space: nowrap; 15 | /// } 16 | /// 17 | /// @todo Remove height argument in v5.0.0 18 | 19 | @mixin hide-text($height: null) { 20 | overflow: hidden; 21 | text-indent: 101%; 22 | white-space: nowrap; 23 | 24 | @if $height { 25 | @warn "The `hide-text` mixin has changed and no longer requires a height. The height argument will no longer be accepted in v5.0.0"; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /labs/Lab2/Lab2.nasm: -------------------------------------------------------------------------------- 1 | bits 64 2 | 3 | extern value 4 | global first_func, second_func 5 | 6 | first_func: 7 | mov rax, -1 8 | mov rcx, -1 9 | mov cl, 0x04 10 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 11 | ; For this task, you must move 12 | ; the first byte of RCX into 13 | ; RAX, using zero extend. 14 | ; 15 | ; 16 | ; BEGIN student code 17 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 18 | 19 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 20 | ; END student code 21 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 22 | ret 23 | 24 | 25 | second_func: 26 | xor rax, rax 27 | mov ah, 0x42 28 | mov al, 0x41 29 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 30 | ; For this task, you must swap 31 | ; the contents of the first two 32 | ; bytes of RAX (ah/al). 33 | ; 34 | ; BEGIN student code 35 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 36 | 37 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 38 | ; END student code 39 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 40 | ret -------------------------------------------------------------------------------- /tex/introduction/section_3_call_ret_pt1.tex: -------------------------------------------------------------------------------- 1 | \documentclass{standalone} 2 | \usepackage{tikz} 3 | \usetikzlibrary{matrix} 4 | 5 | \begin{document} 6 | \begin{tikzpicture} 7 | 8 | \matrix (m) [matrix of nodes, nodes in empty cells, 9 | column sep=0, row sep=0, 10 | column 1/.style={}, 11 | column 2/.style={nodes={text width=8cm, align=center}}, 12 | column 3/.style={nodes={minimum width=5mm}}] { 13 | 14 | 0x0000 & Parameters &\\ 15 | 0x0008 & Old RIP/return pointer & \\ 16 | 0x0010 & Old RBP &\\ 17 | 0x0018 & ... & \\ 18 | }; 19 | 20 | \draw (m-1-2.north west) rectangle (m-4-2.south east); 21 | \draw (m-1-2.north east) rectangle (m-4-3.south east); 22 | \draw (m-4-2.north west) rectangle (m-4-2.south east); 23 | \draw (m-4-2.north east) rectangle (m-4-3.south east); 24 | 25 | \foreach \x in {1, 2} { 26 | \draw (m-\x-2.south west) -- (m-\x-3.south east); 27 | }; 28 | 29 | \end{tikzpicture} 30 | \end{document} -------------------------------------------------------------------------------- /asm_slides/bourbon/helpers/_linear-angle-parser.scss: -------------------------------------------------------------------------------- 1 | // Private function for linear-gradient-parser 2 | @function _linear-angle-parser($image, $first-val, $prefix, $suffix) { 3 | $offset: null; 4 | $unit-short: str-slice($first-val, str-length($first-val) - 2, str-length($first-val)); 5 | $unit-long: str-slice($first-val, str-length($first-val) - 3, str-length($first-val)); 6 | 7 | @if ($unit-long == "grad") or 8 | ($unit-long == "turn") { 9 | $offset: if($unit-long == "grad", -100grad * 3, -0.75turn); 10 | } 11 | 12 | @else if ($unit-short == "deg") or 13 | ($unit-short == "rad") { 14 | $offset: if($unit-short == "deg", -90 * 3, 1.6rad); 15 | } 16 | 17 | @if $offset { 18 | $num: _str-to-num($first-val); 19 | 20 | @return ( 21 | webkit-image: -webkit- + $prefix + ($offset - $num) + $suffix, 22 | spec-image: $image 23 | ); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /asm_slides/bourbon/helpers/_convert-units.scss: -------------------------------------------------------------------------------- 1 | //************************************************************************// 2 | // Helper function for str-to-num fn. 3 | // Source: http://sassmeister.com/gist/9647408 4 | //************************************************************************// 5 | @function _convert-units($number, $unit) { 6 | $strings: "px", "cm", "mm", "%", "ch", "pica", "in", "em", "rem", "pt", "pc", "ex", "vw", "vh", "vmin", "vmax", "deg", "rad", "grad", "turn"; 7 | $units: 1px, 1cm, 1mm, 1%, 1ch, 1pica, 1in, 1em, 1rem, 1pt, 1pc, 1ex, 1vw, 1vh, 1vmin, 1vmax, 1deg, 1rad, 1grad, 1turn; 8 | $index: index($strings, $unit); 9 | 10 | @if not $index { 11 | @warn "Unknown unit `#{$unit}`."; 12 | @return false; 13 | } 14 | 15 | @if type-of($number) != "number" { 16 | @warn "`#{$number} is not a number`"; 17 | @return false; 18 | } 19 | 20 | @return $number * nth($units, $index); 21 | } 22 | -------------------------------------------------------------------------------- /labs/Lab10/Lab10.nasm: -------------------------------------------------------------------------------- 1 | bits 64 2 | 3 | global first_func, second_func, third_func 4 | 5 | first_func: 6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 7 | ; Using the rdtsc instruction, 8 | ; 1.) Obtain the current timestamp 9 | ; 2.) Combine the low 32 bits (from RAX) 10 | ; and the high 32 bits (RDX), and 11 | ; return them. 12 | ; 13 | ; BEGIN student code 14 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 15 | 16 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 17 | ; END student code 18 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 19 | ret 20 | 21 | second_func: 22 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 23 | ; Using CPUID, get the vendor 24 | ; string, and copy each chunk 25 | ; returned into the buffer 26 | ; passed to your function. 27 | ; The buffer should be the 28 | ; first (and only) argument. 29 | ; 30 | ; BEGIN student code 31 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 32 | 33 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 34 | ; END student code 35 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 36 | ret 37 | 38 | 39 | -------------------------------------------------------------------------------- /labs/Lab11/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #define FIRST_EXPECTED (float)3.5795002 7 | #define SECOND_EXPECTED (float)11.23450005 8 | 9 | extern "C" float out1; 10 | extern "C" double out2; 11 | extern "C" size_t first_func(void); 12 | extern "C" size_t second_func(int); 13 | 14 | #define EQ(x,y)\ 15 | do { if(x == y) printf("[*] Success! Values are equal!\n"); \ 16 | else printf("[x] Test Failed! Value %.8g does not match value %.8g!\n", x, y); } while(0) 17 | 18 | int main(int argc, char** argv) 19 | { 20 | printf("Preparing to run first_func (Add floating point numbers)\n"); 21 | first_func(); 22 | printf("Result: %.8g\n", out1); 23 | EQ(FIRST_EXPECTED, out1); 24 | 25 | printf("Preparing to run second_func (Add floats and integers)\n"); 26 | second_func(10); 27 | printf("Result: %.16g\n", out2); 28 | EQ(SECOND_EXPECTED, (float)out2); 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /asm_slides/bourbon/addons/_retina-image.scss: -------------------------------------------------------------------------------- 1 | @mixin retina-image($filename, $background-size, $extension: png, $retina-filename: null, $retina-suffix: _2x, $asset-pipeline: $asset-pipeline) { 2 | @if $asset-pipeline { 3 | background-image: image-url("#{$filename}.#{$extension}"); 4 | } @else { 5 | background-image: url("#{$filename}.#{$extension}"); 6 | } 7 | 8 | @include hidpi { 9 | @if $asset-pipeline { 10 | @if $retina-filename { 11 | background-image: image-url("#{$retina-filename}.#{$extension}"); 12 | } @else { 13 | background-image: image-url("#{$filename}#{$retina-suffix}.#{$extension}"); 14 | } 15 | } @else { 16 | @if $retina-filename { 17 | background-image: url("#{$retina-filename}.#{$extension}"); 18 | } @else { 19 | background-image: url("#{$filename}#{$retina-suffix}.#{$extension}"); 20 | } 21 | } 22 | 23 | background-size: $background-size; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /asm_slides/.sass-cache/3a8503476eb5763ba1a284dc68e3bbb7f36fb2a3/_px-to-em.scssc: -------------------------------------------------------------------------------- 1 | 3.4.21 (Selective Steve) 2 | 14880c373629b1e71abf17d6dc147ca56126856a 3 | o:Sass::Tree::RootNode :@children[o:Sass::Tree::VariableNode : 4 | @nameI" em-base:ET: 5 | @expro: Sass::Script::Tree::Literal : @valueo: Sass::Script::Value::Number 6 | ; i:@numerator_units[I"px; T:@denominator_units[: @options{:@originalI" 16px; F: 7 | @linei:@source_rangeo:Sass::Source::Range :@start_poso:Sass::Source::Position;i: @offseti: @end_poso;;i;i: 8 | @fileI"$bourbon/settings/_px-to-em.scss; T:@importero: Sass::Importers::Filesystem: 9 | @rootI"//Users/aaron/Documents/projects/asm_slides; T:@real_rootI"//Users/aaron/Documents/projects/asm_slides; T:@same_name_warningso:Set: 10 | @hash{:@filename@: @guardedT: @global0;[;i;o; ;o;;i;i;o;;i;i;@;@;@:@templateI"$em-base: 16px !default; 11 | ; T:@has_childrenT;@;i;o; ;o;;i;i;o;;i;i;@;@ -------------------------------------------------------------------------------- /asm_slides/bourbon/helpers/_render-gradients.scss: -------------------------------------------------------------------------------- 1 | // User for linear and radial gradients within background-image or border-image properties 2 | 3 | @function _render-gradients($gradient-positions, $gradients, $gradient-type, $vendor: false) { 4 | $pre-spec: null; 5 | $spec: null; 6 | $vendor-gradients: null; 7 | @if $gradient-type == linear { 8 | @if $gradient-positions { 9 | $pre-spec: nth($gradient-positions, 1); 10 | $spec: nth($gradient-positions, 2); 11 | } 12 | } 13 | @else if $gradient-type == radial { 14 | $pre-spec: nth($gradient-positions, 1); 15 | $spec: nth($gradient-positions, 2); 16 | } 17 | 18 | @if $vendor { 19 | $vendor-gradients: -#{$vendor}-#{$gradient-type}-gradient(#{$pre-spec} $gradients); 20 | } 21 | @else if $vendor == false { 22 | $vendor-gradients: "#{$gradient-type}-gradient(#{$spec} #{$gradients})"; 23 | $vendor-gradients: unquote($vendor-gradients); 24 | } 25 | @return $vendor-gradients; 26 | } 27 | -------------------------------------------------------------------------------- /labs/Lab2/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | extern "C" size_t first_func(void); 6 | extern "C" size_t second_func(void); 7 | extern "C" size_t value = -20; 8 | 9 | #define EQ(x,y)\ 10 | do { if(x == y) printf("[*] Success! Values are equal!\n"); \ 11 | else printf("[x] Test Failed! Value %zu does not match value %zu!\n", x, y); } while(0) 12 | 13 | #define EQ_C(x,y)\ 14 | do { if(x == y) printf("[*] Success! Values are equal!\n"); \ 15 | else printf("[x] Test Failed! Value %c does not match value %c!\n", x, y); } while(0) 16 | 17 | 18 | int main(int argc, char** argv) 19 | { 20 | char vals[] = { 'B', 'A' }; 21 | printf("Preparing to run first function (copying a byte)\n"); 22 | EQ((size_t)4, first_func()); 23 | printf("Preparing to run the second function (swapping low and high)\n"); 24 | size_t res = second_func(); 25 | 26 | EQ_C(((char*)&res)[0], vals[0]); 27 | EQ_C(((char*)&res)[1], vals[1]); 28 | 29 | return 0; 30 | } -------------------------------------------------------------------------------- /labs/WinFunctions/ASM/WinLab1/WinLab1.nasm: -------------------------------------------------------------------------------- 1 | bits 32 2 | 3 | global _first_func@12, _second_func@8 4 | 5 | section .text 6 | 7 | ;;;;;;;;;;;;;;;;;;;;;;; 8 | ; Using SIMD instructions, 9 | ; add the values in firstVec 10 | ; (a pointer that points to a 11 | ; 128 bit vector) with the values 12 | ; in secondVec, and store the 13 | ; results at thirdVec. 14 | ; 15 | ; void __stdcall first_func(int* firstVec, int* secondVec, int* thirdVec) 16 | ; BEGIN STUDENT CODE 17 | ;;;;;;;;;;;;;;;;;;;;;;; 18 | _first_func@12: 19 | 20 | ;;;;;;;;;;;;;;;;;;;;;;; 21 | ; END STUDENT CODE 22 | ;;;;;;;;;;;;;;;;;;;;;;; 23 | 24 | 25 | ;;;;;;;;;;;;;;;;;;;;;;; 26 | ; Using SIMD instructions, 27 | ; find the max of the two 28 | ; provided numbers, and 29 | ; return it. 30 | ; 31 | ; void __stdcall first_func(int first, int second) 32 | ; BEGIN STUDENT CODE 33 | ;;;;;;;;;;;;;;;;;;;;;;; 34 | _second_func@8: 35 | 36 | ;;;;;;;;;;;;;;;;;;;;;;; 37 | ; END STUDENT CODE 38 | ;;;;;;;;;;;;;;;;;;;;;;; -------------------------------------------------------------------------------- /tex/introduction/section_5_syscall.tex: -------------------------------------------------------------------------------- 1 | \documentclass{standalone} 2 | \usepackage{tikz} 3 | \usetikzlibrary{positioning} 4 | 5 | \begin{document} 6 | \begin{tikzpicture}[ 7 | n_st/.style={ 8 | rectangle, 9 | minimum size=8mm, 10 | very thick, 11 | draw=red!50!black!50, 12 | top color=white, 13 | bottom color=red!50!black!20, 14 | rounded corners=3mm, 15 | }] 16 | 17 | \node(proc)[n_st][label=User Mode]{Running Process}; 18 | \node(readcall)[n_st, right=of proc][label=User Mode]{read()}; 19 | \node(syscall)[n_st,right=of readcall][label=User Mode]{Syscall Occurs}; 20 | \node(kernel)[n_st,below=of syscall][label=Kernel Mode]{Syscall Handler}; 21 | \node(wh)[n_st, left=of kernel][label=Kernel Mode]{File Read Happens (incl. File System)}; 22 | \path (proc) edge[->] (readcall); 23 | \path (readcall) edge[->] (syscall); 24 | \path (syscall) edge[->] (kernel); 25 | \path (kernel) edge[->] (wh); 26 | \path (wh) edge[->] (readcall); 27 | 28 | \end{tikzpicture} 29 | \end{document} 30 | -------------------------------------------------------------------------------- /tex/introduction/section_2_stack_diag_2.tex: -------------------------------------------------------------------------------- 1 | \documentclass{standalone} 2 | \usepackage{tikz} 3 | \usetikzlibrary{matrix} 4 | 5 | \begin{document} 6 | \begin{tikzpicture} 7 | 8 | \matrix (m) [matrix of nodes, nodes in empty cells, 9 | column sep=0, row sep=0, 10 | column 1/.style={}, 11 | column 2/.style={nodes={text width=8cm,align=center}}, 12 | column 3/.style={nodes={minimum width=5mm}}] { 13 | 0x0000 &RSP &\\ 14 | 0x0008 &Old RSP&\\ 15 | 0x0010 &0x0000&\\ 16 | 0x0018 &0x0000 &\\ 17 | 0x0020 &0x0000&\\ 18 | 0x0028 &RBP &\\ 19 | }; 20 | 21 | \draw (m-1-2.north west) rectangle (m-6-2.south east); 22 | \draw (m-1-2.north east) rectangle (m-6-3.south east); 23 | \draw (m-4-2.north west) rectangle (m-6-2.south east); 24 | \draw (m-4-2.north east) rectangle (m-6-3.south east); 25 | 26 | \foreach \x in {1, 2, 3, 4, 5} { 27 | \draw (m-\x-2.south west) -- (m-\x-3.south east); 28 | }; 29 | 30 | \draw[->, rounded corners] (m-2-3.mid) -| ++(1cm, 1cm) |- (m-1-3.east); 31 | 32 | \end{tikzpicture} 33 | \end{document} -------------------------------------------------------------------------------- /tex/introduction/section_2_stack_diag_3.tex: -------------------------------------------------------------------------------- 1 | \documentclass{standalone} 2 | \usepackage{tikz} 3 | \usetikzlibrary{matrix} 4 | 5 | \begin{document} 6 | \begin{tikzpicture} 7 | 8 | \matrix (m) [matrix of nodes, nodes in empty cells, 9 | column sep=0, row sep=0, 10 | column 1/.style={}, 11 | column 2/.style={nodes={text width=8cm,align=center}}, 12 | column 3/.style={nodes={minimum width=5mm}}] { 13 | 0x0000 &Old RSP &\\ 14 | 0x0008 &RSP &\\ 15 | 0x0010 &0x0000&\\ 16 | 0x0018 &0x0000 &\\ 17 | 0x0020 &0x0000&\\ 18 | 0x0028 &RBP &\\ 19 | }; 20 | 21 | \draw (m-1-2.north west) rectangle (m-6-2.south east); 22 | \draw (m-1-2.north east) rectangle (m-6-3.south east); 23 | \draw (m-4-2.north west) rectangle (m-6-2.south east); 24 | \draw (m-4-2.north east) rectangle (m-6-3.south east); 25 | 26 | \foreach \x in {1, 2, 3, 4, 5} { 27 | \draw (m-\x-2.south west) -- (m-\x-3.south east); 28 | }; 29 | 30 | \draw[->, rounded corners] (m-1-3.mid) -| ++(1cm, 1cm) |- (m-2-3.east); 31 | 32 | \end{tikzpicture} 33 | \end{document} -------------------------------------------------------------------------------- /tex/introduction/section_3_call_ret_pt2.tex: -------------------------------------------------------------------------------- 1 | \documentclass{standalone} 2 | \usepackage{tikz} 3 | \usetikzlibrary{matrix, positioning} 4 | 5 | \begin{document} 6 | \begin{tikzpicture} 7 | 8 | \matrix (m) [matrix of nodes, nodes in empty cells, 9 | column sep=0, row sep=0, 10 | column 1/.style={}, 11 | column 2/.style={nodes={text width=8cm, align=center}}, 12 | column 3/.style={nodes={minimum width=5mm}}] { 13 | 14 | 0x0000 & Parameters &\\ 15 | 0x0008 & Old RIP/return pointer & \\ 16 | 0x0010 & ... &\\ 17 | 0x0018 & ... & \\ 18 | }; 19 | 20 | \draw node (n) [circle, draw=blue!80, right=1in of m]{RIP}; 21 | \draw[->] (m-2-3) -- (n.west); 22 | \draw (m-1-2.north west) rectangle (m-4-2.south east); 23 | \draw (m-1-2.north east) rectangle (m-4-3.south east); 24 | \draw (m-4-2.north west) rectangle (m-4-2.south east); 25 | \draw (m-4-2.north east) rectangle (m-4-3.south east); 26 | 27 | \foreach \x in {1, 2} { 28 | \draw (m-\x-2.south west) -- (m-\x-3.south east); 29 | }; 30 | 31 | \end{tikzpicture} 32 | \end{document} -------------------------------------------------------------------------------- /labs/Lab6/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | extern "C" size_t get_flags(void); 6 | extern "C" size_t first_func(void); 7 | extern "C" size_t second_func(void); 8 | extern "C" size_t third_func(void); 9 | 10 | 11 | #define CF_SET(x) x & (1 << 0) 12 | #define OF_SET(x) x & (1 << 11) 13 | 14 | #define T(x)\ 15 | do { if(x) printf("[*] Success!\n"); \ 16 | else printf("[x] Test Failed! Value did not evaluate to true\n"); } while(0) 17 | 18 | int main(int argc, char** argv) 19 | { 20 | size_t flags = 0; 21 | printf("Preparing to run first function (Carrying)\n"); 22 | first_func(); 23 | flags = get_flags(); 24 | T(CF_SET(flags)); 25 | 26 | printf("Preparing to run second function (Overflow)\n"); 27 | second_func(); 28 | flags = get_flags(); 29 | T(OF_SET(flags)); 30 | 31 | printf("Preparing to run third function (Setting both OF and CF)\n"); 32 | third_func(); 33 | flags = get_flags(); 34 | T(OF_SET(flags) && CF_SET(flags)); 35 | 36 | return 0; 37 | } 38 | -------------------------------------------------------------------------------- /asm_slides/bourbon/css3/_selection.scss: -------------------------------------------------------------------------------- 1 | @charset "UTF-8"; 2 | 3 | /// Outputs the spec and prefixed versions of the `::selection` pseudo-element. 4 | /// 5 | /// @param {Bool} $current-selector [false] 6 | /// If set to `true`, it takes the current element into consideration. 7 | /// 8 | /// @example scss - Usage 9 | /// .element { 10 | /// @include selection(true) { 11 | /// background-color: #ffbb52; 12 | /// } 13 | /// } 14 | /// 15 | /// @example css - CSS Output 16 | /// .element::-moz-selection { 17 | /// background-color: #ffbb52; 18 | /// } 19 | /// 20 | /// .element::selection { 21 | /// background-color: #ffbb52; 22 | /// } 23 | 24 | @mixin selection($current-selector: false) { 25 | @if $current-selector { 26 | &::-moz-selection { 27 | @content; 28 | } 29 | 30 | &::selection { 31 | @content; 32 | } 33 | } @else { 34 | ::-moz-selection { 35 | @content; 36 | } 37 | 38 | ::selection { 39 | @content; 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /labs/Lab13/quicksort.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int partition(int* array, int low, int high) 4 | { 5 | int pivot = array[high]; 6 | int i = low; 7 | int tmp = 0; 8 | 9 | for(int j = low; j < high; ++j) { 10 | if(array[j] <= pivot) { 11 | tmp = array[i]; 12 | array[i] = array[j]; 13 | array[j] = tmp; 14 | 15 | i += 1; 16 | } 17 | } 18 | tmp = array[i]; 19 | array[i] = array[high]; 20 | array[high] = tmp; 21 | return i; 22 | 23 | } 24 | 25 | void sort(int* array, int lower, int upper) 26 | { 27 | int i = 0; 28 | if (NULL == array) 29 | return; 30 | 31 | if(lower < upper) { 32 | i = partition(array, lower, upper); 33 | sort(array, lower, i-1); 34 | sort(array, i, upper); 35 | 36 | } 37 | } 38 | 39 | int main(int argc, char** argv) { 40 | int ar[] = {2, 3, 4, 5,10, 5}; 41 | 42 | sort(ar, 0, (sizeof(ar)/sizeof(int)-1)); 43 | 44 | for(int i = 0; i < sizeof(ar)/sizeof(int); ++i) 45 | printf("%d\t", ar[i]); 46 | 47 | printf("\n"); 48 | return 0; 49 | } 50 | -------------------------------------------------------------------------------- /tex/introduction/fpu_outline.tex: -------------------------------------------------------------------------------- 1 | \documentclass{standalone} 2 | \usepackage{tikz} 3 | \usepackage{tabularx} 4 | \usepackage{colortbl} 5 | \usepackage{booktabs} 6 | \usetikzlibrary{positioning} 7 | 8 | \begin{document} 9 | \begin{tikzpicture}[tab_style/.style={ 10 | draw=blue!50!black!50, 11 | top color=white, 12 | bottom color=blue!50!black!50, 13 | rounded corners=1mm, 14 | text width=12cm, 15 | align=center 16 | }] 17 | 18 | \node[tab_style] (tbl) { 19 | \begin{tabularx}{.8\textwidth}{cXrccc} 20 | \arrayrulecolor{purple} 21 | \textbf{Register Name(s)} & \textbf{Size} & \textbf{Register Type} \\ 22 | \toprule 23 | R0-R7 & 80 bits & Data \\ 24 | \midrule 25 | Control & 16 bits & Special \\ 26 | \midrule 27 | Status & 16 bits & Special \\ 28 | \midrule 29 | Tag & 16 bits & Special \\ 30 | \midrule 31 | Last Instruction Pointer & pointer-width (sorta) & Special \\ 32 | \midrule 33 | Last Data Pointer & pointer-width (sorta) & Special \\ 34 | \midrule 35 | Last Instruction Opcode & 10 bits & Special 36 | \end{tabularx} 37 | }; 38 | 39 | \end{tikzpicture} 40 | \end{document} -------------------------------------------------------------------------------- /asm_slides/bourbon/helpers/_linear-side-corner-parser.scss: -------------------------------------------------------------------------------- 1 | // Private function for linear-gradient-parser 2 | @function _linear-side-corner-parser($image, $first-val, $prefix, $suffix, $has-multiple-vals) { 3 | $val-1: str-slice($first-val, 1, $has-multiple-vals - 1); 4 | $val-2: str-slice($first-val, $has-multiple-vals + 1, str-length($first-val)); 5 | $val-3: null; 6 | $has-val-3: str-index($val-2, " "); 7 | 8 | @if $has-val-3 { 9 | $val-3: str-slice($val-2, $has-val-3 + 1, str-length($val-2)); 10 | $val-2: str-slice($val-2, 1, $has-val-3 - 1); 11 | } 12 | 13 | $pos: _position-flipper($val-1) _position-flipper($val-2) _position-flipper($val-3); 14 | $pos: unquote($pos + ""); 15 | 16 | // Use old spec for webkit 17 | @if $val-1 == "to" { 18 | @return ( 19 | webkit-image: -webkit- + $prefix + $pos + $suffix, 20 | spec-image: $image 21 | ); 22 | } 23 | 24 | // Bring the code up to spec 25 | @else { 26 | @return ( 27 | webkit-image: -webkit- + $image, 28 | spec-image: $prefix + "to " + $pos + $suffix 29 | ); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /labs/Lab6/Lab6.nasm: -------------------------------------------------------------------------------- 1 | bits 64 2 | 3 | global first_func, second_func, third_func 4 | 5 | first_func: 6 | push rbp 7 | mov rbp, rsp 8 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 9 | ; Set the carry flag. 10 | ; 11 | ; BEGIN student code 12 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 13 | 14 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 15 | ; END student code 16 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 17 | pop rbp 18 | ret 19 | 20 | second_func: 21 | push rbp 22 | mov rbp, rsp 23 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 24 | ; Set the overflow flag. 25 | ; 26 | ; BEGIN student code 27 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 28 | 29 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 30 | ; END student code 31 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 32 | pop rbp 33 | ret 34 | 35 | third_func: 36 | push rbp 37 | mov rbp, rsp 38 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 39 | ; Set both the carry and overflow 40 | ; flags. 41 | ; 42 | ; BEGIN student code 43 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 44 | 45 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 46 | ; END student code 47 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 48 | pop rbp 49 | ret 50 | 51 | 52 | -------------------------------------------------------------------------------- /labs/Lab3/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | extern "C" size_t first_func(void); 5 | extern "C" size_t second_func(void); 6 | extern "C" size_t third_func(void); 7 | extern "C" size_t fourth_func(void); 8 | extern "C" size_t fifth_func(void); 9 | 10 | #define EQ(x,y)\ 11 | do { if(x == y) printf("[*] Success! Values are equal!\n"); \ 12 | else printf("[x] Test Failed! Value %zu does not match value %zu!\n", x, y); } while(0) 13 | 14 | 15 | int main(int argc, char** argv) 16 | { 17 | printf("Preparing to run the first function (adding values)\n"); 18 | EQ((size_t)20, first_func()); 19 | 20 | 21 | printf("Preparing to run the second function (subtracting values)\n"); 22 | EQ((size_t)10, second_func()); 23 | 24 | printf("Preparing to run the third function (multiplying)\n"); 25 | EQ((size_t)100, third_func()); 26 | 27 | printf("Preparing to run the fourth function (division)\n"); 28 | EQ((size_t)5, fourth_func()); 29 | 30 | printf("Preparing to run the fifth function (remainder)\n"); 31 | EQ((size_t)1, fifth_func()); 32 | 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /labs/Lab7/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | extern "C" size_t first_func(size_t, size_t); 6 | extern "C" size_t second_func(int*, int); 7 | extern "C" size_t third_func(char*); 8 | 9 | #define SECOND_GREATER (size_t)-1 10 | #define FIRST_GREATER (size_t)1 11 | #define VALUES_EQUAL (size_t)0 12 | 13 | 14 | char buf[] = "Has anyone ever been as far as decided to look more like"; 15 | int values[] = { 10, 20, 30, 40, 50 }; 16 | 17 | #define EQ(x,y)\ 18 | do { if(x == y) printf("[*] Success! Values are equal!\n"); \ 19 | else printf("[x] Test Failed! Value %zu does not match value %zu!\n", x, y); } while(0) 20 | 21 | int main(int argc, char** argv) 22 | { 23 | size_t flags = 0; 24 | printf("Preparing to run first function (Larger Number)\n"); 25 | EQ(VALUES_EQUAL, first_func(2, 2)); 26 | EQ(FIRST_GREATER, first_func(2,1)); 27 | EQ(SECOND_GREATER, first_func(10, 20)); 28 | 29 | printf("Preparing to run second function (Sum)\n"); 30 | EQ((size_t)150, second_func(values, 5)); 31 | 32 | printf("Preparing to run third function (String length)\n"); 33 | EQ(strlen(buf), third_func(buf)); 34 | 35 | return 0; 36 | } 37 | -------------------------------------------------------------------------------- /labs/WinFunctions/ASM/ASM/ASM.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | 23 | 24 | Source Files 25 | 26 | 27 | -------------------------------------------------------------------------------- /labs/WinFunctions/ASM/WinLab1/WinLab1.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | 23 | 24 | Source Files 25 | 26 | 27 | -------------------------------------------------------------------------------- /labs/WinFunctions/WinAsmWeek2/Monday/Monday.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | 23 | 24 | Source Files 25 | 26 | 27 | -------------------------------------------------------------------------------- /labs/WinFunctions/WinAsmWeek2/Thursday/Thursday.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | 23 | 24 | Source Files 25 | 26 | 27 | -------------------------------------------------------------------------------- /labs/WinFunctions/WinAsmWeek2/Tuesday/Tuesday.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | 23 | 24 | Source Files 25 | 26 | 27 | -------------------------------------------------------------------------------- /labs/WinFunctions/WinAsmWeek2/Wednesday/Wednesday.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | 23 | 24 | Source Files 25 | 26 | 27 | -------------------------------------------------------------------------------- /labs/Lab13/insertion_sort.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void sort(int* array, size_t size) 4 | { 5 | int i = 0; 6 | int key = 0; 7 | 8 | if(NULL == array || 0 == size) 9 | return; 10 | 11 | // Starting from 1, we need to walk 12 | // to the end of the array. 13 | for(int j = 1; j < size; ++j) { 14 | // Our inner loop will start just below our outer, and 15 | // count backwards. 16 | i = j - 1; 17 | // We will take the value we're currently at, 18 | // and sort everything before it. 19 | key = array[j]; 20 | // while 0 <= i < j, we will check to see 21 | // if the current value in our array is bigger 22 | // than "key" 23 | while(i >= 0 && array[i] > key) { 24 | // If it's bigger, then shift it forward 25 | // one position. 26 | array[i+1] = array[i]; 27 | i = i -1; 28 | } 29 | // store the key we started with in the found position. 30 | array[i+1] = key; 31 | } 32 | 33 | } 34 | 35 | int main(int argc, char** argv) { 36 | int ar[] = {2, 3, 4, 5,10, 23, 22,7, 5}; 37 | 38 | sort(ar, sizeof(ar)/sizeof(int)); 39 | 40 | for(int i = 0; i < sizeof(ar)/sizeof(int); ++i) 41 | printf("%d\t", ar[i]); 42 | 43 | printf("\n"); 44 | return 0; 45 | } 46 | -------------------------------------------------------------------------------- /handouts/lab_instructions.txt: -------------------------------------------------------------------------------- 1 | ##################################################################### 2 | # 3 | # Using the labs 4 | # 5 | ##################################################################### 6 | 7 | 1.) Required Software 8 | 2.) Building and Running 9 | 10 | --------------------------------------------------------------------- 11 | 12 | 1.) List of Required Software 13 | 14 | * CMake, version >= 3.2 15 | * NASM 16 | * A C(++) compiler, such as clang or gcc 17 | * GDB 18 | * Visual Studio 2015 (Windows labs), and NASM for Windows 19 | 20 | 2.) Building and Running 21 | 22 | CMake Projects 23 | -------------- 24 | 25 | The bulk of the labs are all set up to use CMake to build/run, 26 | and should just require the following sequence of commands: 27 | 28 | cd project_dir 29 | cmake . 30 | cmake --build . 31 | ./labX 32 | 33 | Windows Projects 34 | ---------------- 35 | 36 | The Windows-specific labs are all bundled with a VS2015 solution file, 37 | which expects to find NASM in the solution directory (This will likely be 38 | ported to CMake in the future). The project should be buildable either via 39 | Visual Studio, or by running the following command: 40 | 41 | "%VS140COMNTOOLS%vsvars32.bat" && msbuild 42 | -------------------------------------------------------------------------------- /tex/introduction/section_3_eflags_layout.tex: -------------------------------------------------------------------------------- 1 | \documentclass{standalone} 2 | \usepackage{tikz} 3 | \usetikzlibrary{matrix, shapes.multipart, positioning} 4 | 5 | \begin{document} 6 | \begin{tikzpicture} 7 | 8 | \matrix (m1) [ matrix of nodes, nodes in empty cells, column sep=0, row sep=0, 9 | column 1/.style={}, 10 | column 2/.style={nodes={text width=2cm, align=center}}] { 11 | 0 &CF& \\ 12 | 1 &1 &\\ 13 | 2 &PF& \\ 14 | 3 &0 &\\ 15 | 4 &AF&\\ 16 | 5 &0 &\\ 17 | 6 &ZF &\\ 18 | 7 &SF &\\ 19 | 8 &TF &\\ 20 | 9 &IF &\\ 21 | 10 &DF &\\ 22 | 11 &OF &\\ 23 | 12 &IOPL &\\ 24 | 13 &IOPL &\\ 25 | 14 &NT &\\ 26 | 15 &0 &\\ 27 | 16 &RF &\\ 28 | 17 &VM &\\ 29 | 18 &AC &\\ 30 | 19 &VIF &\\ 31 | 20 &VIP &\\ 32 | 21 &ID &\\ 33 | 22 &0 &\\ 34 | 23 &0 &\\ 35 | 24 &0 &\\ 36 | 25 &0 &\\ 37 | 26 &0 &\\ 38 | 27 &0 &\\ 39 | 28 &0 &\\ 40 | 29 &0 &\\ 41 | 30 &0 &\\ 42 | 31 &0 &\\ 43 | }; 44 | 45 | \draw (m1-1-2.north west) rectangle (m1-32-2.south east); 46 | \draw (m1-1-2.north east) rectangle (m1-32-3.south east); 47 | \draw (m1-31-2.north west) rectangle (m1-32-2.south east); 48 | \draw (m1-31-2.north east) rectangle (m1-32-3.south east); 49 | 50 | \foreach \x in {1,2,...,31}{ \draw (m1-\x-2.south west) -- (m1-\x-3.south east); } 51 | 52 | \end{tikzpicture} 53 | \end{document} -------------------------------------------------------------------------------- /labs/CRT/more_defs.inc: -------------------------------------------------------------------------------- 1 | bits 64 2 | 3 | struc Dirent 4 | .d_ino resq 1 ; inode # 5 | .d_off resq 1 ; Offset to next record 6 | .d_reclen resw 1 ; length of this record 7 | .d_name resb 1 ; Start of filename (NULL-terminated) 8 | endstruc 9 | 10 | struc Stat 11 | .st_dev resq 1 12 | .st_ino resq 1 13 | .st_nlink resq 1 14 | .st_mode resd 1 15 | .st_uid resd 1 16 | .st_gid resd 1 17 | .pad0 resb 4 18 | .st_rdev resq 1 19 | .st_size resq 1 20 | .st_blksize resq 1 21 | .st_blocks resq 1 22 | .st_atime resq 1 23 | .st_atime_nsec resq 1 24 | .st_mtime resq 1 25 | .st_mtime_nsec resq 1 26 | .st_ctime resq 1 27 | .st_ctime_nsec resq 1 28 | endstruc 29 | 30 | ; Arguments for lseek (values for 3rd param - whence) 31 | %define SEEK_SET 0 ; Seek from beginning of file 32 | %define SEEK_CUR 1 ; Seek from current position 33 | %define SEEK_END 2 ; Seek from the end of the file 34 | 35 | %define sys_getdents 78 36 | %define sys_execve 59 37 | %define sys_stat 4 38 | %define sys_lseek 8 39 | %define sys_pause 34 40 | -------------------------------------------------------------------------------- /asm_slides/bourbon/helpers/_font-source-declaration.scss: -------------------------------------------------------------------------------- 1 | // Used for creating the source string for fonts using @font-face 2 | // Reference: http://goo.gl/Ru1bKP 3 | 4 | @function font-url-prefixer($asset-pipeline) { 5 | @if $asset-pipeline == true { 6 | @return font-url; 7 | } @else { 8 | @return url; 9 | } 10 | } 11 | 12 | @function font-source-declaration( 13 | $font-family, 14 | $file-path, 15 | $asset-pipeline, 16 | $file-formats, 17 | $font-url) { 18 | 19 | $src: (); 20 | 21 | $formats-map: ( 22 | eot: "#{$file-path}.eot?#iefix" format("embedded-opentype"), 23 | woff2: "#{$file-path}.woff2" format("woff2"), 24 | woff: "#{$file-path}.woff" format("woff"), 25 | ttf: "#{$file-path}.ttf" format("truetype"), 26 | svg: "#{$file-path}.svg##{$font-family}" format("svg") 27 | ); 28 | 29 | @each $key, $values in $formats-map { 30 | @if contains($file-formats, $key) { 31 | $file-path: nth($values, 1); 32 | $font-format: nth($values, 2); 33 | 34 | @if $asset-pipeline == true { 35 | $src: append($src, font-url($file-path) $font-format, comma); 36 | } @else { 37 | $src: append($src, url($file-path) $font-format, comma); 38 | } 39 | } 40 | } 41 | 42 | @return $src; 43 | } 44 | -------------------------------------------------------------------------------- /demos/syscall_demos/threads_demo/src/threads.nasm: -------------------------------------------------------------------------------- 1 | bits 64 2 | 3 | %define sys_exit 60 4 | %define sys_clone 56 5 | 6 | ; Clone Flags 7 | %define CLONE_VM 0x00000100 ; VM shared between procs. 8 | %define CLONE_FS 0x00000200 ; fs info shared 9 | %define CLONE_FILES 0x00000400 ; open files shared 10 | %define CLONE_SIGHAND 0x00000800 ; signal handlers shared. 11 | %define CLONE_THREAD 0x00010000 ; add to same thread group. 12 | 13 | global create_thread, exit_p 14 | 15 | create_thread: 16 | push rdi ; Store our thread function 17 | 18 | ; Set clone flags 19 | mov rdi, CLONE_VM 20 | or rdi, CLONE_FS 21 | or rdi, CLONE_FILES 22 | or rdi, CLONE_SIGHAND 23 | or rdi, CLONE_THREAD 24 | 25 | lea rsi, [rsi + rdx - 8] ; get us 8 bytes shy of the end of our new stack 26 | ; Store exit at the very top of the stack 27 | mov rax, exit_p 28 | mov [rsi], rax 29 | ; Move down, and store our thread function here 30 | sub rsi, 8 31 | pop qword [rsi] 32 | ; Perform the syscall 33 | mov rax, sys_clone 34 | syscall 35 | ; Parent returns to main(), child to 36 | ; the thread function, and then exit. 37 | ret 38 | 39 | exit_p: 40 | mov rax, sys_exit 41 | xor rdi, rdi 42 | syscall 43 | 44 | 45 | -------------------------------------------------------------------------------- /labs/Lab11/Lab11.nasm: -------------------------------------------------------------------------------- 1 | bits 64 2 | 3 | extern first_value 4 | global first_func, second_func, third_func 5 | global out1, out2 6 | 7 | section .data 8 | 9 | firstfloat dd 1.2345 10 | 11 | secondfloat dd 2.345 12 | 13 | out1 dd 0x00 14 | 15 | 16 | out2 dq 0x00 17 | 18 | tmp dq 0x00 19 | 20 | section .text 21 | 22 | first_func: 23 | push rbp 24 | mov rbp, rsp 25 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 26 | ; This problem will require 27 | ; you to load both firstfloat 28 | ; and secondfloat (above) onto 29 | ; the floating point stack, add 30 | ; them together, and store the 31 | ; result in out1. 32 | ; 33 | ; BEGIN student code 34 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 35 | 36 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 37 | ; END student code 38 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 39 | pop rbp 40 | ret 41 | 42 | second_func: 43 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 44 | ; This problem will require 45 | ; you to add the contents of 46 | ; _firstfloat to an integer 47 | ; that is passed in as the 48 | ; first (and only) argument 49 | ; to your function. Store the 50 | ; result at out2. 51 | ; 52 | ; BEGIN student code 53 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 54 | 55 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 56 | ; END student code 57 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 58 | ret 59 | 60 | 61 | -------------------------------------------------------------------------------- /labs/WinFunctions/ASM/WinLab1/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #define EQ(x, y)\ 5 | do { x == y ? printf("[*] Success! Test passed.\n") : printf("[x] %s : %d - Test failed! %d is not equal to %d!", __FILE__, __LINE__, x, y); } while (0) 6 | 7 | extern "C" void __stdcall first_func(int* firstVec, int* secondVec, int* thirdVec); 8 | extern "C" int __stdcall second_func(int first, int second); 9 | 10 | void first_test() 11 | { 12 | int set1[] = { 10, 20, 30, 40 }; 13 | int set2[] = { 20, 30, 40, 50 }; 14 | int res[4] = { 0 }; 15 | 16 | printf("Preparing to run first test... (Adding two vectors)\n"); 17 | first_func(set1, set2, res); 18 | 19 | printf("Result: %d | %d | %d | %d\n", res[0], res[1], res[2], res[3]); 20 | 21 | for (int i = 0; i < 4; ++i) { 22 | EQ((set1[i] + set2[i]), res[i]); 23 | } 24 | } 25 | 26 | void second_test() 27 | { 28 | int first = rand(); 29 | int second = rand(); 30 | int tmp = (first > second) ? first : second; 31 | 32 | printf("Preparing to run the second test... (Getting the max of two numbers-%d and %d)\n"); 33 | EQ(tmp, second_func(first, second)); 34 | } 35 | 36 | int main(int argc, char** argv) 37 | { 38 | srand(GetTickCount()); 39 | first_test(); 40 | second_test(); 41 | return 0; 42 | } -------------------------------------------------------------------------------- /asm_slides/bourbon/helpers/_linear-gradient-parser.scss: -------------------------------------------------------------------------------- 1 | @function _linear-gradient-parser($image) { 2 | $image: unquote($image); 3 | $gradients: (); 4 | $start: str-index($image, "("); 5 | $end: str-index($image, ","); 6 | $first-val: str-slice($image, $start + 1, $end - 1); 7 | 8 | $prefix: str-slice($image, 1, $start); 9 | $suffix: str-slice($image, $end, str-length($image)); 10 | 11 | $has-multiple-vals: str-index($first-val, " "); 12 | $has-single-position: unquote(_position-flipper($first-val) + ""); 13 | $has-angle: is-number(str-slice($first-val, 1, 1)); 14 | 15 | @if $has-multiple-vals { 16 | $gradients: _linear-side-corner-parser($image, $first-val, $prefix, $suffix, $has-multiple-vals); 17 | } 18 | 19 | @else if $has-single-position != "" { 20 | $pos: unquote($has-single-position + ""); 21 | 22 | $gradients: ( 23 | webkit-image: -webkit- + $image, 24 | spec-image: $prefix + "to " + $pos + $suffix 25 | ); 26 | } 27 | 28 | @else if $has-angle { 29 | // Rotate degree for webkit 30 | $gradients: _linear-angle-parser($image, $first-val, $prefix, $suffix); 31 | } 32 | 33 | @else { 34 | $gradients: ( 35 | webkit-image: -webkit- + $image, 36 | spec-image: $image 37 | ); 38 | } 39 | 40 | @return $gradients; 41 | } 42 | -------------------------------------------------------------------------------- /asm_slides/bourbon/addons/_border-radius.scss: -------------------------------------------------------------------------------- 1 | @charset "UTF-8"; 2 | 3 | /// Provides a quick method for targeting `border-radius` on both corners on the side of a box. 4 | /// 5 | /// @param {Number} $radii 6 | /// List of arguments 7 | /// 8 | /// @example scss - Usage 9 | /// .element-one { 10 | /// @include border-top-radius(5px); 11 | /// } 12 | /// 13 | /// .element-two { 14 | /// @include border-left-radius(3px); 15 | /// } 16 | /// 17 | /// @example css - CSS Output 18 | /// .element-one { 19 | /// border-top-left-radius: 5px; 20 | /// border-top-right-radius: 5px; 21 | /// } 22 | /// 23 | /// .element-two { 24 | /// border-bottom-left-radius: 3px; 25 | /// border-top-left-radius: 3px; 26 | /// } 27 | /// 28 | /// @output `border-radius` 29 | 30 | @mixin border-top-radius($radii) { 31 | border-top-left-radius: $radii; 32 | border-top-right-radius: $radii; 33 | } 34 | 35 | @mixin border-right-radius($radii) { 36 | border-bottom-right-radius: $radii; 37 | border-top-right-radius: $radii; 38 | } 39 | 40 | @mixin border-bottom-radius($radii) { 41 | border-bottom-left-radius: $radii; 42 | border-bottom-right-radius: $radii; 43 | } 44 | 45 | @mixin border-left-radius($radii) { 46 | border-bottom-left-radius: $radii; 47 | border-top-left-radius: $radii; 48 | } 49 | -------------------------------------------------------------------------------- /asm_slides/bourbon/css3/_keyframes.scss: -------------------------------------------------------------------------------- 1 | // Adds keyframes blocks for supported prefixes, removing redundant prefixes in the block's content 2 | @mixin keyframes($name) { 3 | $original-prefix-for-webkit: $prefix-for-webkit; 4 | $original-prefix-for-mozilla: $prefix-for-mozilla; 5 | $original-prefix-for-microsoft: $prefix-for-microsoft; 6 | $original-prefix-for-opera: $prefix-for-opera; 7 | $original-prefix-for-spec: $prefix-for-spec; 8 | 9 | @if $original-prefix-for-webkit { 10 | @include disable-prefix-for-all(); 11 | $prefix-for-webkit: true !global; 12 | @-webkit-keyframes #{$name} { 13 | @content; 14 | } 15 | } 16 | 17 | @if $original-prefix-for-mozilla { 18 | @include disable-prefix-for-all(); 19 | $prefix-for-mozilla: true !global; 20 | @-moz-keyframes #{$name} { 21 | @content; 22 | } 23 | } 24 | 25 | $prefix-for-webkit: $original-prefix-for-webkit !global; 26 | $prefix-for-mozilla: $original-prefix-for-mozilla !global; 27 | $prefix-for-microsoft: $original-prefix-for-microsoft !global; 28 | $prefix-for-opera: $original-prefix-for-opera !global; 29 | $prefix-for-spec: $original-prefix-for-spec !global; 30 | 31 | @if $original-prefix-for-spec { 32 | @keyframes #{$name} { 33 | @content; 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /asm_slides/bourbon/addons/_size.scss: -------------------------------------------------------------------------------- 1 | @charset "UTF-8"; 2 | 3 | /// Sets the `width` and `height` of the element. 4 | /// 5 | /// @param {List} $size 6 | /// A list of at most 2 size values. 7 | /// 8 | /// If there is only a single value in `$size` it is used for both width and height. All units are supported. 9 | /// 10 | /// @example scss - Usage 11 | /// .first-element { 12 | /// @include size(2em); 13 | /// } 14 | /// 15 | /// .second-element { 16 | /// @include size(auto 10em); 17 | /// } 18 | /// 19 | /// @example css - CSS Output 20 | /// .first-element { 21 | /// width: 2em; 22 | /// height: 2em; 23 | /// } 24 | /// 25 | /// .second-element { 26 | /// width: auto; 27 | /// height: 10em; 28 | /// } 29 | /// 30 | /// @todo Refactor in 5.0.0 to use a comma-separated argument 31 | 32 | @mixin size($value) { 33 | $width: nth($value, 1); 34 | $height: $width; 35 | 36 | @if length($value) > 1 { 37 | $height: nth($value, 2); 38 | } 39 | 40 | @if is-size($height) { 41 | height: $height; 42 | } @else { 43 | @warn "`#{$height}` is not a valid length for the `$height` parameter in the `size` mixin."; 44 | } 45 | 46 | @if is-size($width) { 47 | width: $width; 48 | } @else { 49 | @warn "`#{$width}` is not a valid length for the `$width` parameter in the `size` mixin."; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /asm_slides/bourbon/addons/_position.scss: -------------------------------------------------------------------------------- 1 | @charset "UTF-8"; 2 | 3 | /// Provides a quick method for setting an element’s position. Use a `null` value to “skip” a side. 4 | /// 5 | /// @param {Position} $position [relative] 6 | /// A CSS position value 7 | /// 8 | /// @param {Arglist} $coordinates [null null null null] 9 | /// List of values that correspond to the 4-value syntax for the edges of a box 10 | /// 11 | /// @example scss - Usage 12 | /// .element { 13 | /// @include position(absolute, 0 null null 10em); 14 | /// } 15 | /// 16 | /// @example css - CSS Output 17 | /// .element { 18 | /// left: 10em; 19 | /// position: absolute; 20 | /// top: 0; 21 | /// } 22 | /// 23 | /// @require {function} is-length 24 | /// @require {function} unpack 25 | 26 | @mixin position($position: relative, $coordinates: null null null null) { 27 | @if type-of($position) == list { 28 | $coordinates: $position; 29 | $position: relative; 30 | } 31 | 32 | $coordinates: unpack($coordinates); 33 | 34 | $offsets: ( 35 | top: nth($coordinates, 1), 36 | right: nth($coordinates, 2), 37 | bottom: nth($coordinates, 3), 38 | left: nth($coordinates, 4) 39 | ); 40 | 41 | position: $position; 42 | 43 | @each $offset, $value in $offsets { 44 | @if is-length($value) { 45 | #{$offset}: $value; 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /labs/WinFunctions/WinAsmWeek2/Tuesday/tuesday.nasm: -------------------------------------------------------------------------------- 1 | bits 32 2 | 3 | global _copy_string, _get_cpu_string@4, _set_flags 4 | 5 | section .text 6 | 7 | 8 | _copy_string: 9 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 10 | ; 11 | ; This method takes 3 params: 12 | ; 13 | ; Param 1: An empty buffer 14 | ; 15 | ; Param 2: A NULL-terminated string 16 | ; 17 | ; Given these two inputs, 18 | ; 1.) Find the length of the string provided in 19 | ; param 2 20 | ; 2.) Copy the string from param 2, to the empty buffer 21 | ; provided in param 1. 22 | ; 23 | ; void __cdecl copy_string(char* dest, char* src); 24 | ; 25 | ; BEGIN STUDENT CODE 26 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 27 | 28 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 29 | ; END STUDENT CODE 30 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 31 | 32 | _get_cpu_string@4: 33 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 34 | ; 35 | ; This function takes 1 param: 36 | ; 37 | ; Param 1: A zero'd character buffer, containing 38 | ; 13 elements. 39 | ; 40 | ; The following steps must be performed: 41 | ; 1.) Call CPUID and get the vendor string 42 | ; 2.) Copy from ASCII bytes returned into the buffer 43 | ; provided. 44 | ; 45 | ; void __stdcall get_cpu_string(char* buf); 46 | ; 47 | ; 48 | ; BEGIN STUDENT CODE 49 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 50 | 51 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 52 | ; END STUDENT CODE 53 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 54 | 55 | 56 | -------------------------------------------------------------------------------- /demos/redirection_demos/fork_output.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #define TMP_FILE_STR "tmp.txt" 12 | #define BEGIN_OFFSET 1 13 | #define BUFSZ 1024 14 | #define LOG_ERROR(x)\ 15 | do { fprintf(stderr, "[x] %s : %d : %d - " x "\n", __FILE__, __LINE__, errno); } while(0) 16 | 17 | int main(int argc, char** argv, char** envp) 18 | { 19 | char buf[BUFSZ] = {0}; 20 | char* newenvp[] = { NULL }; 21 | pid_t child = 0; 22 | int fd = -1; 23 | 24 | if(argc < 2) { 25 | errno = EINVAL; 26 | LOG_ERROR("Must provide one or more arguments!"); 27 | return 0; 28 | } 29 | 30 | if(-1 == (fd = open(TMP_FILE_STR, O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP))) { 31 | LOG_ERROR("File open failed!"); 32 | return 0; 33 | } 34 | 35 | if(-1 == dup2(fd, STDOUT_FILENO)) { 36 | LOG_ERROR("Output redirection failed!"); 37 | close(fd); 38 | return 0; 39 | } 40 | 41 | if(-1 == dup2(fd, STDERR_FILENO)) { 42 | LOG_ERROR("Error redirection failed!"); 43 | close(fd); 44 | return 0; 45 | } 46 | close(fd); 47 | if(0 == (child = fork())) { 48 | execve(argv[BEGIN_OFFSET], &argv[BEGIN_OFFSET], newenvp); 49 | } else { 50 | wait(NULL); 51 | } 52 | 53 | return 0; 54 | } -------------------------------------------------------------------------------- /labs/WinFunctions/WinAsmWeek2/Thursday/thursday.nasm: -------------------------------------------------------------------------------- 1 | bits 32 2 | 3 | global _fibonacci@4, _walk_list_map@8 4 | 5 | 6 | section .text 7 | 8 | 9 | _fibonacci@4: 10 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 11 | ; 12 | ; This method takes a single parameter: 13 | ; 14 | ; Param 1: The fibonacci number to calculate (e.g., "5" would indicate 15 | ; to calculate and return the 5th fibonacci number). 16 | ; 17 | ; int __stdcall fibonacci(int n); 18 | ; 19 | ; BEGIN STUDENT CODE 20 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 21 | 22 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 23 | ; END STUDENT CODE 24 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 25 | 26 | 27 | struc Node 28 | .Next resd 1 29 | .Data resd 1 30 | endstruc 31 | 32 | 33 | _walk_list_map@8: 34 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 35 | ; 36 | ; This method takes two parameters: 37 | ; 38 | ; Param 1: A pointer to the beginning of a linked list of nodes (structure 39 | ; definition above) 40 | ; 41 | ; Param 2: A function pointer 42 | ; 43 | ; Your task: 44 | ; 1.) Walk the list of nodes 45 | ; 2.) For each node, call the function pointer provided 46 | ; as parameter 2, giving it as input the Data from the node. 47 | ; 48 | ; void __stdcall walk_list_map(Node* n, void(*)(size_t)); 49 | ; 50 | ; BEGIN STUDENT CODE 51 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 52 | 53 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 54 | ; END STUDENT CODE 55 | ;;;;;;;;;;;;;;;;;;;;;;;;;; -------------------------------------------------------------------------------- /labs/WinFunctions/WinAsmWeek2/Wednesday/wednesday.nasm: -------------------------------------------------------------------------------- 1 | bits 32 2 | 3 | global _sum_array@8, _find_largest 4 | 5 | section .text 6 | 7 | 8 | _sum_array@8: 9 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 10 | ; 11 | ; This method takes two parameters: 12 | ; 13 | ; Param 1: A pointer to a buffer of integers (4 bytes/each). 14 | ; 15 | ; Param 2: A number indicating the number of elements in the buffer. 16 | ; 17 | ; You must: 18 | ; 1.) Walk through the buffer, and sum together all of the elements 19 | ; 2.) Return the result 20 | ; 21 | ; int __stdcall sum_array(int* buffer, int size); 22 | ; 23 | ; BEGIN STUDENT CODE 24 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 25 | 26 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 27 | ; END STUDENT CODE 28 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 29 | 30 | 31 | _find_largest: 32 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 33 | ; 34 | ; This function takes two 35 | ; parameters: 36 | ; 37 | ; Param 1: A pointer to a buffer of integers (4 bytes/each) 38 | ; 39 | ; Param 2: A number indicating the number of elements in the 40 | ; buffer. 41 | ; 42 | ; Your task is to: 43 | ; 1.) Walk through the buffer, locating the largest element 44 | ; 2.) Return it as the result. 45 | ; 46 | ; int __cdecl find_largest(unsigned long* buffer, int size) 47 | ; 48 | ; BEGIN STUDENT CODE 49 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 50 | 51 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 52 | ; END STUDENT CODE 53 | ;;;;;;;;;;;;;;;;;;;;;;;;;; -------------------------------------------------------------------------------- /labs/Lab9/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | extern "C" size_t first_func(void); 6 | extern "C" char* second_func(void*, char*); 7 | extern "C" size_t third_func(size_t); 8 | 9 | char str[] = "Super awesome test string.\0"; 10 | 11 | char* copystring(char* src, int len) 12 | { 13 | char* tmp = NULL; 14 | 15 | if(NULL == src || 0 == len) 16 | return NULL; 17 | 18 | if(NULL == (tmp = (char*)malloc(len + 1))) { 19 | printf("[x] Allocation failed!\n"); 20 | return tmp; 21 | } 22 | 23 | memset(tmp, 0x00, len+1); 24 | memcpy(tmp, src, len); 25 | 26 | return tmp; 27 | } 28 | 29 | #define EQ(x,y)\ 30 | do { if(x == y) printf("[*] Success! Values are equal!\n"); \ 31 | else printf("[x] Test Failed! Value %zu does not match value %zu!\n", x, y); } while(0) 32 | 33 | int main(int argc, char** argv) 34 | { 35 | char* tmp = NULL; 36 | 37 | printf("Calling first function (printf)\n"); 38 | first_func(); 39 | 40 | printf("Calling the second function (function pointer)\n"); 41 | if(NULL == (tmp = second_func((void*)copystring, str))) { 42 | printf("[x] Failed to copy string!\n"); 43 | return -1; 44 | } 45 | EQ((size_t)0, strcmp(tmp, str)); 46 | 47 | printf("Calling the third function (fibonacci)\n"); 48 | EQ((size_t)55, third_func(10)); 49 | 50 | return 0; 51 | } 52 | -------------------------------------------------------------------------------- /asm_slides/stylesheets: -------------------------------------------------------------------------------- 1 | /* 2 | Errno::ENOENT: No such file or directory - stylesheets/sass 3 | 4 | Backtrace: 5 | /Library/Ruby/Gems/2.0.0/gems/sass-3.4.21/lib/sass/plugin/compiler.rb:482:in `read' 6 | /Library/Ruby/Gems/2.0.0/gems/sass-3.4.21/lib/sass/plugin/compiler.rb:482:in `update_stylesheet' 7 | /Library/Ruby/Gems/2.0.0/gems/sass-3.4.21/lib/sass/plugin/compiler.rb:215:in `block in update_stylesheets' 8 | /Library/Ruby/Gems/2.0.0/gems/sass-3.4.21/lib/sass/plugin/compiler.rb:209:in `each' 9 | /Library/Ruby/Gems/2.0.0/gems/sass-3.4.21/lib/sass/plugin/compiler.rb:209:in `update_stylesheets' 10 | /Library/Ruby/Gems/2.0.0/gems/sass-3.4.21/lib/sass/plugin/compiler.rb:293:in `watch' 11 | /Library/Ruby/Gems/2.0.0/gems/sass-3.4.21/lib/sass/plugin.rb:109:in `method_missing' 12 | /Library/Ruby/Gems/2.0.0/gems/sass-3.4.21/lib/sass/exec/sass_scss.rb:383:in `watch_or_update' 13 | /Library/Ruby/Gems/2.0.0/gems/sass-3.4.21/lib/sass/exec/sass_scss.rb:51:in `process_result' 14 | /Library/Ruby/Gems/2.0.0/gems/sass-3.4.21/lib/sass/exec/base.rb:52:in `parse' 15 | /Library/Ruby/Gems/2.0.0/gems/sass-3.4.21/lib/sass/exec/base.rb:19:in `parse!' 16 | /Library/Ruby/Gems/2.0.0/gems/sass-3.4.21/bin/sass:13:in `' 17 | /usr/local/bin/sass:23:in `load' 18 | /usr/local/bin/sass:23:in `
' 19 | */ 20 | body:before { 21 | white-space: pre; 22 | font-family: monospace; 23 | content: "Errno::ENOENT: No such file or directory - stylesheets/sass"; } 24 | -------------------------------------------------------------------------------- /demos/Dirent/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | struct dirent { 7 | unsigned long d_ino; 8 | unsigned long d_off; 9 | unsigned short d_reclen; 10 | char d_name[]; 11 | }; 12 | 13 | extern int dent_me(int fd, struct dirent*, unsigned int size); 14 | extern size_t file_size(char*); 15 | extern int add_nums(int*, int); 16 | extern int add_2(int, int); 17 | extern int is_set(int); 18 | 19 | int stuff = 0; 20 | int main(int argc, char** argv, char** envp) 21 | { 22 | char buf[1024] = {0}; 23 | int num_read = 0; 24 | int current = 0; 25 | struct dirent* tmp = (struct dirent*)buf; 26 | int fd = open("/proc/self", O_RDONLY); 27 | num_read = dent_me(fd, tmp, sizeof(buf)); 28 | 29 | while(current < num_read) { 30 | fprintf(stdout, "%s\n", tmp->d_name); 31 | current += tmp->d_reclen; 32 | tmp = (struct dirent*)(buf + current); 33 | } 34 | 35 | close(fd); 36 | unsigned long s = file_size("/proc/self/environ"); 37 | printf("File Size: %lu\n", s); 38 | int a = 10; 39 | add_nums(&a, 20); 40 | printf("%d\n", a); 41 | printf("%d\n", add_2(10, 20)); 42 | char* out = (is_set(&stuff)) ? "Is set!\n" : "Isn't set!\n"; 43 | printf(out); 44 | out = (is_set(&stuff)) ? "Is set!\n" : "Isn't set!\n"; 45 | printf(out); 46 | return 0; 47 | } 48 | 49 | -------------------------------------------------------------------------------- /asm_slides/bourbon/css3/_columns.scss: -------------------------------------------------------------------------------- 1 | @mixin columns($arg: auto) { 2 | // || 3 | @include prefixer(columns, $arg, webkit moz spec); 4 | } 5 | 6 | @mixin column-count($int: auto) { 7 | // auto || integer 8 | @include prefixer(column-count, $int, webkit moz spec); 9 | } 10 | 11 | @mixin column-gap($length: normal) { 12 | // normal || length 13 | @include prefixer(column-gap, $length, webkit moz spec); 14 | } 15 | 16 | @mixin column-fill($arg: auto) { 17 | // auto || length 18 | @include prefixer(column-fill, $arg, webkit moz spec); 19 | } 20 | 21 | @mixin column-rule($arg) { 22 | // || || 23 | @include prefixer(column-rule, $arg, webkit moz spec); 24 | } 25 | 26 | @mixin column-rule-color($color) { 27 | @include prefixer(column-rule-color, $color, webkit moz spec); 28 | } 29 | 30 | @mixin column-rule-style($style: none) { 31 | // none | hidden | dashed | dotted | double | groove | inset | inset | outset | ridge | solid 32 | @include prefixer(column-rule-style, $style, webkit moz spec); 33 | } 34 | 35 | @mixin column-rule-width ($width: none) { 36 | @include prefixer(column-rule-width, $width, webkit moz spec); 37 | } 38 | 39 | @mixin column-span($arg: none) { 40 | // none || all 41 | @include prefixer(column-span, $arg, webkit moz spec); 42 | } 43 | 44 | @mixin column-width($length: auto) { 45 | // auto || length 46 | @include prefixer(column-width, $length, webkit moz spec); 47 | } 48 | -------------------------------------------------------------------------------- /asm_slides/bourbon/helpers/_str-to-num.scss: -------------------------------------------------------------------------------- 1 | //************************************************************************// 2 | // Helper function for linear/radial-gradient-parsers. 3 | // Source: http://sassmeister.com/gist/9647408 4 | //************************************************************************// 5 | @function _str-to-num($string) { 6 | // Matrices 7 | $strings: "0" "1" "2" "3" "4" "5" "6" "7" "8" "9"; 8 | $numbers: 0 1 2 3 4 5 6 7 8 9; 9 | 10 | // Result 11 | $result: 0; 12 | $divider: 0; 13 | $minus: false; 14 | 15 | // Looping through all characters 16 | @for $i from 1 through str-length($string) { 17 | $character: str-slice($string, $i, $i); 18 | $index: index($strings, $character); 19 | 20 | @if $character == "-" { 21 | $minus: true; 22 | } 23 | 24 | @else if $character == "." { 25 | $divider: 1; 26 | } 27 | 28 | @else { 29 | @if not $index { 30 | $result: if($minus, $result * -1, $result); 31 | @return _convert-units($result, str-slice($string, $i)); 32 | } 33 | 34 | $number: nth($numbers, $index); 35 | 36 | @if $divider == 0 { 37 | $result: $result * 10; 38 | } 39 | 40 | @else { 41 | // Move the decimal dot to the left 42 | $divider: $divider * 10; 43 | $number: $number / $divider; 44 | } 45 | 46 | $result: $result + $number; 47 | } 48 | } 49 | @return if($minus, $result * -1, $result); 50 | } 51 | -------------------------------------------------------------------------------- /asm_slides/bourbon/css3/_linear-gradient.scss: -------------------------------------------------------------------------------- 1 | @mixin linear-gradient($pos, $g1, $g2: null, 2 | $g3: null, $g4: null, 3 | $g5: null, $g6: null, 4 | $g7: null, $g8: null, 5 | $g9: null, $g10: null, 6 | $fallback: null) { 7 | // Detect what type of value exists in $pos 8 | $pos-type: type-of(nth($pos, 1)); 9 | $pos-spec: null; 10 | $pos-degree: null; 11 | 12 | // If $pos is missing from mixin, reassign vars and add default position 13 | @if ($pos-type == color) or (nth($pos, 1) == "transparent") { 14 | $g10: $g9; $g9: $g8; $g8: $g7; $g7: $g6; $g6: $g5; 15 | $g5: $g4; $g4: $g3; $g3: $g2; $g2: $g1; $g1: $pos; 16 | $pos: null; 17 | } 18 | 19 | @if $pos { 20 | $positions: _linear-positions-parser($pos); 21 | $pos-degree: nth($positions, 1); 22 | $pos-spec: nth($positions, 2); 23 | } 24 | 25 | $full: $g1, $g2, $g3, $g4, $g5, $g6, $g7, $g8, $g9, $g10; 26 | 27 | // Set $g1 as the default fallback color 28 | $fallback-color: nth($g1, 1); 29 | 30 | // If $fallback is a color use that color as the fallback color 31 | @if (type-of($fallback) == color) or ($fallback == "transparent") { 32 | $fallback-color: $fallback; 33 | } 34 | 35 | background-color: $fallback-color; 36 | background-image: -webkit-linear-gradient($pos-degree $full); // Safari 5.1+, Chrome 37 | background-image: unquote("linear-gradient(#{$pos-spec}#{$full})"); 38 | } 39 | -------------------------------------------------------------------------------- /labs/Lab8/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | extern "C" size_t first_func(char*, char, size_t); 6 | extern "C" size_t second_func(char*, char*, size_t); 7 | extern "C" size_t third_func(char*); 8 | 9 | #define BUFF_SIZE (size_t)256 10 | 11 | char buf[] = "Has anyone ever been as far as decided to look more like"; 12 | int values[] = { 10, 20, 30, 40, 50 }; 13 | 14 | #define EQ(x,y)\ 15 | do { if(x == y) printf("[*] Success! Values are equal!\n"); \ 16 | else printf("[x] Test Failed! Value %zu does not match value %zu!\n", x, y); } while(0) 17 | 18 | int main(int argc, char** argv) 19 | { 20 | { 21 | char buf1[BUFF_SIZE] = {0}; 22 | char buf2[BUFF_SIZE] = {0}; 23 | 24 | memset(buf1, 0x41, BUFF_SIZE); 25 | printf("Preparing to run first function (Initialize Memory)\n"); 26 | first_func(buf2, 0x41, BUFF_SIZE); 27 | EQ((size_t)0, memcmp(buf1, buf2, BUFF_SIZE)); 28 | } 29 | { 30 | char fbuf[BUFF_SIZE+1] = {0}; 31 | char sbuf[BUFF_SIZE+1] = {0}; 32 | 33 | memset(buf, 0x41, BUFF_SIZE); 34 | printf("Preparing to run second function (Copy memory)\n"); 35 | second_func(sbuf, fbuf, BUFF_SIZE); 36 | EQ((size_t)0, memcmp(fbuf, sbuf, BUFF_SIZE)); 37 | } 38 | { 39 | char strbuf[] = "abcdef1234"; 40 | printf("Preparing to run third function (String length)\n"); 41 | EQ((size_t)strlen(strbuf), third_func(strbuf)); 42 | } 43 | 44 | return 0; 45 | } 46 | -------------------------------------------------------------------------------- /asm_slides/bourbon/helpers/_radial-gradient-parser.scss: -------------------------------------------------------------------------------- 1 | @function _radial-gradient-parser($image) { 2 | $image: unquote($image); 3 | $gradients: (); 4 | $start: str-index($image, "("); 5 | $end: str-index($image, ","); 6 | $first-val: str-slice($image, $start + 1, $end - 1); 7 | 8 | $prefix: str-slice($image, 1, $start); 9 | $suffix: str-slice($image, $end, str-length($image)); 10 | 11 | $is-spec-syntax: str-index($first-val, "at"); 12 | 13 | @if $is-spec-syntax and $is-spec-syntax > 1 { 14 | $keyword: str-slice($first-val, 1, $is-spec-syntax - 2); 15 | $pos: str-slice($first-val, $is-spec-syntax + 3, str-length($first-val)); 16 | $pos: append($pos, $keyword, comma); 17 | 18 | $gradients: ( 19 | webkit-image: -webkit- + $prefix + $pos + $suffix, 20 | spec-image: $image 21 | ); 22 | } 23 | 24 | @else if $is-spec-syntax == 1 { 25 | $pos: str-slice($first-val, $is-spec-syntax + 3, str-length($first-val)); 26 | 27 | $gradients: ( 28 | webkit-image: -webkit- + $prefix + $pos + $suffix, 29 | spec-image: $image 30 | ); 31 | } 32 | 33 | @else if str-index($image, "cover") or str-index($image, "contain") { 34 | @warn "Radial-gradient needs to be updated to conform to latest spec."; 35 | 36 | $gradients: ( 37 | webkit-image: null, 38 | spec-image: $image 39 | ); 40 | } 41 | 42 | @else { 43 | $gradients: ( 44 | webkit-image: -webkit- + $image, 45 | spec-image: $image 46 | ); 47 | } 48 | 49 | @return $gradients; 50 | } 51 | -------------------------------------------------------------------------------- /labs/Solutions/Lab11_s2.nasm: -------------------------------------------------------------------------------- 1 | bits 64 2 | 3 | extern first_value 4 | global first_func, second_func, third_func 5 | global out1, out2 6 | 7 | section .data 8 | 9 | firstfloat dd 1.2345 10 | 11 | secondfloat dd 2.345 12 | 13 | out1 dd 0x00 14 | 15 | 16 | out2 dq 0x00 17 | 18 | tmp dq 0x00 19 | 20 | section .text 21 | 22 | first_func: 23 | push rbp 24 | mov rbp, rsp 25 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 26 | ; This problem will require 27 | ; you to load both firstfloat 28 | ; and secondfloat (above) onto 29 | ; the floating point stack, add 30 | ; them together, and store the 31 | ; result in out1. 32 | ; 33 | ; BEGIN student code 34 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 35 | mov rax, _firstfloat 36 | fld dword[rax] 37 | mov rax, _secondfloat 38 | fld dword[rax] 39 | fadd 40 | mov rax, _out1 41 | fstp dword[rax] 42 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 43 | ; END student code 44 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 45 | pop rbp 46 | ret 47 | 48 | second_func: 49 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 50 | ; This problem will require 51 | ; you to add the contents of 52 | ; _firstfloat to an integer 53 | ; that is passed in as the 54 | ; first (and only) argument 55 | ; to your function. Store the 56 | ; result at out2. 57 | ; 58 | ; BEGIN student code 59 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 60 | mov rax, _firstfloat 61 | fld dword[rax] 62 | fild rdi 63 | fiadd 64 | mov rax, _out2 65 | fstp qword[rax] 66 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 67 | ; END student code 68 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 69 | ret 70 | 71 | 72 | -------------------------------------------------------------------------------- /asm_slides/bourbon/css3/_background-image.scss: -------------------------------------------------------------------------------- 1 | //************************************************************************// 2 | // Background-image property for adding multiple background images with 3 | // gradients, or for stringing multiple gradients together. 4 | //************************************************************************// 5 | 6 | @mixin background-image($images...) { 7 | $webkit-images: (); 8 | $spec-images: (); 9 | 10 | @each $image in $images { 11 | $webkit-image: (); 12 | $spec-image: (); 13 | 14 | @if (type-of($image) == string) { 15 | $url-str: str-slice($image, 1, 3); 16 | $gradient-type: str-slice($image, 1, 6); 17 | 18 | @if $url-str == "url" { 19 | $webkit-image: $image; 20 | $spec-image: $image; 21 | } 22 | 23 | @else if $gradient-type == "linear" { 24 | $gradients: _linear-gradient-parser($image); 25 | $webkit-image: map-get($gradients, webkit-image); 26 | $spec-image: map-get($gradients, spec-image); 27 | } 28 | 29 | @else if $gradient-type == "radial" { 30 | $gradients: _radial-gradient-parser($image); 31 | $webkit-image: map-get($gradients, webkit-image); 32 | $spec-image: map-get($gradients, spec-image); 33 | } 34 | } 35 | 36 | $webkit-images: append($webkit-images, $webkit-image, comma); 37 | $spec-images: append($spec-images, $spec-image, comma); 38 | } 39 | 40 | background-image: $webkit-images; 41 | background-image: $spec-images; 42 | } 43 | -------------------------------------------------------------------------------- /labs/Lab4/Lab4.nasm: -------------------------------------------------------------------------------- 1 | bits 64 2 | 3 | extern value 4 | global first_func, second_func 5 | 6 | first_func: 7 | push rbp 8 | mov rbp, rsp 9 | mov rcx, 0x10 10 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 11 | ; For this task, you must allocate 12 | ; 8 bytes of space on the stack, and 13 | ; store the value of rcx there. 14 | ; 15 | ; BEGIN student code 16 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 17 | 18 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 19 | ; END student code 20 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 21 | pop rax 22 | pop rbp 23 | ret 24 | 25 | second_func 26 | push rbp 27 | mov rbp, rsp 28 | mov rcx, value 29 | mov rax, 1 30 | mov rdx, 2 31 | mov rsi, 3 32 | mov rdi, 4 33 | mov r8, 5 34 | mov r9, 6 35 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 36 | ; For this task, you must allocate 37 | ; space to 38 | ; manage your registers and save them 39 | ; to the stack as needed. Divide the 40 | ; number stored where rcx points by 10, 41 | ; and place the value back at that address. 42 | ; Make sure all the register values are the 43 | ; same at the end of the call! 44 | ; 45 | ; BEGIN student code 46 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 47 | 48 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 49 | ; END student code 50 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 51 | cmp rax, 1 52 | jnz .fail 53 | cmp rdx, 2 54 | jnz .fail 55 | cmp rsi, 3 56 | jnz .fail 57 | cmp rdi, 4 58 | jnz .fail 59 | cmp r8, 5 60 | jnz .fail 61 | cmp r9, 6 62 | jnz .fail 63 | jmp .end 64 | .fail: 65 | mov rax, -1 66 | .end: 67 | pop rbp 68 | ret 69 | -------------------------------------------------------------------------------- /asm_slides/bourbon/css3/_radial-gradient.scss: -------------------------------------------------------------------------------- 1 | // Requires Sass 3.1+ 2 | @mixin radial-gradient($g1, $g2, 3 | $g3: null, $g4: null, 4 | $g5: null, $g6: null, 5 | $g7: null, $g8: null, 6 | $g9: null, $g10: null, 7 | $pos: null, 8 | $shape-size: null, 9 | $fallback: null) { 10 | 11 | $data: _radial-arg-parser($g1, $g2, $pos, $shape-size); 12 | $g1: nth($data, 1); 13 | $g2: nth($data, 2); 14 | $pos: nth($data, 3); 15 | $shape-size: nth($data, 4); 16 | 17 | $full: $g1, $g2, $g3, $g4, $g5, $g6, $g7, $g8, $g9, $g10; 18 | 19 | // Strip deprecated cover/contain for spec 20 | $shape-size-spec: _shape-size-stripper($shape-size); 21 | 22 | // Set $g1 as the default fallback color 23 | $first-color: nth($full, 1); 24 | $fallback-color: nth($first-color, 1); 25 | 26 | @if (type-of($fallback) == color) or ($fallback == "transparent") { 27 | $fallback-color: $fallback; 28 | } 29 | 30 | // Add Commas and spaces 31 | $shape-size: if($shape-size, "#{$shape-size}, ", null); 32 | $pos: if($pos, "#{$pos}, ", null); 33 | $pos-spec: if($pos, "at #{$pos}", null); 34 | $shape-size-spec: if(($shape-size-spec != " ") and ($pos == null), "#{$shape-size-spec}, ", "#{$shape-size-spec} "); 35 | 36 | background-color: $fallback-color; 37 | background-image: -webkit-radial-gradient(unquote(#{$pos}#{$shape-size}#{$full})); 38 | background-image: unquote("radial-gradient(#{$shape-size-spec}#{$pos-spec}#{$full})"); 39 | } 40 | -------------------------------------------------------------------------------- /labs/Lab12/Lab12.nasm: -------------------------------------------------------------------------------- 1 | bits 64 2 | 3 | global first_func, second_func, third_func 4 | 5 | _firstdata dd 0x00 6 | _seconddata dd 0x00 7 | 8 | first_func: 9 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 10 | ; This problem will require 11 | ; adding two vectors of numbers. 12 | ; A pointer to two unaligned 13 | ; vectors of 32-bit integers 14 | ; have been passed as the first 15 | ; two parameters to your function, 16 | ; and a pointer to an empty 17 | ; vector has been provided to store 18 | ; the result. 19 | ; 20 | ; BEGIN student code 21 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 22 | 23 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 24 | ; END student code 25 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 26 | ret 27 | 28 | second_func: 29 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 30 | ; This problem will require 31 | ; you to compare the values 32 | ; stored in the vector pointed 33 | ; to by parameter 1 with the 34 | ; values stored in the vector 35 | ; pointed to by parameter 2. 36 | ; Store the results of the 37 | ; comparison in the vector 38 | ; pointed to by parameter 3. 39 | ; 40 | ; BEGIN student code 41 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 42 | 43 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 44 | ; END student code 45 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 46 | ret 47 | 48 | third_func: 49 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 50 | ; Given two scalar values, passed 51 | ; in as two parameters, find the max 52 | ; of the two, and return it as your 53 | ; result. 54 | ; 55 | ; BEGIN student code 56 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 57 | 58 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 59 | ; END student code 60 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 61 | ret -------------------------------------------------------------------------------- /labs/Lab1/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | extern "C" size_t first_func(void); 5 | extern "C" size_t second_func(void); 6 | extern "C" void third_func(void); 7 | extern "C" size_t fourth_func(void); 8 | extern "C" size_t fifth_func(void); 9 | extern "C" void sixth_func(void); 10 | 11 | #define EQ(x,y)\ 12 | do { if(x == y) printf("[*] Success! Values are equal!\n"); \ 13 | else printf("[x] Test Failed! Value %zu does not match value %zu!\n", x, y); } while(0) 14 | 15 | extern "C" size_t value = 0; 16 | extern "C" size_t buf[] = {10,20,30,40}; 17 | 18 | extern "C" size_t val1 = 10; 19 | extern "C" size_t val2 = 40; 20 | 21 | int main(int argc, char** argv) 22 | { 23 | printf("Preparing to run the first test (moving a value to a register)\n"); 24 | EQ(first_func(), (size_t)16); 25 | 26 | printf("Preparing to run the second test (moving the contents of one register into another)\n"); 27 | EQ(second_func(), (size_t)32); 28 | 29 | printf("Preparing to run the third test (moving a value from a register to memory)\n"); 30 | third_func(); 31 | EQ(value, (size_t)16); 32 | 33 | value = 255; 34 | printf("Preparing to run the fourth test (moving a value from memory into a register)\n"); 35 | EQ((size_t)255, fourth_func()); 36 | 37 | printf("Preparing to run the fifth test (using lea to calculate the next item in a list)\n"); 38 | EQ(buf[1], fifth_func()); 39 | 40 | printf("Preparing to run the sixth test (using xchg to swap two array values)\n"); 41 | sixth_func(); 42 | EQ((size_t)10, val2); 43 | EQ((size_t)40, val1); 44 | return 0; 45 | } 46 | -------------------------------------------------------------------------------- /labs/Solutions/Lab11.nasm: -------------------------------------------------------------------------------- 1 | bits 64 2 | 3 | extern _first_value 4 | global _first_func, _second_func, _third_func 5 | global _out, _out2 6 | 7 | section .data 8 | 9 | _firstfloat dd 1.2345 10 | _secondfloat dd 2.345 11 | _out dd 0x0 12 | 13 | _out2 dq 0x0 14 | _tmp dq 0x0 15 | 16 | section .text 17 | 18 | _first_func: 19 | push rbp 20 | mov rbp, rsp 21 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 22 | ; This problem will require 23 | ; you to load both _firstfloat 24 | ; and _secondfloat (above) onto 25 | ; the floating point stack, add 26 | ; them together, and store the 27 | ; result in _out. 28 | ; 29 | ; BEGIN student code 30 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 31 | mov rax, _firstfloat 32 | fld dword [rax] 33 | mov rax, _secondfloat 34 | fld dword [rax] 35 | fadd 36 | mov rax, _out 37 | fstp dword [rax] 38 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 39 | ; END student code 40 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 41 | pop rbp 42 | ret 43 | 44 | _second_func: 45 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 46 | ; This problem will require 47 | ; you to add the contents of 48 | ; _firstfloat to an integer 49 | ; that is passed in as the 50 | ; first (and only) argument 51 | ; to your function. Store the 52 | ; result at _out2. 53 | ; 54 | ; BEGIN student code 55 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 56 | mov rax, _firstfloat 57 | fld dword [rax] 58 | mov rax, _tmp 59 | mov qword [rax], rdi 60 | fiadd dword [rax] 61 | mov rax, _out2 62 | fstp qword [rax] 63 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 64 | ; END student code 65 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 66 | ret 67 | 68 | 69 | -------------------------------------------------------------------------------- /labs/Lab9/Lab9.nasm: -------------------------------------------------------------------------------- 1 | bits 64 2 | 3 | global first_func, second_func, third_func 4 | 5 | extern printf 6 | mystr db "Success!", 0xa, 0x00 7 | 8 | first_func: 9 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 10 | ; The function printf has been 11 | ; externed in (above). Call it, 12 | ; passing mystr (also defined 13 | ; above), as its only argument. 14 | ; 15 | ; BEGIN student code 16 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 17 | 18 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 19 | ; END student code 20 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 21 | ret 22 | 23 | extern strlen 24 | 25 | second_func: 26 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 27 | ; Your function will be called 28 | ; with two arguments: a function 29 | ; pointer (the first parameter), 30 | ; and a string (the second). The 31 | ; function pointer takes two 32 | ; arguments: a string, and a length. 33 | ; You will need to call strlen 34 | ; (above), passing in the string, 35 | ; and pass the results to the 36 | ; function pointer (along with the 37 | ; string). Return the string you get 38 | ; back from the function. 39 | ; 40 | ; BEGIN student code 41 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 42 | 43 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 44 | ; END student code 45 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 46 | ret 47 | 48 | third_func: 49 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 50 | ; Calculate the Nth fibonacci 51 | ; number (where N is the value 52 | ; passed to your method as the 53 | ; only parameter). 54 | ; 55 | ; BEGIN student code 56 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 57 | 58 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 59 | ; END student code 60 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 61 | ret 62 | 63 | 64 | -------------------------------------------------------------------------------- /labs/Lab12/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | extern "C" size_t first_func(int*, int*, int*); 7 | extern "C" size_t second_func(int*, int*, int*); 8 | extern "C" int third_func(int, int); 9 | 10 | #define EQ(x,y)\ 11 | do { if(x == y) printf("[*] Success! Values are equal!\n"); \ 12 | else printf("[x] Test Failed! Value %d does not match value %d!\n", x, y); } while(0) 13 | 14 | void first_test() 15 | { 16 | int vals[] = {10, 20, 30, 40}; 17 | int vals2[] = {20, 30 , 40, 50}; 18 | int out[4] = {0}; 19 | int exp[] = {30, 50, 70, 90}; 20 | 21 | printf("Preparing to run first_func (Add two vectors)\n"); 22 | first_func(vals, vals2, out); 23 | printf("Result: %d, %d, %d, %d\n", out[0], out[1], out[2], out[3]); 24 | EQ(0, memcmp(out, exp, sizeof(out))); 25 | } 26 | 27 | void second_test() 28 | { 29 | int v1[] = {10, 30, 40, 70}; 30 | int v2[] = {10, 20, 40, 20}; 31 | int out[4] = {0}; 32 | 33 | printf("Preparing to run second_func (Compare vectors)\n"); 34 | second_func(v1, v2, out); 35 | printf("%d, %d, %d, %d\n", out[0], out[1], out[2], out[3]); 36 | EQ(out[0], -1); 37 | EQ(out[1], 0); 38 | EQ(out[2], -1); 39 | EQ(out[3], 0); 40 | } 41 | 42 | void third_test() 43 | { 44 | int x = 10; 45 | int y = 42; 46 | int res = third_func(x, y); 47 | printf("%d\n", res); 48 | EQ(y, res); 49 | 50 | x = 32; 51 | y = 21; 52 | res = third_func(x, y); 53 | EQ(x, res); 54 | } 55 | 56 | int main(int argc, char** argv) 57 | { 58 | 59 | first_test(); 60 | second_test(); 61 | third_test(); 62 | return 0; 63 | } 64 | -------------------------------------------------------------------------------- /asm_slides/bourbon/css3/_animation.scss: -------------------------------------------------------------------------------- 1 | // http://www.w3.org/TR/css3-animations/#the-animation-name-property- 2 | // Each of these mixins support comma separated lists of values, which allows different transitions for individual properties to be described in a single style rule. Each value in the list corresponds to the value at that same position in the other properties. 3 | 4 | @mixin animation($animations...) { 5 | @include prefixer(animation, $animations, webkit moz spec); 6 | } 7 | 8 | @mixin animation-name($names...) { 9 | @include prefixer(animation-name, $names, webkit moz spec); 10 | } 11 | 12 | @mixin animation-duration($times...) { 13 | @include prefixer(animation-duration, $times, webkit moz spec); 14 | } 15 | 16 | @mixin animation-timing-function($motions...) { 17 | // ease | linear | ease-in | ease-out | ease-in-out 18 | @include prefixer(animation-timing-function, $motions, webkit moz spec); 19 | } 20 | 21 | @mixin animation-iteration-count($values...) { 22 | // infinite | 23 | @include prefixer(animation-iteration-count, $values, webkit moz spec); 24 | } 25 | 26 | @mixin animation-direction($directions...) { 27 | // normal | alternate 28 | @include prefixer(animation-direction, $directions, webkit moz spec); 29 | } 30 | 31 | @mixin animation-play-state($states...) { 32 | // running | paused 33 | @include prefixer(animation-play-state, $states, webkit moz spec); 34 | } 35 | 36 | @mixin animation-delay($times...) { 37 | @include prefixer(animation-delay, $times, webkit moz spec); 38 | } 39 | 40 | @mixin animation-fill-mode($modes...) { 41 | // none | forwards | backwards | both 42 | @include prefixer(animation-fill-mode, $modes, webkit moz spec); 43 | } 44 | -------------------------------------------------------------------------------- /labs/Lab7/Lab7.nasm: -------------------------------------------------------------------------------- 1 | bits 64 2 | 3 | global first_func, second_func, third_func 4 | 5 | first_func: 6 | push rbp 7 | mov rbp, rsp 8 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 9 | ; Two values have been provided, 10 | ; with the first stored in RDI, 11 | ; and the second in RSI. If the 12 | ; first is greater than the second, 13 | ; set RAX equal to 1, if the second 14 | ; is greater than the first, set 15 | ; RAX equal to -1. If they are 16 | ; both equal, set RAX to 0. 17 | ; 18 | ; BEGIN student code 19 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 20 | 21 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 22 | ; END student code 23 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 24 | pop rbp 25 | ret 26 | 27 | second_func: 28 | push rbp 29 | mov rbp, rsp 30 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 31 | ; You have been provided with 32 | ; a pointer to the start of an 33 | ; array of numbers in RDI, and 34 | ; the number of elements in the 35 | ; array in RSI. Loop through the 36 | ; array, adding all the numbers 37 | ; together, and store the result 38 | ; in RAX. 39 | ; 40 | ; BEGIN student code 41 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 42 | 43 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 44 | ; END student code 45 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 46 | pop rbp 47 | ret 48 | 49 | third_func: 50 | push rbp 51 | mov rbp, rsp 52 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 53 | ; Find the length of the 54 | ; provided, NULL-terminated 55 | ; string (a pointer to the 56 | ; beginning of which is 57 | ; currently stored in RDI), 58 | ; and store the result in RAX. 59 | ; 60 | ; BEGIN student code 61 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 62 | 63 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 64 | ; END student code 65 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 66 | pop rbp 67 | ret 68 | 69 | 70 | -------------------------------------------------------------------------------- /demos/debug_demo/pure_c/src/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | /** 6 | * open_file: Opens a file. 7 | * @param fname: the file name to open. 8 | * @param fptr: The output parameter for 9 | * out file pointer. 10 | */ 11 | int open_file(char* fname, FILE** fptr) 12 | { 13 | FILE* ftmp = NULL; 14 | 15 | if(NULL == fname || NULL == fptr) 16 | return -1; 17 | 18 | if(NULL == (ftmp = fopen(fname, "w"))) { 19 | fprintf(stdout, "File open failed! %s\n", strerror(errno)); 20 | return errno; 21 | } 22 | 23 | *fptr = ftmp; 24 | return 0; 25 | } 26 | 27 | /** 28 | * print_env: Prints a list of strings to a file handle. 29 | * @param fh: The file handle to write output into. 30 | * @param envp: A pointer to a NULL-terminated list of pointers. 31 | * @returns int: A value indicating success. 32 | */ 33 | int print_env(FILE* fh, char** envp) 34 | { 35 | if (NULL == envp || NULL == *envp || NULL == fh) 36 | return -1; 37 | 38 | for(int i = 0; NULL != envp[i]; ++i) { 39 | fprintf(fh, "Printing ENV val %d: %s\n", i, envp[i]); 40 | } 41 | 42 | return 0; 43 | } 44 | 45 | int main(int argc, char** argv, char** envp) 46 | { 47 | int value = 0; 48 | FILE* fh = NULL; 49 | 50 | if((value = print_env(stdout, envp))) { 51 | printf("Failed to print env!\n"); 52 | return value; 53 | } 54 | 55 | if((value = open_file("test.txt", &fh))) { 56 | printf("Failed to open file!\n"); 57 | return value; 58 | } 59 | 60 | if((value = print_env(fh, envp))) { 61 | printf("Failed to write env to file!\n"); 62 | goto cleanup; 63 | } 64 | 65 | cleanup: 66 | fclose(fh); 67 | return value; 68 | } 69 | -------------------------------------------------------------------------------- /asm_slides/.sass-cache/2a8f65206aa6ecb0bc1c1ba1bcb99e5ee2d1cc96/_backface-visibility.scssc: -------------------------------------------------------------------------------- 1 | 3.4.21 (Selective Steve) 2 | 7587d5653fa2b48af9371d2b63a2a666ac6ac928 3 | o:Sass::Tree::RootNode :@children[o:Sass::Tree::MixinDefNode : 4 | @nameI"backface-visibility:ET: 5 | @args[[o:!Sass::Script::Tree::Variable ;I"visibility; T:@underscored_nameI"visibility; T: 6 | @linei:@source_rangeo:Sass::Source::Range :@start_poso:Sass::Source::Position; i: @offseti!: @end_poso;; i;i,: 7 | @fileI"+bourbon/css3/_backface-visibility.scss; T:@importero: Sass::Importers::Filesystem: 8 | @rootI"//Users/aaron/Documents/projects/asm_slides; T:@real_rootI"//Users/aaron/Documents/projects/asm_slides; T:@same_name_warningso:Set: 9 | @hash{:@filename@: @options{0: @splat0;[o:Sass::Tree::MixinNode;I" prefixer; T; 10 | [o: Sass::Script::Tree::Literal : @valueo: Sass::Script::Value::String ;!I"backface-visibility; T: 11 | @type:identifier:"@deprecated_interp_equivalent0;@; i;o; ;o;; i;i;o;; i;i-;@;@;@o; ;I"visibility; T; I"visibility; T; i;o; ;o;; i;i/;o;; i;i:;@;@;@;@o:$Sass::Script::Tree::ListLiteral :@elements[o; ;!o;" ;!I" webkit; T;#;$;%0;@; i;o; ;o;; i;i<;o;; i;iB;@;@;@o; ;!o;" ;!I" spec; T;#;$;%0;@; i;o; ;o;; i;iC;o;; i;iG;@;@;@:@separator: 12 | space; i;o; ;o;; i;i;;o;; i;iG;@;@;@;@:@keywordso:Sass::Util::NormalizedMap:@key_strings{: @map{;0:@kwarg_splat0;[; i;o; ;o;; i;i;o;; i;iH;@;@;@; i;o; ;o;; i;i;o;; i;i.;@;@:@has_childrenT;@:@templateI"u@mixin backface-visibility($visibility) { 13 | @include prefixer(backface-visibility, $visibility, webkit spec); 14 | } 15 | ; T;/T;@; i;o; ;o;; i;i;o;; i;i;@;@ -------------------------------------------------------------------------------- /demos/syscall_demos/threads_demo/src/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | extern pid_t create_thread(void*, void* stack, size_t size); 10 | 11 | #define NUM_THREADS 5 12 | #define STACK_SIZE ((size_t)4096) 13 | #define LOGFILE "tmp.txt" 14 | 15 | void print_stuff(void) 16 | { 17 | for(int i=0; i < 20; ++i) { 18 | printf("Current Iteration: %d\n", i); 19 | sleep(1); 20 | } 21 | } 22 | 23 | int main(int argc, char** argv, char** envp) 24 | { 25 | char buf[2048] = {0}; 26 | FILE* fh = NULL; 27 | FILE* outf = NULL; 28 | void* segs[NUM_THREADS] = {0}; 29 | 30 | for(int i = 0; i < NUM_THREADS; ++i) { 31 | if(NULL == (segs[i] = mmap(NULL, STACK_SIZE, 32 | PROT_READ | PROT_WRITE, 33 | MAP_PRIVATE | MAP_ANON | MAP_GROWSDOWN, 34 | 0, 0))) 35 | { 36 | printf("[x] Failed to allocate stack memory!"); 37 | return -1; 38 | } 39 | } 40 | 41 | for(int i = 0; i < NUM_THREADS; ++i) 42 | create_thread((void*)print_stuff, segs[i], STACK_SIZE); 43 | 44 | if(NULL == (fh = fopen("/proc/self/status", "r"))) { 45 | printf("Failed to open proc!\n"); 46 | goto Skip; 47 | } 48 | 49 | fread(buf, 2047, 2047, fh); 50 | if(NULL != (outf = fopen(LOGFILE, "w"))) { 51 | fprintf(outf, "Process Information:\n%s", buf); 52 | fclose(outf); 53 | } 54 | fclose(fh); 55 | Skip: 56 | getchar(); 57 | 58 | // Cleanup 59 | for(int i = 0; i < NUM_THREADS; ++i) 60 | munmap(segs[i], STACK_SIZE); 61 | 62 | return 0; 63 | } 64 | -------------------------------------------------------------------------------- /labs/Lab8/Lab8.nasm: -------------------------------------------------------------------------------- 1 | bits 64 2 | 3 | global first_func, second_func, third_func 4 | 5 | first_func: 6 | push rbp 7 | mov rbp, rsp 8 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 9 | ; Two values have been provided, 10 | ; a value (consisting of a single 11 | ; byte), which is stored in RSI, 12 | ; a buffer to initialize, a 13 | ; pointer to which is in RDI, 14 | ; and a number of bytes to set, 15 | ; which is stored in RCX. 16 | ; Implement a function that will 17 | ; set the buffer pointed to by RDI 18 | ; to the value stored in RSI. 19 | ; 20 | ; BEGIN student code 21 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 22 | 23 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 24 | ; END student code 25 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 26 | pop rbp 27 | ret 28 | 29 | second_func: 30 | push rbp 31 | mov rbp, rsp 32 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 33 | ; You have been provided with 34 | ; pointers to two buffers, one 35 | ; being the "source" (in RSI), 36 | ; and the other, in RDI, being 37 | ; the destination. Copy the values 38 | ; from source to destination. 39 | ; The size of both buffers is 40 | ; stored in RCX. 41 | ; 42 | ; BEGIN student code 43 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 44 | 45 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 46 | ; END student code 47 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 48 | pop rbp 49 | ret 50 | 51 | third_func: 52 | push rbp 53 | mov rbp, rsp 54 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 55 | ; Find the length of the 56 | ; provided, NULL-terminated 57 | ; string (a pointer to the 58 | ; beginning of which is 59 | ; currently stored in RDI), 60 | ; and store the result in RAX, 61 | ; using only string instructions. 62 | ; 63 | ; BEGIN student code 64 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 65 | 66 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 67 | ; END student code 68 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 69 | pop rbp 70 | ret 71 | 72 | 73 | -------------------------------------------------------------------------------- /labs/Solutions/WinLabsWeek2_Solutions/tuesday.nasm: -------------------------------------------------------------------------------- 1 | bits 32 2 | 3 | global _copy_string, _get_cpu_string@4, _set_flags 4 | 5 | section .text 6 | 7 | 8 | _copy_string: 9 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 10 | ; 11 | ; This method takes 3 params: 12 | ; 13 | ; Param 1: An empty buffer 14 | ; 15 | ; Param 2: A NULL-terminated string 16 | ; 17 | ; Given these two inputs, 18 | ; 1.) Find the length of the string provided in 19 | ; param 2 20 | ; 2.) Copy the string from param 2, to the empty buffer 21 | ; provided in param 1. 22 | ; 23 | ; void __cdecl copy_string(char* dest, char* src); 24 | ; 25 | ; BEGIN STUDENT CODE 26 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 27 | push ebp 28 | mov ebp, esp 29 | push edi 30 | push esi 31 | mov edi, [ebp + 12] 32 | mov ecx, -1 33 | xor eax, eax 34 | repne scasb 35 | not ecx 36 | mov edi, [ebp + 12] 37 | mov esi, [ebp + 8] 38 | rep movsb 39 | pop esi 40 | pop edi 41 | pop ebp 42 | ret 43 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 44 | ; END STUDENT CODE 45 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 46 | 47 | _get_cpu_string@4: 48 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 49 | ; 50 | ; This function takes 1 param: 51 | ; 52 | ; Param 1: A zero'd character buffer, containing 53 | ; 13 elements. 54 | ; 55 | ; The following steps must be performed: 56 | ; 1.) Call CPUID and get the vendor string 57 | ; 2.) Copy from ASCII bytes returned into the buffer 58 | ; provided. 59 | ; 60 | ; void __stdcall get_cpu_string(char* buf); 61 | ; 62 | ; 63 | ; BEGIN STUDENT CODE 64 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 65 | xor eax, eax 66 | mov ecx, [esp + 4] 67 | push edi 68 | mov edi, ecx 69 | cpuid 70 | push ecx 71 | mov eax, ebx 72 | stosd 73 | mov eax, edx 74 | stosd 75 | pop eax 76 | stosd 77 | pop edi 78 | ret 4 79 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 80 | ; END STUDENT CODE 81 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 82 | 83 | 84 | -------------------------------------------------------------------------------- /labs/Lab3/Lab3.nasm: -------------------------------------------------------------------------------- 1 | bits 64 2 | 3 | global first_func, second_func, third_func, fourth_func, fifth_func 4 | 5 | 6 | first_func: 7 | mov rax, 10 8 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 9 | ; For this test, you will 10 | ; need to add 10 to the 11 | ; value stored in rax. 12 | ; 13 | ; BEGIN student code 14 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 15 | 16 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 17 | ; END student code 18 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 19 | ret 20 | 21 | second_func: 22 | mov rax, 30 23 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 24 | ; For this test you will 25 | ; need to subtract 20 26 | ; from the value in rax. 27 | ; 28 | ; BEGIN student code 29 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 30 | 31 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 32 | ; END student code 33 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 34 | ret 35 | 36 | 37 | 38 | third_func: 39 | mov rax, 10 40 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 41 | ; For this lab, you will 42 | ; need to multiply rax by 43 | ; 10. 44 | ; 45 | ; BEGIN student code 46 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 47 | 48 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 49 | ; END student code 50 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 51 | ret 52 | 53 | fourth_func: 54 | mov rax, 10 55 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 56 | ; For this lab, you will 57 | ; need to divide by 2, 58 | ; and return the quotient. 59 | ; hint: make sure you clear 60 | ; the high bits! 61 | ; 62 | ; BEGIN student code 63 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 64 | 65 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 66 | ; END student code 67 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 68 | ret 69 | 70 | fifth_func: 71 | mov rax, 7 72 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 73 | ; For this lab, you will 74 | ; be required to divide 75 | ; by 2, and move the 76 | ; remainder into rax. 77 | ; hint: make sure you 78 | ; clear the high bits! 79 | ; 80 | ; BEGIN student code 81 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 82 | 83 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 84 | ; END student code 85 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 86 | ret 87 | -------------------------------------------------------------------------------- /asm_slides/bourbon/addons/_timing-functions.scss: -------------------------------------------------------------------------------- 1 | @charset "UTF-8"; 2 | 3 | /// CSS cubic-bezier timing functions. Timing functions courtesy of jquery.easie (github.com/jaukia/easie) 4 | /// 5 | /// Timing functions are the same as demoed here: http://jqueryui.com/resources/demos/effect/easing.html 6 | /// 7 | /// @type cubic-bezier 8 | 9 | $ease-in-quad: cubic-bezier(0.550, 0.085, 0.680, 0.530); 10 | $ease-in-cubic: cubic-bezier(0.550, 0.055, 0.675, 0.190); 11 | $ease-in-quart: cubic-bezier(0.895, 0.030, 0.685, 0.220); 12 | $ease-in-quint: cubic-bezier(0.755, 0.050, 0.855, 0.060); 13 | $ease-in-sine: cubic-bezier(0.470, 0.000, 0.745, 0.715); 14 | $ease-in-expo: cubic-bezier(0.950, 0.050, 0.795, 0.035); 15 | $ease-in-circ: cubic-bezier(0.600, 0.040, 0.980, 0.335); 16 | $ease-in-back: cubic-bezier(0.600, -0.280, 0.735, 0.045); 17 | 18 | $ease-out-quad: cubic-bezier(0.250, 0.460, 0.450, 0.940); 19 | $ease-out-cubic: cubic-bezier(0.215, 0.610, 0.355, 1.000); 20 | $ease-out-quart: cubic-bezier(0.165, 0.840, 0.440, 1.000); 21 | $ease-out-quint: cubic-bezier(0.230, 1.000, 0.320, 1.000); 22 | $ease-out-sine: cubic-bezier(0.390, 0.575, 0.565, 1.000); 23 | $ease-out-expo: cubic-bezier(0.190, 1.000, 0.220, 1.000); 24 | $ease-out-circ: cubic-bezier(0.075, 0.820, 0.165, 1.000); 25 | $ease-out-back: cubic-bezier(0.175, 0.885, 0.320, 1.275); 26 | 27 | $ease-in-out-quad: cubic-bezier(0.455, 0.030, 0.515, 0.955); 28 | $ease-in-out-cubic: cubic-bezier(0.645, 0.045, 0.355, 1.000); 29 | $ease-in-out-quart: cubic-bezier(0.770, 0.000, 0.175, 1.000); 30 | $ease-in-out-quint: cubic-bezier(0.860, 0.000, 0.070, 1.000); 31 | $ease-in-out-sine: cubic-bezier(0.445, 0.050, 0.550, 0.950); 32 | $ease-in-out-expo: cubic-bezier(1.000, 0.000, 0.000, 1.000); 33 | $ease-in-out-circ: cubic-bezier(0.785, 0.135, 0.150, 0.860); 34 | $ease-in-out-back: cubic-bezier(0.680, -0.550, 0.265, 1.550); 35 | -------------------------------------------------------------------------------- /asm_slides/bourbon/functions/_modular-scale.scss: -------------------------------------------------------------------------------- 1 | // Scaling Variables 2 | $golden: 1.618; 3 | $minor-second: 1.067; 4 | $major-second: 1.125; 5 | $minor-third: 1.2; 6 | $major-third: 1.25; 7 | $perfect-fourth: 1.333; 8 | $augmented-fourth: 1.414; 9 | $perfect-fifth: 1.5; 10 | $minor-sixth: 1.6; 11 | $major-sixth: 1.667; 12 | $minor-seventh: 1.778; 13 | $major-seventh: 1.875; 14 | $octave: 2; 15 | $major-tenth: 2.5; 16 | $major-eleventh: 2.667; 17 | $major-twelfth: 3; 18 | $double-octave: 4; 19 | 20 | $modular-scale-ratio: $perfect-fourth !default; 21 | $modular-scale-base: em($em-base) !default; 22 | 23 | @function modular-scale($increment, $value: $modular-scale-base, $ratio: $modular-scale-ratio) { 24 | $v1: nth($value, 1); 25 | $v2: nth($value, length($value)); 26 | $value: $v1; 27 | 28 | // scale $v2 to just above $v1 29 | @while $v2 > $v1 { 30 | $v2: ($v2 / $ratio); // will be off-by-1 31 | } 32 | @while $v2 < $v1 { 33 | $v2: ($v2 * $ratio); // will fix off-by-1 34 | } 35 | 36 | // check AFTER scaling $v2 to prevent double-counting corner-case 37 | $double-stranded: $v2 > $v1; 38 | 39 | @if $increment > 0 { 40 | @for $i from 1 through $increment { 41 | @if $double-stranded and ($v1 * $ratio) > $v2 { 42 | $value: $v2; 43 | $v2: ($v2 * $ratio); 44 | } @else { 45 | $v1: ($v1 * $ratio); 46 | $value: $v1; 47 | } 48 | } 49 | } 50 | 51 | @if $increment < 0 { 52 | // adjust $v2 to just below $v1 53 | @if $double-stranded { 54 | $v2: ($v2 / $ratio); 55 | } 56 | 57 | @for $i from $increment through -1 { 58 | @if $double-stranded and ($v1 / $ratio) < $v2 { 59 | $value: $v2; 60 | $v2: ($v2 / $ratio); 61 | } @else { 62 | $v1: ($v1 / $ratio); 63 | $value: $v1; 64 | } 65 | } 66 | } 67 | 68 | @return $value; 69 | } 70 | -------------------------------------------------------------------------------- /asm_slides/bourbon/addons/_prefixer.scss: -------------------------------------------------------------------------------- 1 | @charset "UTF-8"; 2 | 3 | /// A mixin for generating vendor prefixes on non-standardized properties. 4 | /// 5 | /// @param {String} $property 6 | /// Property to prefix 7 | /// 8 | /// @param {*} $value 9 | /// Value to use 10 | /// 11 | /// @param {List} $prefixes 12 | /// Prefixes to define 13 | /// 14 | /// @example scss - Usage 15 | /// .element { 16 | /// @include prefixer(border-radius, 10px, webkit ms spec); 17 | /// } 18 | /// 19 | /// @example css - CSS Output 20 | /// .element { 21 | /// -webkit-border-radius: 10px; 22 | /// -moz-border-radius: 10px; 23 | /// border-radius: 10px; 24 | /// } 25 | /// 26 | /// @require {variable} $prefix-for-webkit 27 | /// @require {variable} $prefix-for-mozilla 28 | /// @require {variable} $prefix-for-microsoft 29 | /// @require {variable} $prefix-for-opera 30 | /// @require {variable} $prefix-for-spec 31 | 32 | @mixin prefixer($property, $value, $prefixes) { 33 | @each $prefix in $prefixes { 34 | @if $prefix == webkit { 35 | @if $prefix-for-webkit { 36 | -webkit-#{$property}: $value; 37 | } 38 | } @else if $prefix == moz { 39 | @if $prefix-for-mozilla { 40 | -moz-#{$property}: $value; 41 | } 42 | } @else if $prefix == ms { 43 | @if $prefix-for-microsoft { 44 | -ms-#{$property}: $value; 45 | } 46 | } @else if $prefix == o { 47 | @if $prefix-for-opera { 48 | -o-#{$property}: $value; 49 | } 50 | } @else if $prefix == spec { 51 | @if $prefix-for-spec { 52 | #{$property}: $value; 53 | } 54 | } @else { 55 | @warn "Unrecognized prefix: #{$prefix}"; 56 | } 57 | } 58 | } 59 | 60 | @mixin disable-prefix-for-all() { 61 | $prefix-for-webkit: false !global; 62 | $prefix-for-mozilla: false !global; 63 | $prefix-for-microsoft: false !global; 64 | $prefix-for-opera: false !global; 65 | $prefix-for-spec: false !global; 66 | } 67 | -------------------------------------------------------------------------------- /labs/Solutions/WinLabsWeek2_Solutions/thursday.nasm: -------------------------------------------------------------------------------- 1 | bits 32 2 | 3 | global _fibonacci@4, _walk_list_map@8 4 | 5 | 6 | section .text 7 | 8 | 9 | _fibonacci@4: 10 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 11 | ; 12 | ; This method takes a single parameter: 13 | ; 14 | ; Param 1: The fibonacci number to calculate (e.g., "5" would indicate 15 | ; to calculate and return the 5th fibonacci number). 16 | ; 17 | ; int __stdcall fibonacci(int n); 18 | ; 19 | ; BEGIN STUDENT CODE 20 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 21 | mov eax, [esp + 4] 22 | test eax, eax 23 | jz .done 24 | cmp eax, 1 25 | jz .done 26 | push eax 27 | dec eax 28 | push eax 29 | call _fibonacci@4 30 | mov edx, eax 31 | pop eax 32 | sub eax, 2 33 | push edx 34 | push eax 35 | call _fibonacci@4 36 | pop edx 37 | add eax, edx 38 | .done: 39 | ret 4 40 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 41 | ; END STUDENT CODE 42 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 43 | 44 | 45 | struc Node 46 | .Next resd 1 47 | .Data resd 1 48 | endstruc 49 | 50 | 51 | _walk_list_map@8: 52 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 53 | ; 54 | ; This method takes two parameters: 55 | ; 56 | ; Param 1: A pointer to the beginning of a linked list of nodes (structure 57 | ; definition above) 58 | ; 59 | ; Param 2: A function pointer 60 | ; 61 | ; Your task: 62 | ; 1.) Walk the list of nodes 63 | ; 2.) For each node, call the function pointer provided 64 | ; as parameter 2, giving it as input the Data from the node. 65 | ; 66 | ; void __stdcall walk_list_map(Node* n, void(*)(size_t)); 67 | ; 68 | ; BEGIN STUDENT CODE 69 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 70 | mov ecx, [esp + 4] 71 | mov edx, [esp + 8] 72 | .continue: 73 | test ecx, ecx 74 | jz .done 75 | mov eax, [ecx + Node.Data] 76 | push ecx 77 | push eax 78 | call edx 79 | add esp, 4 80 | pop ecx 81 | mov ecx, [ecx] 82 | jmp .continue 83 | .done: 84 | ret 8 85 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 86 | ; END STUDENT CODE 87 | ;;;;;;;;;;;;;;;;;;;;;;;;;; -------------------------------------------------------------------------------- /asm_slides/.sass-cache/2a8f65206aa6ecb0bc1c1ba1bcb99e5ee2d1cc96/_appearance.scssc: -------------------------------------------------------------------------------- 1 | 3.4.21 (Selective Steve) 2 | 3e3b77ca8717a4a8fb3d4309b1db9fd8a47d2dca 3 | o:Sass::Tree::RootNode :@children[o:Sass::Tree::MixinDefNode : 4 | @nameI"appearance:ET: 5 | @args[[o:!Sass::Script::Tree::Variable ;I" 6 | value; T:@underscored_nameI" 7 | value; T: 8 | @linei:@source_rangeo:Sass::Source::Range :@start_poso:Sass::Source::Position; i: @offseti: @end_poso;; i;i: 9 | @fileI""bourbon/css3/_appearance.scss; T:@importero: Sass::Importers::Filesystem: 10 | @rootI"//Users/aaron/Documents/projects/asm_slides; T:@real_rootI"//Users/aaron/Documents/projects/asm_slides; T:@same_name_warningso:Set: 11 | @hash{:@filename@: @options{0: @splat0;[o:Sass::Tree::MixinNode;I" prefixer; T; 12 | [o: Sass::Script::Tree::Literal : @valueo: Sass::Script::Value::String ;!I"appearance; T: 13 | @type:identifier:"@deprecated_interp_equivalent0;@; i;o; ;o;; i;i;o;; i;i$;@;@;@o; ;I" 14 | value; T; I" 15 | value; T; i;o; ;o;; i;i&;o;; i;i,;@;@;@;@o:$Sass::Script::Tree::ListLiteral :@elements[ 16 | o; ;!o;" ;!I" webkit; T;#;$;%0;@; i;o; ;o;; i;i.;o;; i;i4;@;@;@o; ;!o;" ;!I"moz; T;#;$;%0;@; i;o; ;o;; i;i5;o;; i;i8;@;@;@o; ;!o;" ;!I"ms; T;#;$;%0;@; i;o; ;o;; i;i9;o;; i;i;;@;@;@o; ;!o;" ;!I"o; T;#;$;%0;@; i;o; ;o;; i;i<;o;; i;i=;@;@;@o; ;!o;" ;!I" spec; T;#;$;%0;@; i;o; ;o;; i;i>;o;; i;iB;@;@;@:@separator: 17 | space; i;o; ;o;; i;i-;o;; i;iB;@;@;@;@:@keywordso:Sass::Util::NormalizedMap:@key_strings{: @map{;0:@kwarg_splat0;[; i;o; ;o;; i;i;o;; i;iC;@;@;@; i;o; ;o;; i;i;o;; i;i ;@;@:@has_childrenT;@:@templateI"b@mixin appearance($value) { 18 | @include prefixer(appearance, $value, webkit moz ms o spec); 19 | } 20 | ; T;/T;@; i;o; ;o;; i;i;o;; i;i;@;@ -------------------------------------------------------------------------------- /asm_slides/.sass-cache/2a8f65206aa6ecb0bc1c1ba1bcb99e5ee2d1cc96/_user-select.scssc: -------------------------------------------------------------------------------- 1 | 3.4.21 (Selective Steve) 2 | 2d413db6645a8aefe9f2439edc11f4d207f44337 3 | o:Sass::Tree::RootNode :@children[o:Sass::Tree::MixinDefNode : 4 | @nameI"user-select:ET: 5 | @args[[o:!Sass::Script::Tree::Variable ;I" 6 | value; T:@underscored_nameI" 7 | value; T: 8 | @linei:@source_rangeo:Sass::Source::Range :@start_poso:Sass::Source::Position; i: @offseti: @end_poso;; i;i: 9 | @fileI"#bourbon/css3/_user-select.scss; T:@importero: Sass::Importers::Filesystem: 10 | @rootI"//Users/aaron/Documents/projects/asm_slides; T:@real_rootI"//Users/aaron/Documents/projects/asm_slides; T:@same_name_warningso:Set: 11 | @hash{:@filename@: @options{o: Sass::Script::Tree::Literal : @valueo: Sass::Script::Value::String ;I" none; T: 12 | @type:identifier:"@deprecated_interp_equivalent0;@; i;o; ;o;; i;i!;o;; i;i%;@;@;@: @splat0;[o:Sass::Tree::MixinNode;I" prefixer; T; 13 | [o; ;o; ;I"user-select; T;!;";#0;@; i;o; ;o;; i;i;o;; i;i%;@;@;@o; ;I" 14 | value; T; I" 15 | value; T; i;o; ;o;; i;i';o;; i;i-;@;@;@;@o:$Sass::Script::Tree::ListLiteral :@elements[ o; ;o; ;I" webkit; T;!;";#0;@; i;o; ;o;; i;i/;o;; i;i5;@;@;@o; ;o; ;I"moz; T;!;";#0;@; i;o; ;o;; i;i6;o;; i;i9;@;@;@o; ;o; ;I"ms; T;!;";#0;@; i;o; ;o;; i;i:;o;; i;i<;@;@;@o; ;o; ;I" spec; T;!;";#0;@; i;o; ;o;; i;i=;o;; i;iA;@;@;@:@separator: 16 | space; i;o; ;o;; i;i.;o;; i;iA;@;@;@;@:@keywordso:Sass::Util::NormalizedMap:@key_strings{: @map{;$0:@kwarg_splat0;[; i;o; ;o;; i;i;o;; i;iB;@;@;@; i;o; ;o;; i;i;o;; i;i';@;@:@has_childrenT;@:@templateI"h@mixin user-select($value: none) { 17 | @include prefixer(user-select, $value, webkit moz ms spec); 18 | } 19 | ; T;/T;@; i;o; ;o;; i;i;o;; i;i;@;@ -------------------------------------------------------------------------------- /asm_slides/bourbon/addons/_buttons.scss: -------------------------------------------------------------------------------- 1 | @charset "UTF-8"; 2 | 3 | /// Generates variables for all buttons. Please note that you must use interpolation on the variable: `#{$all-buttons}`. 4 | /// 5 | /// @example scss - Usage 6 | /// #{$all-buttons} { 7 | /// background-color: #f00; 8 | /// } 9 | /// 10 | /// #{$all-buttons-focus}, 11 | /// #{$all-buttons-hover} { 12 | /// background-color: #0f0; 13 | /// } 14 | /// 15 | /// #{$all-buttons-active} { 16 | /// background-color: #00f; 17 | /// } 18 | /// 19 | /// @example css - CSS Output 20 | /// button, 21 | /// input[type="button"], 22 | /// input[type="reset"], 23 | /// input[type="submit"] { 24 | /// background-color: #f00; 25 | /// } 26 | /// 27 | /// button:focus, 28 | /// input[type="button"]:focus, 29 | /// input[type="reset"]:focus, 30 | /// input[type="submit"]:focus, 31 | /// button:hover, 32 | /// input[type="button"]:hover, 33 | /// input[type="reset"]:hover, 34 | /// input[type="submit"]:hover { 35 | /// background-color: #0f0; 36 | /// } 37 | /// 38 | /// button:active, 39 | /// input[type="button"]:active, 40 | /// input[type="reset"]:active, 41 | /// input[type="submit"]:active { 42 | /// background-color: #00f; 43 | /// } 44 | /// 45 | /// @require assign-inputs 46 | /// 47 | /// @type List 48 | /// 49 | /// @todo Remove double assigned variables (Lines 59–62) in v5.0.0 50 | 51 | $buttons-list: 'button', 52 | 'input[type="button"]', 53 | 'input[type="reset"]', 54 | 'input[type="submit"]'; 55 | 56 | $all-buttons: assign-inputs($buttons-list); 57 | $all-buttons-active: assign-inputs($buttons-list, active); 58 | $all-buttons-focus: assign-inputs($buttons-list, focus); 59 | $all-buttons-hover: assign-inputs($buttons-list, hover); 60 | 61 | $all-button-inputs: $all-buttons; 62 | $all-button-inputs-active: $all-buttons-active; 63 | $all-button-inputs-focus: $all-buttons-focus; 64 | $all-button-inputs-hover: $all-buttons-hover; 65 | -------------------------------------------------------------------------------- /labs/Solutions/WinLabsWeek2_Solutions/wednesday.nasm: -------------------------------------------------------------------------------- 1 | bits 32 2 | 3 | global _sum_array@8, _find_largest 4 | 5 | section .text 6 | 7 | 8 | _sum_array@8: 9 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 10 | ; 11 | ; This method takes two parameters: 12 | ; 13 | ; Param 1: A pointer to a buffer of integers (4 bytes/each). 14 | ; 15 | ; Param 2: A number indicating the number of elements in the buffer. 16 | ; 17 | ; You must: 18 | ; 1.) Walk through the buffer, and sum together all of the elements 19 | ; 2.) Return the result 20 | ; 21 | ; int __stdcall sum_array(int* buffer, int size); 22 | ; 23 | ; BEGIN STUDENT CODE 24 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 25 | push ebp 26 | mov ebp, esp 27 | push esi 28 | mov esi, [ebp + 8] 29 | mov ecx, [ebp + 12] 30 | xor eax, eax 31 | xor edx, edx 32 | .continue: 33 | lodsd 34 | add edx, eax 35 | loop .continue 36 | 37 | xchg eax, edx 38 | pop esi 39 | pop ebp 40 | ret 8 41 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 42 | ; END STUDENT CODE 43 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 44 | 45 | 46 | _find_largest: 47 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 48 | ; 49 | ; This function takes two 50 | ; parameters: 51 | ; 52 | ; Param 1: A pointer to a buffer of integers (4 bytes/each) 53 | ; 54 | ; Param 2: A number indicating the number of elements in the 55 | ; buffer. 56 | ; 57 | ; Your task is to: 58 | ; 1.) Walk through the buffer, locating the largest element 59 | ; 2.) Return it as the result. 60 | ; 61 | ; int __cdecl find_largest(unsigned long* buffer, int size) 62 | ; 63 | ; BEGIN STUDENT CODE 64 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 65 | push ebp 66 | mov ebp, esp 67 | push esi 68 | mov esi, [ebp + 8] 69 | mov ecx, [ebp + 12] 70 | xor eax, eax 71 | xor edx, edx 72 | .continue: 73 | lodsd 74 | cmp eax, edx 75 | jg .larger 76 | jmp .skip 77 | .larger: 78 | mov edx, eax 79 | .skip: 80 | loop .continue 81 | xchg eax, edx 82 | pop esi 83 | pop ebp 84 | ret 85 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 86 | ; END STUDENT CODE 87 | ;;;;;;;;;;;;;;;;;;;;;;;;;; -------------------------------------------------------------------------------- /asm_slides/bourbon/css3/_background.scss: -------------------------------------------------------------------------------- 1 | //************************************************************************// 2 | // Background property for adding multiple backgrounds using shorthand 3 | // notation. 4 | //************************************************************************// 5 | 6 | @mixin background($backgrounds...) { 7 | $webkit-backgrounds: (); 8 | $spec-backgrounds: (); 9 | 10 | @each $background in $backgrounds { 11 | $webkit-background: (); 12 | $spec-background: (); 13 | $background-type: type-of($background); 14 | 15 | @if $background-type == string or $background-type == list { 16 | $background-str: if($background-type == list, nth($background, 1), $background); 17 | 18 | $url-str: str-slice($background-str, 1, 3); 19 | $gradient-type: str-slice($background-str, 1, 6); 20 | 21 | @if $url-str == "url" { 22 | $webkit-background: $background; 23 | $spec-background: $background; 24 | } 25 | 26 | @else if $gradient-type == "linear" { 27 | $gradients: _linear-gradient-parser("#{$background}"); 28 | $webkit-background: map-get($gradients, webkit-image); 29 | $spec-background: map-get($gradients, spec-image); 30 | } 31 | 32 | @else if $gradient-type == "radial" { 33 | $gradients: _radial-gradient-parser("#{$background}"); 34 | $webkit-background: map-get($gradients, webkit-image); 35 | $spec-background: map-get($gradients, spec-image); 36 | } 37 | 38 | @else { 39 | $webkit-background: $background; 40 | $spec-background: $background; 41 | } 42 | } 43 | 44 | @else { 45 | $webkit-background: $background; 46 | $spec-background: $background; 47 | } 48 | 49 | $webkit-backgrounds: append($webkit-backgrounds, $webkit-background, comma); 50 | $spec-backgrounds: append($spec-backgrounds, $spec-background, comma); 51 | } 52 | 53 | background: $webkit-backgrounds; 54 | background: $spec-backgrounds; 55 | } 56 | -------------------------------------------------------------------------------- /labs/Lab10/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | extern "C" size_t first_func(void); 7 | extern "C" size_t second_func(char*); 8 | 9 | size_t gettsc() 10 | { 11 | size_t lowbits, highbits; 12 | asm("rdtsc" : "=a" (lowbits), "=d" (highbits)); 13 | return (lowbits | (highbits << 32)); 14 | } 15 | 16 | void getvstr(char** buf) 17 | { 18 | uint32_t p1,p2,p3; 19 | char* tmp = NULL; 20 | if(NULL == buf) 21 | return; 22 | 23 | if(NULL == (tmp = (char*)malloc(13))) { 24 | printf("[x] Out of memory!\n"); 25 | return; 26 | } 27 | memset(tmp, 0x00, 13); 28 | asm("xor %rax,%rax"); 29 | asm("cpuid" : "=b" (p1), 30 | "=d" (p2), 31 | "=c" (p3)); 32 | memcpy(tmp, &p1, sizeof(p1)); 33 | memcpy((tmp+4), &p2, sizeof(p2)); 34 | memcpy((tmp+8), &p3, sizeof(p3)); 35 | *buf = tmp; 36 | } 37 | 38 | #define EQ(x,y)\ 39 | do { if(x == y) printf("[*] Success! Values are equal!\n"); \ 40 | else printf("[x] Test Failed! Value %zu does not match value %zu!\n", x, y); } while(0) 41 | 42 | #define CLOSE(x,y)\ 43 | do { if((x - y) <= 1000) printf("[*] Success! values %zu and %zu are close!\n", x, y); \ 44 | else printf("[x] Test failed! Values %zu and %zu are not close!\n", x, y); \ 45 | } while(0) 46 | int main(int argc, char** argv) 47 | { 48 | size_t first = 0; 49 | size_t second = 0; 50 | char* tmp = NULL; 51 | char idbuf[13] = {0}; 52 | 53 | printf("Preparing to run first_func (Get timestamp)\n"); 54 | first = gettsc(); 55 | second = first_func(); 56 | CLOSE(second, first); 57 | 58 | getvstr(&tmp); 59 | if(NULL == tmp) { 60 | printf("[x] Allocation failed!\n"); 61 | return -1; 62 | } 63 | printf("Preparing to run second_func (Get vendor string)\n"); 64 | second_func(idbuf); 65 | EQ((size_t)0, (size_t)strcmp(idbuf, tmp)); 66 | printf("Your vendor ID string is: %s\n", idbuf); 67 | free(tmp); 68 | 69 | return 0; 70 | } 71 | -------------------------------------------------------------------------------- /labs/Solutions/Lab12.nasm: -------------------------------------------------------------------------------- 1 | bits 64 2 | 3 | global first_func, second_func, third_func 4 | 5 | 6 | 7 | first_func: 8 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 9 | ; This problem will require 10 | ; adding two vectors of numbers. 11 | ; A pointer to two unaligned 12 | ; vectors of 32-bit integers 13 | ; have been passed as the first 14 | ; two parameters to your function, 15 | ; and a pointer to an empty 16 | ; vector has been provided to store 17 | ; the result. 18 | ; 19 | ; BEGIN student code 20 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 21 | movups xmm0, [rdi] 22 | movups xmm1, [rsi] 23 | addps xmm0, xmm1 24 | movups [rdx], xmm0 25 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 26 | ; END student code 27 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 28 | ret 29 | 30 | second_func: 31 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 32 | ; This problem will require 33 | ; you to compare the values 34 | ; stored in the vector pointed 35 | ; to by parameter 1 with the 36 | ; values stored in the vector 37 | ; pointed to by parameter 2. 38 | ; Store the results of the 39 | ; comparison in the vector 40 | ; pointer to by parameter 3. 41 | ; 42 | ; BEGIN student code 43 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 44 | movups xmm0, [rdi] 45 | movups xmm1, [rsi] 46 | cmpps xmm0, xmm1, 0 47 | movups [rdx], xmm0 48 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 49 | ; END student code 50 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 51 | ret 52 | 53 | third_func: 54 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 55 | ; Given two scalar values, passed 56 | ; in as two parameters, find the max 57 | ; of the two, and return it as your 58 | ; result. 59 | ; 60 | ; BEGIN student code 61 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 62 | push rbp 63 | mov rbp, rsp 64 | sub rsp, 0x04 65 | xor rax, rax 66 | mov [rbp-4], edi 67 | movss xmm0, [rbp-4] 68 | mov [rbp-4], esi 69 | movss xmm1, [rbp-4] 70 | maxss xmm0, xmm1 71 | movss [rbp-4], xmm0 72 | mov eax, [rbp-4] 73 | add rsp, 0x04 74 | pop rbp 75 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 76 | ; END student code 77 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 78 | ret -------------------------------------------------------------------------------- /asm_slides/bourbon/css3/_border-image.scss: -------------------------------------------------------------------------------- 1 | @mixin border-image($borders...) { 2 | $webkit-borders: (); 3 | $spec-borders: (); 4 | 5 | @each $border in $borders { 6 | $webkit-border: (); 7 | $spec-border: (); 8 | $border-type: type-of($border); 9 | 10 | @if $border-type == string or list { 11 | $border-str: if($border-type == list, nth($border, 1), $border); 12 | 13 | $url-str: str-slice($border-str, 1, 3); 14 | $gradient-type: str-slice($border-str, 1, 6); 15 | 16 | @if $url-str == "url" { 17 | $webkit-border: $border; 18 | $spec-border: $border; 19 | } 20 | 21 | @else if $gradient-type == "linear" { 22 | $gradients: _linear-gradient-parser("#{$border}"); 23 | $webkit-border: map-get($gradients, webkit-image); 24 | $spec-border: map-get($gradients, spec-image); 25 | } 26 | 27 | @else if $gradient-type == "radial" { 28 | $gradients: _radial-gradient-parser("#{$border}"); 29 | $webkit-border: map-get($gradients, webkit-image); 30 | $spec-border: map-get($gradients, spec-image); 31 | } 32 | 33 | @else { 34 | $webkit-border: $border; 35 | $spec-border: $border; 36 | } 37 | } 38 | 39 | @else { 40 | $webkit-border: $border; 41 | $spec-border: $border; 42 | } 43 | 44 | $webkit-borders: append($webkit-borders, $webkit-border, comma); 45 | $spec-borders: append($spec-borders, $spec-border, comma); 46 | } 47 | 48 | -webkit-border-image: $webkit-borders; 49 | border-image: $spec-borders; 50 | border-style: solid; 51 | } 52 | 53 | //Examples: 54 | // @include border-image(url("image.png")); 55 | // @include border-image(url("image.png") 20 stretch); 56 | // @include border-image(linear-gradient(45deg, orange, yellow)); 57 | // @include border-image(linear-gradient(45deg, orange, yellow) stretch); 58 | // @include border-image(linear-gradient(45deg, orange, yellow) 20 30 40 50 stretch round); 59 | // @include border-image(radial-gradient(top, cover, orange, yellow, orange)); 60 | -------------------------------------------------------------------------------- /labs/WinFunctions/ASM/ASM/WinLab.nasm: -------------------------------------------------------------------------------- 1 | bits 32 2 | 3 | global _first_func@8, _second_func@8, _third_func, _fourth_func@12 4 | 5 | section .text 6 | 7 | ;;;;;;;;;;;;;;;;;;;;;;; 8 | ; Standard Call 9 | ; Using the following 10 | ; function definition, 11 | ; add the first parameter 12 | ; to the second, and return 13 | ; the result (via eax). 14 | ; 15 | ; 16 | ; int __stdcall first_func(int v1, int v2) 17 | ; BEGIN STUDENT CODE 18 | ;;;;;;;;;;;;;;;;;;;;;;; 19 | _first_func@8: 20 | 21 | ;;;;;;;;;;;;;;;;;;;;;;; 22 | ; END STUDENT CODE 23 | ;;;;;;;;;;;;;;;;;;;;;;; 24 | 25 | ;;;;;;;;;;;;;;;;;;;;;;; 26 | ; Standard Call 27 | ; Using the following 28 | ; function definition, 29 | ; subtract the second parameter 30 | ; from the first, and return 31 | ; the result (via eax). 32 | ; 33 | ; int __stdcall second_func(int v1, int v2) 34 | ; BEGIN STUDENT CODE 35 | ;;;;;;;;;;;;;;;;;;;;;;; 36 | _second_func@8: 37 | 38 | ;;;;;;;;;;;;;;;;;;;;;;; 39 | ; END STUDENT CODE 40 | ;;;;;;;;;;;;;;;;;;;;;;; 41 | 42 | 43 | ;;;;;;;;;;;;;;;;;;;;;;; 44 | ; cdecl 45 | ; Using the following 46 | ; function definition, 47 | ; given a NULL-terminated 48 | ; string, and a max value 49 | ; for length, find and return 50 | ; the string's length. 51 | ; 52 | ; size_t __cdecl third_func(char* string, size_t maxlen) 53 | ; BEGIN STUDENT CODE 54 | ;;;;;;;;;;;;;;;;;;;;;;; 55 | _third_func: 56 | 57 | ;;;;;;;;;;;;;;;;;;;;;;; 58 | ; END STUDENT CODE 59 | ;;;;;;;;;;;;;;;;;;;;;;; 60 | 61 | ;;;;;;;;;;;;;;;;;;;;;;; 62 | ; Standard Call 63 | ; Give the following function 64 | ; definition, which takes: 65 | ; 1.) a pointer to a set of 66 | ; obfuscated bytes 67 | ; 2.) a pointer to a destination 68 | ; array 69 | ; 3.) a size to operate on 70 | ; XOR each obfuscated byte 71 | ; by the constant value 72 | ; 0x5f, and store the result 73 | ; in the destination. 74 | ; 75 | ; void __stdcall fourth_func(unsigned char* input, char* output, size_t len) 76 | ; BEGIN STUDENT CODE 77 | ;;;;;;;;;;;;;;;;;;;;;;; 78 | _fourth_func@12: 79 | 80 | ;;;;;;;;;;;;;;;;;;;;;;; 81 | ; END STUDENT CODE 82 | ;;;;;;;;;;;;;;;;;;;;;;; -------------------------------------------------------------------------------- /asm_slides/asm.scss: -------------------------------------------------------------------------------- 1 | @import "bourbon/bourbon"; 2 | 3 | 4 | .split-table table { 5 | @include border-top-radius(5px); 6 | @include border-bottom-radius(5px); 7 | @include border-left-radius(5px); 8 | @include border-right-radius(5px); 9 | @include border-style(thick); 10 | box-shadow: 2px 2px 2px 5px rgba(0,0,0,0.3); 11 | } 12 | 13 | .split-table td { 14 | padding: 10px; 15 | @include border-style(solid); 16 | } 17 | 18 | .shrink-table td { 19 | font-size: 10pt; 20 | } 21 | 22 | .instruction-table td { 23 | padding: 5px; 24 | font-size: 10pt; 25 | } 26 | 27 | .flex-image img { 28 | @include display(inline-flex); 29 | @include justify-content(flex-end); 30 | width:175%; 31 | height: auto; 32 | } 33 | 34 | .shrink-image img { 35 | width: 50%; 36 | height: auto; 37 | } 38 | 39 | .block-image img { 40 | background-color: #ffffff; 41 | @include border-top-radius(5px); 42 | @include border-bottom-radius(5px); 43 | @include border-left-radius(5px); 44 | @include border-right-radius(5px); 45 | @include border-style(solid); 46 | box-shadow: 2px 2px 2px 5px rgba(0,0,0,0.3); 47 | } 48 | 49 | .flex-image p { 50 | font-size: 8pt; 51 | } 52 | 53 | pre { 54 | color: black; 55 | text-shadow: 0.5px 0.5px 1px #eaf2f4; 56 | @include border-style(thin thin thin); 57 | @include border-top-radius(5px); 58 | @include border-right-radius(5px); 59 | @include border-bottom-radius(5px); 60 | @include border-left-radius(5px); 61 | @include border-color(#70696e #70696e #70696e #70696e); 62 | @include padding(10px 40px 10px 10px); 63 | background-color: #ffffff; 64 | box-shadow: 2px 2px 2px 5px rgba(0,0,0,0.3); 65 | } 66 | 67 | pre > span { 68 | @include word-wrap; 69 | } 70 | 71 | h1 { 72 | text-align: center; 73 | font-family: Palatino Linotype, Book Antiqua, Palatino, serif; 74 | color: #110c3a; 75 | } 76 | 77 | div { 78 | font-family: Arial, Helvetica, sans-serif; 79 | text-shadow: 0.5px 0.5px 2px black; 80 | } 81 | 82 | li { 83 | @include padding(1em null null null); 84 | } 85 | 86 | body { 87 | @include background(radial-gradient(#eaeaea, #eaeaef)); 88 | font-size: modular-scale(2); 89 | color: #110c3a; 90 | } 91 | 92 | --------------------------------------------------------------------------------