lc3

Print contents of register to console in LC3 Assembly

♀尐吖头ヾ 提交于 2019-12-24 11:28:38
问题 Say I have a value (eg. 1234) that I load into R0. How could I print this value to the console? 回答1: I'm assuming you would like to print a number out to the console but you're getting random characters if anything. This happens when the LC3 tries to interpret your number as an ASCII character. Example: The number 8 in ASCII is the backspace character. To make your program work you will need to add 48 (decimal) or x30 (hex) to your number before you can print it to the console. .ORIG x3000

LC3 LEA instruction and the value stored

試著忘記壹切 提交于 2019-12-24 10:46:56
问题 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 please help? Many thanks! .ORIG X3700 LEA R0, A LDI R2, C LDR R3, R0, 2 AND R1, R1, #0 IN ST R0, D JSR F HALT F LD R1, B ADD R1, R1, #1 BRp F RET A .FILL X1234 B .FILL X370B C .FILL X370C D .BLKW 2 E .STRINGZ "ABCD" G .FILL X1234 .END 回答1: The

VHDL STD_LOGIC_VECTOR Wildcard Values

ぐ巨炮叔叔 提交于 2019-12-21 12:32: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

LC3 Assembly Bitwise Right Shift

前提是你 提交于 2019-12-19 06:56:33
问题 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

How does LEA instruction store address of A?

陌路散爱 提交于 2019-12-18 09:47:35
问题 This is based off this question LEA instruction Here is the code segment I have a question about .ORIG X3700 LEA R0, A ..... A .FILL X1234 @Paul R, the answer responder, said that "The origin of the code is x3700, and you have 12 instructions, so the address of A will be x3700 + x0C = x370C. As you guessed, LEA R0,A loads the address of A into R0, so R0 will contain x370C after that first instruction has been executed." I agree with the first part of what Paul said, his reasoning for why the

How would you go about converting a stored Hex value to it's binary equivalent using lc3/assembly code?

你说的曾经没有我的故事 提交于 2019-12-14 02:40:02
问题 The values are stored in a .BLKW object and are loaded in a LOOP with LDR R0,R1,0 - ADD R1,R1,1 (to increment the .BLKW address). The problem is how do you convert the stored HEX values to their binary values, and then output the conversion to the CONSOLE in 16-bit binary format. Any ideas will be greatly appreciated! I've thought about ANDing values, but am unsure how to go about it. 回答1: You've already got the loop down. However, one small error. We know that when we use OUT to print, it

How do I write a program that prints out “Hello World”, 5 times using a loop in LC3?

送分小仙女□ 提交于 2019-12-13 11:09:43
问题 .ORIG x3000 COUNTER .FILL x0005 LEA R0, HELLO_WORLD PUTS HALT HELLO_WORLD .stringz "Hello World this is John Cena!" .END This is the code I have so far for just writing the name once, I'm confused how to implement the loop into this code so that the name will be displayed 5 times. 回答1: Printing Hello World! 5 Times using a loop: ; +++ Intro to LC-3 Programming Environment +++ ; Print "Hello World!" 5 times ; Use Loops to achieve the aforementioned output ; Execution Phase .ORIG x3000 LEA R0,

How to add 2 numbers in lc3 to get a sum of 4 digits?

时间秒杀一切 提交于 2019-12-13 07:43:09
问题 So far i have made a code that add 2 numbers but they are single digits. .orig x3000 lea r0, string1 puts getc out add r1, r0, 0 ld r0, minus48 add r1, r1, r0 lea r0, string1 ;input one puts LOOP getc out add r2, r0, 0 ld r0, minus48 add r2, r2, r0 add r3, r1, r2 out OUTSIDE lea r0, string2 ;input two puts ld r0, plus48 add r0, r3, r0 out HALT plus48 .FILL 48 minus48 .FILL -48 string1 .stringz "\nPlease enter a number: " string2 .stringz "\nSum is: " .end and this works fine however I've been

How do i do a bitshift right in binary?

天涯浪子 提交于 2019-12-13 05:42:36
问题 Hopefully this is a simple question but I cannot for the life of me figure out how to do a bitshift in binary. This is being done in the LC3 environemnt. I just need to know how to arithmetical divide by two and shift to the right. I know going left is simple by just adding the binary value to itself, but I have tried the opposite for bitshift right(subtracting from itself, NOTing and then subtracting etc etc.) Would be much appreciated. Or if you have a better way to move x00A0 to x000A that

Binary Right Shift, Given Only Addition

杀马特。学长 韩版系。学妹 提交于 2019-12-13 05:40:05
问题 I am working on a project where I am reading memory locations and need to output their hex value in ASCII. The language gives me a 16 bit word length, so I have a need to divide to grab a nibble at a time to convert to hex. Unfortunately, the language only offers and, or, not, and add for mathematical/logical functions. I've figured I can create the desired effect by left shifting and testing for a negative flag to add a 1 to the end after shifting, but I'm figuring there has to be a better