lab1 - .data MEM: .byte 0x80 ! LOAD 0 .byte 0x7F ! DIV 31...

Info iconThis preview shows pages 1–3. 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
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: .data MEM: .byte 0x80 ! LOAD 0 .byte 0x7F ! DIV 31 .byte 0xAE ! STORE 14 .byte 0x1F ! ADD 31 .byte 0x2E ! SUB 14 .byte 0x5F ! MPY 31 .skip 26 .text /* PREAMBLE ----------------------------------------------------------- Name: Assignment: Lab 1 Objectives: * Organize instruction and data sections * Write and read from memory * Practice I/O primitives * Use arithmetic instructions * Work with ASCII characters Problem: This program provides an accurate simulation of the SAM archictecture performing computations using its standard OPCODES. During execution SAM memory address 0x1F is used and the contents of registers are printed after each instruction. To accomplish this SAM's registers are mapped to a set of SPARC registers as follows: %r2 <--> PC, program counter %r3 <--> ACC, accumulator %r4 <--> IR, instruction register %r5 <--> MAR, memory address register %r6 <--> MDR, memory data register As a demonstration of the instructions and register mapping, the following SAM instructions are executed: LOAD DIV 31 STORE 14 ADD 31 SUB 14 MPY 31 */ prelim: ! preliminary computation set MEM, %r7 ! %r7 = start of SAM memory set 0, %r2 ! PC = 0 /* This program is designed under the assumption nothing it does after this point changes %r7. Be careful to observe this program's convention in this regard. */ loadMem: ! read in data for the SAM program ! read in contents for MEM+0x1F set 0x1F, %r8 ! load offset for output ta 4 ! display offset as hex set '?', %r8 ! load ? for output ta 1 ! display character set ' ', %r8 ! load space for output ta 1 ! display character ta 5 ! prompt for an integer to work with stb %r8, [%r7 + 0x1F] ! write to MEM+0x1F load0: ! ACC <- M[0] ! fetch instruction mov %r2, %r5 ! PC to bus, load MAR add %r2, 1, %r2 ! INC to PC, load PC ldub [%r7 + %r5], %r6 ! CS, R/~W mov %r6, %r4 ! MDR to bus, load IR ! execute instruction set 0, %r5 ! addr to bus, load MAR (addr = 0) ldsb [%r7 + %r5], %r6 ! CS, R/~W mov %r6, %r3 ! MDR to bus, load ACC ! display contents of registers ! skip to the next display line set '\n', %r8 ! load newline for output ta 1 ! display character ! "PC=" %r2 set 'P', %r8 ! load P for output ta 1 ! display character set 'C', %r8 ! load C for output ta 1 ! display character set '=', %r8 ! load = for output ta 1 ! display character mov %r2, %r8 ! load %r2 for output ta 4 ! display %r2 ! "ACC=" %r3 set 'A', %r8 ! load A for output ta 1 ! display character set 'C', %r8 ! load C for output ta 1 ! display character ta 1 ! display same character set '=', %r8 ! load = for output ta 1 ! display character mov %r3, %r8 ! load %r3 for output ta 4 ! display %r3 ! "IR=" %r4 set 'I', %r8 ! load I for output ta 1 ! display character set 'R', %r8 ! load R for output ta 1 ! display character set '=', %r8 ! load = for output ta 1 ! display character mov %r4, %r8 ! load %r4 for output ta 4 ! display %r4 ! "MAR=" %r5 set 'M', %r8 ! load M for output ta 1 ! display character set 'A', %r8 ! load A for output ta 1 ! display character set 'R', %r8...
View Full Document

This note was uploaded on 02/27/2012 for the course CSE 360 taught by Professor Sam during the Winter '11 term at Ohio State.

Page1 / 8

lab1 - .data MEM: .byte 0x80 ! LOAD 0 .byte 0x7F ! DIV 31...

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

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