Lecture 15-17 - Lecture 15-17 Announcements Hwk 5 due...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
Lecture 15-17 – 10/4/10-10/8/10 Announcements Hwk 5 due Friday Last Week LC-3 Instructions + Test LC-3 programs LC-3 Program Execution LC-3 I/O LC-3 Subroutines CS310 Fall 2010 - Boral Assembly Language Programs ; Program to multiply a number by the constant 6 ; .ORIG x3050 ; locate start of pgm at x3050 LD R1, Six LD R2, Num AND R3, R3, #0 ; clear R3 to hold product L ADD R3, R3, R2 ADD R1, R1, #-1 BRp L HALT ; really a TRAP instruction Num .BLKW ; reserve a memory cell Six .FILL x0006 ; store x0006 in this cell .END ; end of program CS310 Fall 2010 - Boral
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Each line of a program is one of the following: an instruction an assember directive (or pseudo-op) a comment Whitespace (between symbols) and case are ignored. Comments (beginning with “;”) are also ignored. An instruction has the following format: LABEL OPCODE OPERANDS ; COMMENTS optional mandatory LC-3 Assembly Language Syntax CS310 Fall 2010 - Boral Opcodes reserved symbols that correspond to LC-3 instructions listed in Appendix A ex: ADD , AND , LD , LDR , … Operands registers -- specified by Rn, where n is the register number numbers -- indicated by # (decimal) or x (hex) label -- symbolic name of memory location separated by comma number, order, and type correspond to instruction format Examples: ADD R1,R1,R3 ADD R1,R1,#3 LD R6,NUMBER BRz LOOP CS310 Fall 2010 - Boral
Background image of page 2
Label placed at the beginning of the line assigns a symbolic name to the address corresponding to line ex: LOOP ADD R1,R1,#-1 BRp LOOP Comment anything after a semicolon is a comment ignored by assembler used by humans to document/understand programs tips for useful comments: avoid restating the obvious, as “decrement R1” provide additional insight, as in “accumulate product in R6” use comments to separate pieces of program CS310 Fall 2010 - Boral Pseudo-operations do not refer to operations executed by program used by assembler look like instruction, but “opcode” starts with dot Opcode Operand Meaning .ORIG address starting address of program .END end of program .BLKW n allocate n words of storage .FILL n allocate one word, initialize with value n .STRINGZ n-character string allocate n+1 locations, initialize w/characters and null terminator Assembler Directives CS310 Fall 2010 - Boral
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Code Equivalent
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 21

Lecture 15-17 - Lecture 15-17 Announcements Hwk 5 due...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online