Set5 - 1 TA C162 Computer Programming I Virendra S Set5 Today’s Agenda LC-3 Assembly Programming Examples 2 TA C162 Computer Programming I

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 1 TA C162 Computer Programming I Virendra S Set5 Today’s Agenda LC-3 Assembly Programming Examples 2 TA C162 Computer Programming I Virendra S Set5 Trap Codes LC-3 assembler provides “pseudo-instructions” for each trap code, so you don’t have to remember them. Description Equivalent Code Write null-terminated string to console. Address of string is in R0. TRAP x22 PUTS Read one character from keyboard. Character stored in R0[7:0]. TRAP x20 GETC Write one character (in R0[7:0]) to console. TRAP x21 OUT Print prompt on console, read (and echo) one character from keybd. Character stored in R0[7:0]. TRAP x23 IN Halt execution and print message to console. TRAP x25 HALT 3 TA C162 Computer Programming I Virendra S Set5 Program1: Character Count Program ;Reads a character from the user and ;count the occurrences of the char in ;the null terminated string. ;Stores the result in R2 .ORIG x3000 AND R2, R2, #0 GETC LEA R1, STRING LDR R3, R1, #0 LOOP1 BRZ DONE NOT R3,R3 ADD R3, R3, #1 ADD R3, R0, R3 BRNP NEXTCHR ADD R2, R2, #1 NEXTCHR ADD R1, R1, #1 LDR R3, R1, #0 BRNZP LOOP1 DONE HALT STRING .STRINGZ "Computer Programming" .END 4...
View Full Document

This note was uploaded on 05/14/2010 for the course CS SS ZG653 taught by Professor Shanta during the Spring '09 term at Birla Institute of Technology & Science.

Page1 / 10

Set5 - 1 TA C162 Computer Programming I Virendra S Set5 Today’s Agenda LC-3 Assembly Programming Examples 2 TA C162 Computer Programming I

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

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