Questions tagged [lc3]

Little Computer 3 (LC-3) is an educational assembly language, designed to help teach low-level programming. It is run using an emulator, and does not run natively on any processor.

Little Computer 3 (LC-3) is an educational assembly language with 15 opcodes, designed by Yale N. Patt and Sanjay J. Patel and published in their textbook Introduction to Computing Systems: From Bits and Gates to C and Beyond, 2nd edition (2003).

It exists solely for educational purposes, and does not run natively on any existing processor. Existing emulation tools include an assembler, a compiler, and a simulator, all provided by McGraw-Hill.

References

361 questions
6
votes
2 answers

VHDL STD_LOGIC_VECTOR Wildcard Values

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…
Eric Townsend
  • 201
  • 2
  • 6
  • 13
6
votes
4 answers

LC3 Assembly Bitwise Right Shift

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…
Will Haynes
  • 758
  • 3
  • 8
  • 15
3
votes
1 answer

Stumped on Extended Multiplication for LC-3 Assembly

I'm trying to get Extended Multiplication to work on the LC-3. Relevant excerpts from my code: .ORIG x3000 ; Calculate AB = A x B LEA R6, ARGS LD R0, B STR R0, R6, #0 ; Store B into Multiplier address of ARGS JSR…
enharmonics
  • 259
  • 3
  • 9
3
votes
1 answer

lc3 LDR instruction and the value stored

I can't figure out why After instruction “LDR R3, R0, 2” is executed, the value stored in R3 is x370C. what does 2 stands for in this instruction? It doesn't look like an immidiate value. I understand that R0 contains x370C at this point. Can…
user4046073
  • 821
  • 4
  • 18
  • 39
3
votes
1 answer

LC3 LEA instruction and the value stored

I am confused by this question: What is the value stored in register 0 after instruction “LEA R0,A" is executed? How come the answer is x370C ? I reckon it is supposed to load the address of A into R0? If so how do we know the address? Can someone…
user3735871
  • 527
  • 2
  • 14
  • 31
3
votes
1 answer

My input code for LC-3 isn't working as intended

I've been working on this bit of code to take a string of input and to have it displayed after I hit the enter key, but it doesn't work for some reason and I can't figure out where I'm going wrong at all. I would love some help to figure this one…
user2293344
  • 77
  • 1
  • 3
2
votes
1 answer

LC-3 If/Else Statements

I have a problem with this LC-3 program, I can't get the string to display from the if/else statement. I don't know if I'm doing the statement wrong, or if I am displaying the string wrong. The goal is to have it display the IF when the user enters…
Jimmy
  • 57
  • 1
  • 5
2
votes
1 answer

How to negate the value in a Register in LC-3 assembly language?

I am new to LC-3 assembly language and writing a program that compares two characters. The program prompts the user to enter in a character to check for (I used GETC to load the user input into R0). The skeleton code I was given loads the negated…
Slippy
  • 93
  • 1
  • 10
2
votes
1 answer

How to do Math(subtraction, multiplication, factorial) and change output to hexadecimal in lc3?

I'm using a LC3 simulator and I want to change the output from decimal to hexadecimal, and as I said in the title I'm wondering how could I do Math operations in LC3. I'm very new to LC3 so I really need help.Thanks. ; ; Initialization ; …
Victoriavv
  • 93
  • 1
  • 9
2
votes
1 answer

Using a TRAP routine from within a subroutine? - LC3 Assembly

So, I have finished an assembly program that asks for a character, reads it, echos it, repeats that four times, then prints out those characters in a consecutive string. I then wanted to experiment with subroutines (which we haven't learned about in…
Alex
  • 64,178
  • 48
  • 151
  • 180
2
votes
2 answers

LC3 Assembly - How do I toggle the lowest order bit in a binary number?

I was wondering if there was a way to toggle the low order bit in binary. For example: 01000001 -> Toggle Low Order Bit -> 01000000 Changing the last bit on the right only. If you are unfamiliar with LC3 it only has the following…
Jacob
  • 113
  • 1
  • 10
2
votes
0 answers

LC3 Conversion from 16 bit to Assembly Language

How would I go about converting a given 16 bit string of 1s and 0s into Assembly language, and then output it onto the console? For example: Convert 0001001010000011 into "ADD R1 R2 R3".
2
votes
0 answers

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

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…
2
votes
2 answers

How can I write a simple LC-3 program

How can I write a simple LC-3 program that compares the two numbers in R1 and R2 and puts the value 0 in R0 if R1 = R2, 1 if R1 > R2 and -1 if R1 < R2.
Linus Gill
  • 53
  • 1
  • 1
  • 7
1
vote
1 answer

how to detect NaN from console input?

Am suppose to exit a loop when ctrl+d(x04) is typed in lc-3 so I'm trying to detect this from console input by using getc. Is there a easy way doing this? Or I have to convert input to a negative number and add with x04? Can some one help me?
pythoniku
  • 3,532
  • 6
  • 23
  • 30
1
2 3
24 25