lc3

What is wrong with this line of Lc3 code?

若如初见. 提交于 2019-12-13 01:56:10
问题 I am doing a practice exam question. The Question is Is there anything wrong in this line of LC3 code? (The starred line) ADD R3, R3, 0; **BRNZ ISPOS;** HALT .BLKW 250 ISPOS NOT R3, R3 .... I saw that the starred line is Branch and the condition codes are negative and zero, basically go to label ISPOS if the condition code is negative or zero or halt the program otherwise. I would say that this line of LC3 code has nothing wrong with it. Does anyone see any problems with it? 回答1: Yes, there

Having trouble reading strings from a file in C and manipluating them as an lc3 disassmbler

余生长醉 提交于 2019-12-08 00:21:29
问题 I want to make a program that scans a file with contents of: 1283 5105 The hexcodes for two instructions in lc3: add r1,r2,r3 and r0,r4,r5 I want my program to read this file and print the two corresponding instructions on the screen can someone please tell me what's wrong with it #include <stdio.h> #include <stdbool.h> #include <string.h> int main(int argc, char *argv[]) { FILE *file; char hexString[5]; int dr, sr1, sr2, instruction; file = fopen(argv[1], "r"); while (fscanf(file, "%d",

Having trouble reading strings from a file in C and manipluating them as an lc3 disassmbler

别等时光非礼了梦想. 提交于 2019-12-06 04:25:40
I want to make a program that scans a file with contents of: 1283 5105 The hexcodes for two instructions in lc3: add r1,r2,r3 and r0,r4,r5 I want my program to read this file and print the two corresponding instructions on the screen can someone please tell me what's wrong with it #include <stdio.h> #include <stdbool.h> #include <string.h> int main(int argc, char *argv[]) { FILE *file; char hexString[5]; int dr, sr1, sr2, instruction; file = fopen(argv[1], "r"); while (fscanf(file, "%d", hexString) != EOF){ unsigned short int instruction = (unsigned short)strtol(hexString, NULL, 16); if

VHDL STD_LOGIC_VECTOR Wildcard Values

蓝咒 提交于 2019-12-04 07:21:17
I've been trying to write a Finite State Machine in VHDL code for a simple 16-bit processor I'm implementing on an Altera DE1 board. In the Finite State Machine, I have a CASE statement that handles the different 16-bit instructions, which are brought into the FSM by a 16-bit STD_LOGIC_VECTOR. However, I'm having a little trouble in the decode state where the Finite State Machine decodes the instruction. One of the instructions is an ADD which takes two registers as operands and a third as the destination register. However, I also have an ADD instruction which takes a register and a 5-bit

Printing a binary number in LC-3 Assembly

不羁岁月 提交于 2019-12-02 18:51:35
问题 I'm trying to print a binary number to the console using LC-3 assembly. What I've tried so far includes (but isn't limited to): binary .fill b10000110 lea r0, binary puts ; prints garbage ld r0, binary out ; prints 0 (I know it only prints one character but I don't know why it chooses to print 0) lea r1, binary and r2, r2, #0 loop ldr r0, r1, r2 out add r2, r2, #1 and r3, r3, #0 not r3, r2 add r3, r3, #1 add r3, r3, #8 ; I know all the binary numbers will be exactly 8 bits long brz end add r3

Printing a binary number in LC-3 Assembly

青春壹個敷衍的年華 提交于 2019-12-02 09:58:43
I'm trying to print a binary number to the console using LC-3 assembly. What I've tried so far includes (but isn't limited to): binary .fill b10000110 lea r0, binary puts ; prints garbage ld r0, binary out ; prints 0 (I know it only prints one character but I don't know why it chooses to print 0) lea r1, binary and r2, r2, #0 loop ldr r0, r1, r2 out add r2, r2, #1 and r3, r3, #0 not r3, r2 add r3, r3, #1 add r3, r3, #8 ; I know all the binary numbers will be exactly 8 bits long brz end add r3, r3, #0 ; to be safe brnzp loop end ; more code... None of this works particularly well. I'm pulling

What does stripping off the ASCII template mean?

浪尽此生 提交于 2019-12-02 07:03:25
问题 I am working on a practice exam problem The Problem On execution of this program, the user inputs two numbers. What is the value of xGuess so we can strip off the ASCII template? Explain. .ORIG x3000 TRAP x23 LD R2, ASCII ADD R1, R2, R0 TRAP x23 ADD R0, R0, R2 ADD R0, R0, R1 ASCII .FILL xGuess .END Using Lc3 Assembly as a reference, I was able to work out what this program does(from top to bottom) Start placing code at memory address x3000 Lets user input a character, call this character.

What does stripping off the ASCII template mean?

亡梦爱人 提交于 2019-12-02 04:36:59
I am working on a practice exam problem The Problem On execution of this program, the user inputs two numbers. What is the value of xGuess so we can strip off the ASCII template? Explain. .ORIG x3000 TRAP x23 LD R2, ASCII ADD R1, R2, R0 TRAP x23 ADD R0, R0, R2 ADD R0, R0, R1 ASCII .FILL xGuess .END Using Lc3 Assembly as a reference, I was able to work out what this program does(from top to bottom) Start placing code at memory address x3000 Lets user input a character, call this character. Register 0 will store the value of k xGuess -> R2 (k + xGuess) -> R1. Lets user input another character,

LC3 Assembly Bitwise Right Shift

╄→гoц情女王★ 提交于 2019-12-01 04:31:43
What I need to do it implement both a bitwise left shift, and a bitwise right shift using LC-3 Assembly . Basically, every bit has to be moved over one space in the direction of the shift, and a zero fills the empty space created. Examples: Right Shift: 01001001 00100100→ Left Shift: 01001001 ←10010010 I've successfully implemented a left shift, by taking the binary string, and adding it to itself. I'm stumped on how to perform a right shift. Any thoughts would be greatly appreciated. I have AND, NOT, ADD operations, data movement operations, seven registers to store values and whole range of

Where is -32768 coming from?

北城以北 提交于 2019-11-29 17:25:08
This is LC3 Assembly code I am working with .ORIG x3000 LOOP LDI R0, KBSR BRzp LOOP From LC3 Assembly , I know that LDI is a load indirect addressing mode, meaning it read in an address stored at an location and then read the value at that location From Lc3 Keyboard , I know that KBSR is the keyboard status register, which is one when keyboard has received a new character. Here is my test run in Lc3 simulator? I entered the character 'a' After executing LDI R0, KBSR, register 0 stores a value of -32768. Does anyone know, based off my definitions for ldi and KBSR where this number is coming