r/lc3 • u/Odd-Statistician6775 • Nov 27 '24
r/lc3 • u/toasterstove • May 30 '19
Half naked women get thousands of upvotes; how many for our boys in blue?
r/lc3 • u/Fine-Nectarine544 • Oct 27 '21
Can anyone help me with my hw?
Using the LC-3 simulator, you will construct an assembly-level program that prompts the user for a starting address (in hex) and an ending address (in hex). Your program will then output the contents of memory (in hex) between the provided ranges (inclusive).ย An example execution of the memory dump routine might look like this:
Enter starting memory address:
x3000
Enter ending memory address:
x3001
Memory contents x3000 to x3001:
x3000 xF030
x3001 xF025
I/O for this routine requires that you develop a routine to enable the input of a 4-digit hex value and a routine for displaying the contents of a 16-bit registers/memory location as a 4-digit hex value.ย You should implement EACH of these two functions as separate user TRAPs according to these specifications:
Input (Trap x40): A Trap routine (invoked as TRAP x40) that reads a 4-digit hex from the keyboard and returns the value in R0. This trap may call other traps. You will develop this trap routine and locate it in memory at address x4000.
Output (Trap x41): A Trap routine (invoked as TRAP x41) that displays the contents of R0 to the display as a 4-digit hex value. This routine should output exactly 5 characters: a leading โxโ and the 4 hex digits. Do not display a carriage return/line feed/end-of-line as part of the trap call. This trap may also call other traps. You will develop this trap routine and locate it in memory at address x5000.
Develop these TRAP routines and the use them to implement a program to perform memory dumps (using the i/o format provided in the example above).
Note: The representation for output characters (ASCII) is different than the standard binary representation of the value. For example, you may find it useful to note that the ASCII representation for any single-digit value is #48 greater than the number itself. Thus, the ASCII representation of the character 0 has value #48 (x30) while the ASCII representation of the character 1 has value #49 (x31).
r/lc3 • u/proton919 • Oct 24 '17
How do I double the value in a register in one cammand line
Also how do I or two registers using luv3 instructions How do I set nzp according to the value of a register
r/lc3 • u/Luviashke • Apr 03 '18
Negative hex? x-65
I'm studying for my programming class and I stumbled across this LC3 command
LD R1 x-65
How can a hex command have a negative sign? What does that even mean?
Am I supposed to convert that into binary or something? x65 equals decimal 101, which is binary 01100101, and the negative representation of that would be 10011011... Or maybe I'm going off on a crazy tangent...
Lol halp pls :)
r/lc3 • u/IntegralCosecantXdX • Apr 16 '16
Matrix Operations Help
Hello,
I have a project in my Computer Engineering class about coding in LC-3. The project is performing various operations on matrices, such as shifts and transposes. I can use subroutines.
Could anyone give me some insight as to how I can do this? Thanks!
r/lc3 • u/TooFewChars • Oct 08 '16
Fun way to crash the LC-3
Here's how to crash the LC-3 simulator:
Set R0 to x3000 Set the x3000 slot to x3000 (see below for how it works)
Make sure that the PC is set to the x3000 slot, and run the code. This should crash the simulator.
HOW IT WORKS
The code x3000 tells the processor to store the value of R0 to the memory slot below the instruction. R0 is also x3000, so when the PC is set to next slot, it runs x3000 again. This becomes a loop that crashes the sim very fast. Try it!
r/lc3 • u/[deleted] • Feb 29 '16
lc3 edit download for windows? simulator was easy to find/download
it would be nice to be able to use LC3 Edit on my personal laptop
r/lc3 • u/ncstateman • Dec 06 '13
Weekly Challenges
I propose we have a simple weekly coding challenge to practice programming in lc3. Do something like find all prime numbers between 50 and 500.
HELP WITH LC3 PROGRAM
Can someone please assist me with my Lc3 assembly program shown below?
My task is to write a program which asks the user to enter three numbers between 1-9, store them in the registry and print them to the console. The program should then display the smallest of the three numbers which have been entered.
I have managed to write the first bit correctly (entering the three numbers, storing and printing) but am struggling to display the smallest of the three numbers:
.orig x3000
lea r0, numberstring1 ;load address of string 1 to r0
puts ;print the string
getc ;get a character store in r0
out ;print a character from r0 to the screen
ld r2, minus48
add r2, r2, r0 ;copy real number from r0 to r2
lea r0, numberstring2 ;load address of string 2 to r0
puts ;print the string
getc ;get a character store in r0
out ;print a character from r0 to the screen
ld r3, minus48
add r3, r3, r0 ;copy real number from r0 to r3
lea r0, numberstring3 ;load address of string 3 to r0
puts ;print the string
getc ;get a character store in r0
out ;print a character from r0 to the screen
ld r4, minus48
add r4, r4, r0 ;copy real number from r0 to r4
halt
numberstring1 .stringz "\nPlease enter number 1: "
numberstring2 .stringz "\nPlease enter number 2: "
numberstring3 .stringz "\nPlease enter number 3: "
numberstring4 .stringz "The smallest number is: "
minus48 .fill -48
.end
Any assistance would be greatly appreciated.
Thanks
r/lc3 • u/BombSquadInc • Apr 09 '18
Line with slope from user
Iโm doing a code for a class that requires me to draw a line with a slope and y intercept given by the user. I can draw the line without a slope but canโt get a slope to work. Does anyone know the math behind that and how to put in in LC-3?
r/lc3 • u/CosmicCartographer • Dec 09 '16
L3C Display options?
I'm working on a project for class and so far I've got it to work just right, except when I print to the console, it goes too far down and a lot of my results are lost. I'm trying to find any commands to scroll up/down but I cant seem to find anything online. Any help?
r/lc3 • u/Maxiplexi • May 04 '13
.FILL pseudo-op displayed as JMP in simulator
Hello!
I'm working with the LC-3 as part of a university assignment, and I discovered something about the LC-3 simulator (included with the Patt & Patel textbook) that I don't quite understand.
Whenever I write .FILL as part of my program, it seems to come up as JMP in the simulator. It's actually causing me a bit of grief with my assignment, because instead of simply storing a value I specify at a memory address, the .FILL command causes the program to JMP to an address stored in some register.
Do you have any idea why this might be?
Thanks for any help in advance :)
r/lc3 • u/supersayanftw • Aug 28 '20
WIP Python LC3 Assembler/Emulator
Hi! To get ready for the upcoming semester, I thought I'd challenge myself by writing an assembler/simulator for the LC3. It's WIP and any suggestions, ect. are welcome!
Note: I do intend to write an interface for this soon enough.
r/lc3 • u/ijustlovemath • Dec 11 '13
Video Series update
Hi all,
Due to a lack of feedback and a large amount of work to get the videos up to par, I never did end up making them. I've gotten some recent interest in this community from others and hope to make this series by the new year. With final exams running right now, I will not be free to start the project until late next week. Hopefully that's soon enough to help those of you who need it.
Until then, I'd definitely recommend reading a bit of Patt and Patel's Introduction to Computing Systems. It's a great resource on LC3.
Happy coding!
r/lc3 • u/[deleted] • Mar 13 '17
LC3 Notepad++ Dark Theme
I liked the Notepad++ theme that this guy made. I use a dark theme for my N++ and all my IDEs though, so it didn't quite fit with it. I modified it to be dark, and specifically to match the N++ Waher Style theme.
Besides coloring, I made two changes to the style:
Instructions that set the condition code are colored differently from instructions that do not (light purple and dark purple respectively). This should make it a little easier to figure out where it was last set when you get to a branch statement.
The numbers, both decimal and hex, were not being colored correctly. To get it to work correctly I had to explicitly define all decimal numbers from -1024 to +1024. It's due to the constraints N++ gives you in defining number formats, specifically it doesn't like #- preceding a number if you define # as the prefix. You would need to use both #- and # as prefixes, which would preclude you from making a number style for hex values.
r/lc3 • u/4head4head1 • May 06 '16
LC3 specific character
How to check if the user entered the valid character in LC3 "Assembly Language"? For example, I want the entered characters between 0 through 9, or letters from A through F? Like if the user entered any other characters it will not be printed in the console. I'm very bad at LC3, as I only started learning this a month ago. Any help is appreciated. Thank you.
r/lc3 • u/Beard_and_Weird • Nov 06 '16
Char occurrence help please
Hey guys, so I just started a computer systems course and I am completely new to the LC3 machine and how it's programming works. I have an assignment due on Tuesday(Nov. 8th) I have been watching videos and still am having problems. Could someone please help me with this program and possibly explain it a bit or point me in the direction of some videos that will help me figure it out please. I am desperate at this point and don't want to fall behind in the class or get an F on the assignment. please and thank you! The specs for the assignment are on this website under the assignment link (the one that says its due 11/6). https://users.cs.fiu.edu/~pestaina/cda3103.html Thank you guys in advance!
r/lc3 • u/[deleted] • Apr 20 '17
LC-3 assembly language Help!!
Hello, I am new to this and am needing help with Asking user for number input including spacing, printing out what user has entered, enter key goes onto next step. Count of how many numbers where entered, smallest number, biggest number and numbers in order. No negative numbers can be entered.
r/lc3 • u/WUTDO11231235 • Nov 10 '16
XOR in LC3?
How can I XOR two values in LC3? I'm trying to figure out a way to XOR R1 and R2 and store it in R0 and using ONLY those three registers.
I came up with X XOR Y = [(xy')' & (x'y)']'
using demoregans, but I can't figure out a way to XOR R1 and R2 using only the 3 regiusters. R1 and R2 should hold the values to be XOR'd and R0 should store the result. How do I do this?
r/lc3 • u/ijustlovemath • Feb 18 '13
Welcome to /r/LC3! Feel free to ask questions about this subreddit in this thread, and I'll do my best to answer them.
r/lc3 • u/[deleted] • Apr 22 '17
Changing LC3 program to find smallest number from 2 inputs
How and what do i change to find smallest number from two number inputs. The code I provided below finds the biggest of 2 inputs.
.orig x3000
Lea r0, numString1
puts
getc
out
add r1, r0, 0
Lea r0, numString2
puts
getc
out
add r2, r0, 0
Lea r0, outString ;load the address of outString to R0
puts ;print to the screen
not r4, r2 ;turn second number to negative form
add r4, r4, 1 ;then store in r4, we want to check if (number1-number2) > 0
add r3, r1, r4 ;store the difference to r3 = (number1-number2)
brp firstNumberIsBigger ;if r3 is positive, print first number is bigger else go to next line
add r0, r2, 0 ;copy second number to r0
out ;print out
brnzp FINISH ;go to finish
firstNumberIsBigger ;label firstNumberIsBigger
add r0, r1, 0 ;copy first number to r0
out
FINISH
Halt
r/lc3 • u/ijustlovemath • Mar 22 '13
LC3 Tutorial thread
Hey everyone! By request, I'm putting together a series of videos explaining different aspects of the LC3 language and its implementations. To save time, I've sought out several preliminary lectures that will give you an understanding of the 2's complement data type and a few other important details that are critical to understanding the LC3 and its functions. I'll be sure to update this post with links as I get to them.
What is the 2's complement data type?
Episode List
Memory and Registers (Coming May 20th)
Address Space and Addressability
Labels and Assembler caveats
"NOT" in LC3
"AND" in LC3
"ADD" in LC3, please make sure you understand 2's complement before starting this one!
"LD" in LC3
"LDI" in LC3
"LDR" in LC3
LD vs LDI vs LDR (static vs dynamic operations)
"ST" in LC3
"STI" in LC3
"STR" in LC3
ST vs STI vs STR
BR and condition codes
TRAP vectors
JSR and RET for subroutines
JSRR and RET for subroutines
Long episode: Creating a multiplication subroutine
Final episode: Deconstructing the matrix multiplication code
Again, please post requests in the comments if you have any. I'm balancing a full courseload with this project, but hope to have it done soon, as the videos will be short and sweet.
Thanks guys!