Textbook Notes (363,079)
Canada (158,178)
CPSC 481 (1)
Tony Tang (1)

Assembly Language Cheat Sheet

3 Pages
Unlock Document

University of Calgary
Computer Science
CPSC 481
Tony Tang

OS COMMAND EFFECT GDB EFFECT COMMAND rhide filename opens file in rhide gdb filename opens filename in gdb nasm -f coff filename c break label sets breakpoint at label (ending in .asm) gcc -c filename Compiles C file into .o file clear label clears breakpoint at label (ending in .c) gcc *.o Links all .o files in currentcontinue continue exectution after folder into executable breakpoint gcc filename1 Links 2 or more files into si next instruction, enters filename2 executable functions dir displays current directory ni next instruction, skips fn's cd \folder1\folder2 go to folder2 disassemble displays fn's code function cd .. go to parent folder info registers displays registers copy q \...\folder2 copy q to folder2 print var show value of var p $register ...or register p/x, p/d, p/c, p/f ...as hex, signed int, char, float x address examine address x &var examine value of var ASM COMMAND EFFECT NOTES cmp dest, src computes dest - src, sets flags ZF, CF according to result ZF CF *** jc label: CF = 1 jg label: dest > src dest= src jz label: ZF = 1 etc dest>src 0 0 jnz label:ZF = 0 dest=src 1 0 loop label -ECX = ECX - 1, - jmp label if ECX != 0 loopz label -ECX = ECX - 1 loopnz same, but ends in - jmp label if ECX != 0 AND ZF = 1 - loope (loop if equal) loopne (loop if not equal) .BSS DECLARATION WITH NASM EXPLANATION Buffer1: resb 64 ; reserve 64 bytes for data -res = reserve; b = byte; w = word; d = Wordvar: resw 1 ;a variable contained in 1 doubleword word BUFFERS GO HERE. Myarray: resd 10 ;array of 10 doublewords .DATA DEFINITION WITH NASM EXPLANATION Mybyte: db 0x55 -[label + 0] holds 1st byte of data Myarray: db 4Fh, 33h, FFh, -ops after strings are terminators. Seems to Mystring: db "john", 13, 10, $ usually be some variation on 13, 10, $ (or 0) Myvar1: dw 0x4534 -db, dw, dd (define byte, word, doubleword) With NASM, can also use %define to create symbolic constants. Eg %define CTRL 0x1F. Also, macros, like this: %macro prologue 1 ; 1 is the argument push ebp mov ebp, esp sub esp, %1 %endmacro BASIC I/O INTERRUPT INPUT AND OUTPUT AND NOTES Read Char with echo
More Less

Related notes for CPSC 481

Log In


Don't have an account?

Join OneClass

Access over 10 million pages of study
documents for 1.3 million courses.

Sign up

Join to view


By registering, I agree to the Terms and Privacy Policies
Already have an account?
Just a few more details

So we can recommend you notes for your school.

Reset Password

Please enter below the email address you registered with and we will send you a link to reset your password.

Add your courses

Get notes from the top students in your class.