lc3代写 | 代做assembly | java | assignment | 代写IT – how to use LC-3 simulator

how to use LC-3 simulator

lc3代写 | 代做assembly | java | assignment | 汇编代写 – 这个题目属于一个LC3汇编的代写任务, 是比较典型的assembly/java/等代写方向, 这个项目是assignment代写的代写题目

java代写 代写java

Introduction

This assignment is to be done using LC-3 simulator. You can download the java version from Canvas.

You can use the simulator to compile and test the program.

Section 1 : Running the Simulator [1] (1 mark)

You can execute the simulator (LC3sim.jar). We need to first load some software. The first piece of software we should load is, naturally, an operating system. The LC-3 operating system is very basic: IT handles simple I/O operations and is responsible for starting other programs. Download the LC-3 OS (LC3os.asm) and you can understand what the operating system does.

The LC-3 machine doesn’t understand assembly directly; we first have to ‘assemble’ the assembly code into machine language (it is an .obj file containing binary data). The LC-3 simulator has a built-in assembler, accessible (as is the case for most of its functionality) via the Command Line text box. To assemble the operating system, type as lc3os.asm at the command line and hit enter. Make sure that the OS file is in the same directory as the .jar file; the as command also understands relative and absolute paths if the OS is in a different directory. Output from the assembly process is displayed in the CommandLine Output Pane. After assembling the OS, you should notice that 2 new files, lc3os.obj and lc3os.sym, have been created. The .obj file is the machine language encoding of the assembly language file, and the .sym file is a text file that holds symbol information so the simulator can display your symbols. Recall that symbols are really just a convenience for silly humans; the machine language encoding knows only about offsets.

Now we can load the lc3os.obj file into the simulator, either via the command load lc3os.obj or by going to the File menu and selecting Open .obj file. Notice that the contents of the memory change when the OS is loaded. Now assemble and load the solution file for Problem 0 (Q0.asm) into the simulator. The memory has changed again, but you may not notice since the relevant memory addresses (starting at x3000) aren’t visible unless you’ve scrolled the screen. User-level programs (i.e., non-OS code) start, by convention, at x3000. If you type the command list x3000 the memory view will jump to x3000 and you can see the 1-instruction solution to this problem.

To actually run code, you can use the 4 control buttons at the top of the simulator, or type commands into the command line interface (the command names are the same as the buttons). Note that the PC register is set to x0200, which is the entry point to the operating system by convention. You can set the value in the registers. Example: You can set the value of R2, either by double-clicking it in the Registers section, or via the command set R2 (value). Now, actually run the code by hitting the continue button. You can find more details of operations from [1].

In section 1, you are going to revise the program below. This program will take two input operands and output the AND results of those inputs. You first assemble all the files: lc3os.asm, data.asm and Q0.asm. Hence, you execute the following commands: load lc3os.obj, load data.obj and load Q0.obj. Click continue to run the program. You can see the results from the display at the bottom-left.

COMPSCI 210 S 1

Assignment ONE
Computer

Science

You now revise the program of the sample file (Q0.asm) so the output will display the addition result (sum) of every two input values from the data.asm. Save the program as the file Q1.asm. 009+008= 008+007= 007+006= 006+005= 005+004= 004+003= 003+002= 002+001=

WARNING: We will use the JAVA simulator for marking. In particular, you should make sure that your answer will produce ONLY the exact output expected. The markers simply makes an exact comparison with the expected output. If you have any debug printouts or other code which produces some unexpected output, the markers will give you zero marks. If your files cannot be compiled successfully or they cannot be executed after compilation, the markers will also give you zero marks.

;
; Initialization
;
.ORIG x
LD R6, EMPTY ; R6 is the stack pointer
LD R5, PTR ; R5 is pointer to characters
AND R0, R0, #
ADD R0, R0, #10 ; Print a new line
OUT
;
REDO LDR R3, R5, #0 ; R3 gets character
;
; Test character for end of file
;
ADD R4, R3, #- 10 ; Test for end of line (ASCII xA)
BRz EXIT ; If done, quit
LD R4, ZERO
ADD R3, R3, R4 ; Get the decimal value from ASCII
JSR CONV
ADD R5, R5, #
AND R4, R5, #1 ; check odd/even
BRz EVEN
ADD R2, R3, #0 ; Save the first operand to R
LD R0, PLUS ; '+', revise the sign here for the corresponding operation
OUT
BRnzp REDO
EVEN LD R0, EQUAL ; '='
OUT
; Start calculation ; You only need to revise this section for the operations
AND R3, R2, R3 ; The second operand is at R
;
JSR CONV
AND R0, R0, #
ADD R0, R0, #10 ; Print a new line
OUT
BRnzp REDO
;
; A subroutine to output a 3-digit decimal result.
;
CONV ..........
................................
EXIT HALT ; Halt machine

