lab3 - .data MEM.skip 32 Addr_prmpt.asciz"Memory...

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

View Full Document Right Arrow Icon
.data MEM: .skip 32 Addr_prmpt: .asciz "Memory [ " Cont_prmpt: .asciz " ] = " Reg_disp_arr: .asciz "PC = " .asciz "ACC = " .asciz "IR = " .asciz "MAR = " .asciz "MDR = " .set Reg_disp_arr_el_sz, 7 .text /* PREAMBLE ----------------------------------------------------------- Name: Assignment: Lab 3 Problem: This is a continuation, and a refinement, of Lab 2, to write a SPARC assembly language program to simulate the processing of the SAM machine. Methodology: In this iteration of the lab the BRL opcode is scrapped for a new instruction that will change the program counter to the specified address only if the accumulator is zero. Additionally, the memory subsystem and arithmetic logic unit have been separated into leaf subroutines. Finally, the method of input has been modified to always expect hexadecimal input and is supported by its own subroutines to handle this. Objectives: * Implement an instruction that conditionally changes the SAM's PC * Define and use null-terminated character strings * Implement array addressing Guidelines: * No SAM memory addressing errors will be attempted. * All entries v supplied for SAM memory cell contents can be construed to satisfy 0 <= v <= 2^8 - 1 * No values out of range (-2^7 to 2^7 - 1) or overflow errors will be calculated. Register Mapping: %r2 <--> program counter (PC) %r3 <--> accumulator (ACC) %r4 <--> instruction register (IR) %r5 <--> memory address register (MAR) %r6 <--> memory data register (MDR) Instruction Mapping: ADD 000 ACC <-- #ACC + M[addr] SUB 001 ACC <-- #ACC - M[addr] MPY 010 ACC <-- #ACC * M[addr] DIV 011 ACC <-- #ACC / M[addr] LOAD 100 ACC <-- M[addr] STORE 101 M[addr] <-- ACC BRNEQL 110 if ACC != 0, PC <-- addr HALT 111 exit the fetch-execute cycle */ ! Symbolic Constants for ISEM extended operations ("Traps"): .set exit, 0 .set putchar, 1
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
.set getchar, 2 .set putinthex, 4 .set getint, 5 ! Symbolic Constants for opcodes: .set ADD, 0 .set SUB, 1 .set MPY, 2 .set DIV, 3 .set LOAD, 4 .set STORE, 5 .set BRNEQL, 6 .set HALT, 7 prelim: ! preliminary computation loadMem: set Addr_prmpt, %r8 ! retrieve prompt address call pr_str ! display the prompt nop addr_lp: ta getchar ! get address input cmp %r8, 0xa ! see if it was a newline be addr_lp_dn ! newline means we handle mem contents next
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 6

lab3 - .data MEM.skip 32 Addr_prmpt.asciz"Memory...

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