1 / 15

CMSC212: Intro to Low-Level Programming Concepts

CMSC212: Intro to Low-Level Programming Concepts. Section 0101: 9:00am – 9:50am Section 0102: 10:00am-10:50am Monday & Wednesdays Room 3118. Emacs Stuff. With Xming [emacs &] calls up a new window with emacs and returns access to command-line

Download Presentation

CMSC212: Intro to Low-Level Programming Concepts

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CMSC212: Intro to Low-Level Programming Concepts Section 0101: 9:00am – 9:50am Section 0102: 10:00am-10:50am Monday & Wednesdays Room 3118

  2. Emacs Stuff • With Xming • [emacs &] calls up a new window with emacs and returns access to command-line • [emacs file1 &] calls up emacs with file1 read into new window • Note: & commonly used to put process into background • [bg] to view background processes • [fg %number] to pull background process “number” to foreground

  3. Emacs Stuff Cont’d • Without Xming • [emacs], [emacs file1] • More commands • [Ctrl-x Ctrl-c] Exit emacs • [Ctrl-x Ctrl-s] Save file (save often) • Useful keybinds for cursor movement • [Ctrl-a] Beginning of current line • [Ctrl-e] End of current line • [Escape-<] Front of file • [Escape->] End of file

  4. Emacs Editing • Keybinds for deleting text • [Ctrl-k] Delete to end of line • [Ctrl-u] Delete line • Cut/pasting • [Ctrl-space] Mark head end of cut • [Ctrl-w] Mark tail end of cut • [Ctrl-y] Paste

  5. GCC Compilation and Linking • File test1.c • #include <stdio.h>int main() { printf("This is CMSC 212."); printf(“hello world!\n"); printf(“bye world!\n"); return 0; }

  6. GCC Compilation and Linking • Method 1 • [gcc –c test1.c] • Creates an object file test1.o • [gcc test1.o –o test1] • Links object file(s) and outputs executable • Method 2 • [gcc test1.c] • No intermediates, produces executable a.out • [gcc test1.c –o test1] • No intermediates, produces executable test1

  7. Gcc Compilation and Linking Multiple files • File1: questionablepractices.h • #ifndef _QUESTIONABLE_H_#define _QUESTIONABLE_H_#include <stdio.h> //Prototypesvoid infiniteLoop();void infiniteStack();#endif

  8. Gcc Compilation and Linking Multiple files • File2: questionablecode.c • #include “questionablepractices.h”void infiniteLoop(){ while(1) printf(“how to terminate?\n”);} void infiniteStack(){ printf(“o really?\n”); infiniteStack();}

  9. Gcc Compilation and Linking Multiple files • File3: questionablemain.c • #include “questionablepractices.h”int main(){ infiniteLoop(); //infiniteStack(); return 0;}

  10. Gcc Compilation and Linking Multiple files • How to build this? • gcc questionablemain.c questionablecode.c -o question • Generates executable called “question” • gcc –c questionablemain.c questionablecode.c • Generates object files questionablemain.o questionablecode.o • gcc questionablemain.o questionablecode.o -question • Links the two files and creates executable

  11. Xming emacs + compilation • Another way to compile directly through emacs • [Escape-x] type compile • Suggests make –k (will get into later when we use make) • For now, use the standard gcc commands • Notice the new menu titled “Compile”

  12. More Unix commands+options • More useful commands • [cp –r] Copy directories recursively, i.e. all sub-file/directories • [man cmd] pulls up the manual and description of options for cmd, e.g. [man cp]

  13. Chmod • [chmod [references][operator][mode] file(s)] • reference classes • u (user/owner), g (users who are members of file group), o (users not in g), a (all from before, i.e. ugo) • operator • + (add modes to reference classes) • - (remove modes from reference classes) • = (specified modes are made exact for reference classes) • Mode • r (read), w (write), x(execute) • X, s, t (not covered)

  14. Chmod • E.g. • chmod ug+rw mydir • Gives read/write mode to user and file group of directory mydir

  15. Questions?

More Related