Binary LC-3二进制指令练习

Binary LC-3二进制指令练习,binary,simulator,lc3,Binary,Simulator,Lc3,这是我现在拥有的LC3模拟器的代码: 0011000000000000 0101010010100000 0010011000010000 1111000000100011 0110001011000000 0001100001111100 0000010000001000 1001001001111111 0001001001100001 0001001001000000 0000101000000001 0001010010100001 0001011011100001 0110001011

这是我现在拥有的LC3模拟器的代码:

0011000000000000 0101010010100000 0010011000010000 1111000000100011 0110001011000000 0001100001111100 0000010000001000 1001001001111111 0001001001100001 0001001001000000 0000101000000001 0001010010100001 0001011011100001 0110001011000000 0000111111110110 0010000000000100 0001000000000010 1111000000100001 1111000000100101 0011000100000000 0000000000 110000

它是一个程序,识别整个字符串中的单个字符,然后输出找到该字符的次数

我有两个问题

1) 该代码的工作原理是,它输出我在字符串中找到某个字母的次数。。。但是我需要修改它,以便它在内存中建立一个找到字符的地址列表。。我需要让这个列表从内存位置x3200开始

2) 仅当在0-9次之间找到字符时,代码才起作用。。我需要修改它,使其从0-99次工作


我不是在问答案。。。如果有人给我指点怎么做我会很感激的。。。谢谢

好吧,我想我开始对这个问题有了更多的了解。我创建了一个二进制文件,然后将其加载到LC3的模拟器中,以生成一些可读的asm。以下是我得到的:

Memory:
 x3000  0101010010100000  x54A0  AND    R2, R2, #0     // Clear R2
 x3001  0010011000010000  x2610  LD     R3, x3012      // load the the value stored at x3012 into R3
 x3002  1111000000100011  xF023  TRAP   IN             // input char
 x3003  0110001011000000  x62C0  LDR    R1, R3, #0     // load the value of memory R3 into R1
 x3004  0001100001111100  x187C  ADD    R4, R1, #-4    // Add -4 to R1 to see if we have reached the end of our string
 x3005  0000010000001000  x0408  BRZ    x300E          // Output result, end program if we run into an x0004 in the string
 x3006  1001001001111111  x927F  NOT    R1, R1         // invert the char from the 
 x3007  0001001001100001  x1261  ADD    R1, R1, #1     // stored string
 x3008  0001001001000000  x1240  ADD    R1, R1, R0     // compare with the char entered by the user
 x3009  0000101000000001  x0A01  BRNP   x300B          // If the chars don't match grab another char from the string
 x300A  0001010010100001  x14A1  ADD    R2, R2, #1     // R2 is our char counter, counts the number of times we find
                                                       // the user's char in the string
 x300B  0001011011100001  x16E1  ADD    R3, R3, #1     // increment our memory pointer
 x300C  0110001011000000  x62C0  LDR    R1, R3, #0     // load the value of memory R3 into R1
 x300D  0000111111110110  x0FF6  BRNZP  x3004          // Jump to      x3004
 x300E  0010000000000100  x2004  LD     R0, x3013      // Load the value of      x30 into R0
 x300F  0001000000000010  x1002  ADD    R0, R0, R2     // Add      x30 to our count to convert it to ASCII
 x3010  1111000000100001  xF021  TRAP   OUT            // Output the count to the user
 x3011  1111000000100101  xF025  TRAP   HALT           // Stop the program
 x3012  0011000100000000  x3100  ST     R0, x2F13      
 x3013  0000000000110000  x0030  NOP
为了帮助您开始您的第一个问题,我将做一些类似于R3如何使用的事情。将内存位置x3200加载到未使用的寄存器中,然后每次在该内存位置中存储地址时将其递增。例如:

LD R5, x3013      // store x3200 in the memory location x3013
.
.                 // if the chars match then do the following
.
STR R3, R5, #0    // Store the value of R3 into the mem of R5
ADD R5, R5, #1    // increment R5

至于第二个问题,它只输出值0-9的原因是,通过添加x30将计数值转换为ASCII字符。这对于前10个整数很好,但是你必须要有点创意才能添加第二个数字


希望这有帮助

有没有办法在asm中发布代码?这将使回答您的一些问题变得更容易。对不起,我还没有学会这个符号,所以我不知道如何用asmI来写它。我不知道这是否太复杂,或者是否有其他更简单的方法来做?还有,很抱歉它的格式。我试着把它分成几段,但我帮不了梅格拉德。因为您使用的是单个ASCII字符,所以我可能会这样做。我不确定是否有更简单的方法。请记住,如果我的解决方案有助于将其标记为已回答。好的,再次感谢您的帮助!我把它标为已回答