{"id":20332485,"url":"https://github.com/permutationlock/cs301_fall_2021","last_synced_at":"2026-04-19T02:34:17.005Z","repository":{"id":95722060,"uuid":"409161973","full_name":"permutationlock/cs301_fall_2021","owner":"permutationlock","description":"Examples for UAF CS301","archived":false,"fork":false,"pushed_at":"2023-09-21T00:36:48.000Z","size":126,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-12-06T01:26:11.869Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/permutationlock.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-09-22T10:36:00.000Z","updated_at":"2022-01-12T12:01:41.000Z","dependencies_parsed_at":"2024-11-14T20:39:00.932Z","dependency_job_id":null,"html_url":"https://github.com/permutationlock/cs301_fall_2021","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/permutationlock/cs301_fall_2021","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/permutationlock%2Fcs301_fall_2021","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/permutationlock%2Fcs301_fall_2021/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/permutationlock%2Fcs301_fall_2021/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/permutationlock%2Fcs301_fall_2021/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/permutationlock","download_url":"https://codeload.github.com/permutationlock/cs301_fall_2021/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/permutationlock%2Fcs301_fall_2021/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31992021,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T20:23:30.271Z","status":"online","status_checked_at":"2026-04-19T02:00:07.110Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-14T20:26:51.877Z","updated_at":"2026-04-19T02:34:16.984Z","avatar_url":"https://github.com/permutationlock.png","language":"C","readme":"# CS301 Fall 2021\n\nExamples for the [Fall 2021 CS301 class](https://docs.google.com/document/d/e/2PACX-1vQOy_S-NkOwHxovtzo13BQloFZsio_FGmOzj7eXg_fF6c2-rWomY468IYcbJ6s0O7qiVXOg3BHcm86R/pub)\nat UAF.\n\n## Requirements\n\nAll of the examples require an x86_64 machine running a Linux distro with\n[gcc](https://gcc.gnu.org) and [nasm](https://nasm.us) installed. However,\nthe readme file in each folder contains a link to run the code on\n[Netrun](http://netrun.cs.uaf.edu/).\n\n## Vagrant VM\n\nA [Vagrant](https://vagrantup.com) box\n[avenbross/cs301](https://app.vagrantup.com/avenbross/boxes/cs301)\nis available with [Alpine Linux](https://alpinelinux.org),\nall of these examples in this repo, and the packages required\nto run them.\n\nTo set up a VM this way you need to install\n[VirtualBox](https://virtualbox.org) and\n[Vagrant](https://vagrantup.com) and then run\nthe following commands (in PowerShell on Windows, terminal on Linux/macOS):\n\n```console\nvagrant init avenbross/cs301\nvagrant up\n```\n\nTo log in and start using the machine run:\n\n```console\nssh -p \u003cport\u003e vagrant@localhost\n```\n\nEnter the password \"vagrant\" when prompted. The port that the VM is running\non is shown during the startup process (it will be something like 2200 or 2222). If you missed it, you can find it by running:\n\n```console\nvagrant ssh-config\n```\n\nOnce you are logged in to the server you need to know a little about Linux to get around. You can run the command `ls` to\nlist the files and subdirectories of the current directory. You can use `cd \u003cdirectory name\u003e` to change directory. For example,\nwhen you first log in to the server running `ls` shows:\n\n```console\nalpine:~$ ls\ncs301_fall_2021\n```\n\nLets move into the `cs301_fall_2021` folder and see what is inside:\n\n```console\nalpine:~$ cd cs301_fall_2021\nalpine:~/cs301_fall_2021$ ls\nREADME.md                             function_ptr\narray_of_function_ptrs                function_ptr_in_struct\nbasic_struct_with_asm                 input_index_to_find_in_array\ncall_c_function_from_asm              linking_c_and_asm\nconstruct_and_return_c_struct_in_asm  linking_cpp_and_asm\ncount_as_in_string\n```\n\nNext, move into the `linking_c_and_asm` example folder and open the `main.c` file with\n[nano](https://www.nano-editor.org/dist/latest/nano.html) text editor:\n\n```console\nalpine:~/cs301_fall_2021$ cd linking_c_and_asm\nalpine:~/cs301_fall_2021/linking_c_and_asm$ nano main.c\n```\n\nPress CTRL-X to close the file (select no if asked to save changes). You \ncan do the same thing to read `foo.asm` by executing `nano foo.asm`.\n\nHaving looked through the code, let's build and run the example:\n\n```console\nalpine:~/cs301_fall_2021/linking_c_and_asm$ ./build.sh\nalpine:~/cs301_fall_2021/linking_c_and_asm$ ./run\nassembly returned: 1783\n```\n\nGreat, we compiled a C and assembly project and it ran! This created an executable\nand a couple object files (.o files):\n\n```console\nalpine:~/cs301_fall_2021/linking_c_and_asm$ ls\nREADME.md  build.sh   clean.sh   foo.asm    foo.o      main.c     main.o     run\n```\n\nTo get rid of these just run the clean script:\n\n```console\nalpine:~/cs301_fall_2021/linking_c_and_asm$ ./clean.sh\nalpine:~/cs301_fall_2021/linking_c_and_asm$ ls\nREADME.md  build.sh   clean.sh   foo.asm    main.c\n```\n\nAll the other examples can be built the same way (and you can copy a directory to start your own project). I would recommend not modifying the files in the `cs301_fall_2021` directory if you are not experienced with git. I will be updating the repo and if you modify the files, pulling updates will cause merge conflicts. Instead make copies of examples by running `cp -r directory_to_copy copy_name`.\n\nIf you are curious as to how each example is built and cleaned you can open those\nscript files with `nano` as well and simply read the list of commands they execute.\n\nWhen you are done, you can close the ssh session by running the command `exit`. This will leave the machine running and you can ssh in later. If you instead want to shut the machine down (all your files will be saved, but you will have to re-run `vagrant up` to boot up the machine again) you can instead run `sudo poweroff`.\n\nSome other things you might want to look at:\n\n - [cheat sheet on linux commands](https://www.guru99.com/linux-commands-cheat-sheet.html)\n - [nano text editor documentation](https://www.nano-editor.org/dist/latest/nano.html)\n - [vim text editor documentation (if you are brave enough to seek its power)](https://vimhelp.org/)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpermutationlock%2Fcs301_fall_2021","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpermutationlock%2Fcs301_fall_2021","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpermutationlock%2Fcs301_fall_2021/lists"}