simulator - LC-3 binary instructions exercise -


this code lc3 simulator have right now:

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

it's program identitfies single character in entire string , outputs number of times character found..

i have 2 questions..

1) code works outputs number of times find letter in string... need modify builds list in memory of addresses character found.. need make list start @ memory location x3200

2) code works if character found between 0-9 times.. need modify works 0-99 times

i'm not asking answer... appreciate pointers on how approach this...

alright think i'm starting understand problem little bit more. created binary file , loaded lc3's simulator produce readable asm. here's i've got:

memory:  x3000  0101010010100000  x54a0  ,    r2, r2, #0     // clear r2  x3001  0010011000010000  x2610  ld     r3, x3012      // load the value stored @ x3012 r3  x3002  1111000000100011  xf023  trap   in             // input char  x3003  0110001011000000  x62c0  ldr    r1, r3, #0     // load value of memory r3 r1  x3004  0001100001111100  x187c  add    r4, r1, #-4    // add -4 r1 see if have reached end of our string  x3005  0000010000001000  x0408  brz    x300e          // output result, end program if run x0004 in string  x3006  1001001001111111  x927f  not    r1, r1         // invert char   x3007  0001001001100001  x1261  add    r1, r1, #1     // stored string  x3008  0001001001000000  x1240  add    r1, r1, r0     // compare char entered user  x3009  0000101000000001  x0a01  brnp   x300b          // if chars don't match grab char string  x300a  0001010010100001  x14a1  add    r2, r2, #1     // r2 our char counter, counts number of times find                                                        // user's char in string  x300b  0001011011100001  x16e1  add    r3, r3, #1     // increment our memory pointer  x300c  0110001011000000  x62c0  ldr    r1, r3, #0     // load value of memory r3 r1  x300d  0000111111110110  x0ff6  brnzp  x3004          // jump      x3004  x300e  0010000000000100  x2004  ld     r0, x3013      // load value of      x30 r0  x300f  0001000000000010  x1002  add    r0, r0, r2     // add      x30 our count convert ascii  x3010  1111000000100001  xf021  trap   out            // output count user  x3011  1111000000100101  xf025  trap   halt           // stop program  x3012  0011000100000000  x3100  st     r0, x2f13        x3013  0000000000110000  x0030  nop 

to started first question, similar how r3 being used. load memory location x3200 unused register , increment each time store address in memory location. example:

ld r5, x3013      // store x3200 in memory location x3013 . .                 // if chars match following . str r3, r5, #0    // store value of r3 mem of r5 add r5, r5, #1    // increment r5 

as second question, reason why outputs values 0-9 because you're converting count value ascii char adding x30. great first 10 integers, you'll have little creative add second digit.

hope helps.


Comments

Popular posts from this blog

rewrite asp to php based on asp query -

android - questions about switching from C2DM to GCM -

visual studio 2010 - Error on RDLC Expression -