Section 2: Hexadecimal Representation (2 marks)

You now revise the program of the section 1 (Q1.asm) so the output will display the correction equation and the addition result of every two input values from the data.asm in hexadecimal representation. Save the program as the file Q2.asm.

For example (data from data.asm): 009+008= 008+007=00F 007+006=00D 006+005=00B 005+004= 004+003= 003+002= 002+001=

You need to revise the CONV subroutine to display the result in hexadecimal representation. You can revise it based on the following template (you can check Lecture 17 for more information).

CONV ADD R1, R7, #0 ; R3, R4, R5 and R7 are used in this subroutine
JSR Push
ADD R1, R3, #0 ; R3 is the input value
JSR Push
ADD R1, R4, #
JSR Push
ADD R1, R5, #
JSR Push
AND R5, R5, #
;
;
; Your code is here
;
;
;
JSR Pop
ADD R5, R1, #
JSR Pop
ADD R4, R1, #
JSR Pop
ADD R3, R1, #
JSR Pop
ADD R7, R1, #
RET
PRINT ADD R1, R7, #0 ; R3, R4, R5 and R7 are used in this subroutine
JSR Push
ADD R0, R0, #- 10
BRn PINT
LD R1, CHAR_A
ADD R0, R1, R
OUT
JSR Pop
ADD R7, R1, #
RET
PINT ADD R0, R0, #
LD R1, ASCII
ADD R0, R0, R
OUT
JSR Pop
ADD R7, R1, #
RET

Section 3 : Subtraction ( 1 mark)

You now revise the program of the section 2 (Q2.asm) so the output will display the correction equation and the subtraction result of every two input values from the data.asm (you can check Lecture 3 for more information). Save the program as the file Q 3 .asm.

For example (data from data.asm): 009 – 008= 008 – 007= 007 – 006= 006 – 005= 005 – 004= 004 – 003= 003 – 002= 002 – 001=

Section 4 : Multiplication ( 2 marks)

You now revise the program of the section 2 (Q 2 .asm) so the output will display the correction equation and the multiplication result of every two input values from the data.asm (you can check Lecture 1 3 for more information). Save the program as the file Q 4 .asm.

For example (data from data.asm): 009008= 008007= 007006=02A 006005=01E 005004= 004003=00C 003002= 002001=

Section 5 : Factorial ( 2 marks)

You now revise the program of the section 2 (Q2.asm) so the output will display the correction equation and the factorial result of every input value from the data 1 .asm (you can check Lecture 1 5 for more information). Save the program as the file Q 5 .asm.

For example (data from data 1 .asm): 006!=2D 005!= 004!= 003!= 002!= 001!=

Remarks:

  1. All input value should be between 000 10 00910.
  2. The results of all output should be between 000 16 FFF 16.
  3. All inputs and outputs should be positive.
  4. There should not be any invalid inputs from the input data file.

Submission

You may electronically submit your assignment through the web Dropbox (https://adb.auckland.ac.nz/) at any time from the first submission date up until the final date. You can make more than one submission. However, every submission that you make replaces your previous submission. Submit ALL your files in every submission. Only your very latest submission will be marked. Please double check that you have included all the files required to run your program.

No marks will be awarded if your program does not compile and run. You are to electronically submit all the following files:

  1. Q1.asm for section 1
  2. Q2.asm for section 2
  3. Q3.asm for section 3
  4. Q4.asm for section 4
  5. Q 5 .asm for section 5

There will be 30% penalty on late submission. The period of late submission will be 2 weeks after the deadline. No more submission will be allowed after that period.

Integrity

Any work you submit must be your work and your work alone. To share assignment solutions and source code is not permitted under our academic integrity policy. Violation of this will result in your assignment submission attracting no marks, and you will face disciplinary actions in addition.

Reference

[1] http://www.cis.upenn.edu/~milom/cse240-Fall05/handouts/lc3guide.html