lc3

LC-3 STR with R1 as offset

风格不统一 提交于 2021-01-28 06:39:25
问题 I'm having trouble getting this subroutine I'm writing to work. Basically, I am trying to have a subroutine where I would set R0 to a value in some array (R3) with an offset of R1 . R0_ORIGINAL .FILL 0 R1_ORIGINAL .FILL 0 R2_ORIGINAL .FILL 0 R3_ORIGINAL .FILL 0 LOAD ST R0, R0_ORIGINAL ST R1, R1_ORIGINAL ST R2, R2_ORIGINAL ST R3, R3_ORIGINAL AND R0, R0, #0 ADD R0, R0, R2 BRz SKIP AND R3, R3, #0 LD R3, FIFTY ADD R1, R1, R3 SKIP AND R3, R3, #0 LEA R3, CIPHER_ARRAY STR R0, R3, R1 LD R0, R0

LC3 Assembly Square of N

梦想的初衷 提交于 2020-01-25 22:54:28
问题 Hi I'm trying to write a lc3 assembly program which computes the square of a number and stores it in r0, the integer is given as a parameter and is located in r1, the problem i noticed while debugging is during the first pass it initially adds 2, but the second pass it fails to add another 2 to r0 - My code is below any help is appreciated .orig x3FF8 ld r1,n ld r5,n square add r2,r1,#0 add r5,r5,#-1 add r0,r2,#0 brzp square brn theend theend halt n .fill #2 .end my final code thanks to the

Assembly Language - LDI

一个人想着一个人 提交于 2020-01-25 07:35:12
问题 I am having trouble figuring out weather to load a regisiter with the contents of the data in the regisiter or indirectly load the register with the address of the value when we execute LDI. Example: x3000 LDI R6, far x3001 ...(some command) x3002 ...(some command) x3003 far x6000 ... x6000 xf000 what is the data in R6 after excecuting x3000? 回答1: well take this for example .orig x3000 LDI R6, far ADD R0,R0,#0 ADD R0,R0,#0 far .fill x6000 .end assemble and dump hexdump -C test.obj 00000000 30

LC3 Bit Counter

故事扮演 提交于 2020-01-14 05:11:05
问题 I'm trying to figure out how to implement a bit counter in LC3 assembly language. ex: input "00001100001000001" output "000000000000100" I would be counting the number of ones in the string of bits and outputting that number in binary. I know how to do this given one bit at a time, but I don't know how I can analyze only one bit of a 16 bit string at a time. Thanks. 回答1: There are several different ways you can count the number of bits in a value stored in the LC3. You can use bit shifting

lc3 LDR instruction and the value stored

心已入冬 提交于 2020-01-04 01:18:39
问题 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 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

program for LC3 Assembly language

匆匆过客 提交于 2019-12-25 18:45:16
问题 How do you convert any character input from the user to its corresponding decimal value? I was just having trouble getting started. The program has to achieve the following things: The program accepts character from keyboard. If the character is a digit (‘0’ through ‘9’): a) Convert the character to its corresponding decimal value. In other words, ‘0’ becomes zero, ‘1’ becomes 1, ... ‘9’ becomes 9. Let’s call that value R (for “run length”). b) Wait for another character (using GETC). c)

Shouldn't R3 hold address x3307?

柔情痞子 提交于 2019-12-25 02:58:21
问题 I am doing a practice question from Question 7 Shouldn't the address I highlighted be x3307, not x3308? The way I reasoned this out was that (PC before 2nd instruction) = (PC after 1st instruction). The PC after 1st instruction is x3301. Therefore when the second instruction executes, the PC, x3301 will be incremented by 6 to x3307. Does everyone agree? Or did I miss something and R3 should actually store x3308? 回答1: PC-relative offsets are applied on top of the already incremented PC, that

Shouldn't R3 hold address x3307?

馋奶兔 提交于 2019-12-25 02:58:18
问题 I am doing a practice question from Question 7 Shouldn't the address I highlighted be x3307, not x3308? The way I reasoned this out was that (PC before 2nd instruction) = (PC after 1st instruction). The PC after 1st instruction is x3301. Therefore when the second instruction executes, the PC, x3301 will be incremented by 6 to x3307. Does everyone agree? Or did I miss something and R3 should actually store x3308? 回答1: PC-relative offsets are applied on top of the already incremented PC, that

LC3 assembly language - create 2 arrays, multiply, and add sums

二次信任 提交于 2019-12-24 15:23:21
问题 I am trying to figure out how to create two arrays (hardcoded), multiply them together (a[0]x b[0], a[1]x b[1] ...etc.) and then add the sums together and print it. I don't have much yet but that's because I am still getting used to this. Please please please help! What I have so far is listed below - .ORIG x3000 LEA R1, arr1 LEA R2, arr2 AND R3, R3, #0 ;index AND R4, R4, #0 ;total LOOP ADD R4, R3, #4 BRzp DONE ADD R5, R1, R3 LDR R6, R5, #0 ADD R4, R4, R6 ADD R3, R3, #-1 BR LOOP HALT arr1

How to load value of a memory address in a register in ASM on the LC3?

元气小坏坏 提交于 2019-12-24 15:10:13
问题 Suppose there's a value stored in memory location x4000 and I want to load it to a Register. If the program has to be started at x3000 how can I do this, since PC+Offset loads would be out of range? 来源: https://stackoverflow.com/questions/29898909/how-to-load-value-of-a-memory-address-in-a-register-in-asm-on-the-lc3