GithubHelp home page GithubHelp logo

261304-assemblysim's Introduction

Assignment Information: http://myweb.cmu.ac.th/sansanee.a/ComputerArchitecture/Y2022/Project1.htm

How to run: This will compile the assembly to machine code and save the compiled file then show the result from simulator. python .\main.py .\programs\example.s

If you want to run on a specific part:

  • Examples on how to use assembler: python .\assembler.py .\tests\files\t2.s

  • Examples on how to use simulator: python .\simulator.py .\tests\files\test_sim_example.bin

Unit Test: This will run all unit tests. python -m unittest discover

261304-assemblysim's People

Contributors

putawande avatar 0736b avatar riwez avatar min23asdw avatar bug-too avatar

Stargazers

 avatar

Watchers

 avatar  avatar

261304-assemblysim's Issues

chain address Assembly ?

image

ถ้าแบบเรียก เป็น ทอดๆ แบบนี้อะ beq มันจะกระโดดผิด ( ซึ่งมันอาจจะห้ามเขียนยังงี้?)

Simulator Unit Test doesn't work due to different tab spacing

Comparing the output from terminal with example output doesn't work. Due to different tab space setting across our IDEs. The tab space for the expected testcase which is supposed to be 8 spaces is always changing. FUCK TAB.

This issue is not urgent. We can fuck it for now.

No exception when label is number

Label should not be number and instruction should except when argument not match

test case

1 add 0 1  label should not be number
1 add 0

result:
image

Offset field should accept negative integer - assembler

Breaking testcase

lw 0 0 -1

Output

Traceback (most recent call last):
  File "D:\PUTAWAN\ComputerProjects\ComArch\261304-AssemblySim\assembler.py", line 25, in <module>
    main()
  File "D:\PUTAWAN\ComputerProjects\ComArch\261304-AssemblySim\assembler.py", line 20, in main
    for item in p.execute():
  File "D:\PUTAWAN\ComputerProjects\ComArch\261304-AssemblySim\assembler\asm_parser.py", line 41, in execute
    res[i] = node.evaluate(self.var_map)
  File "D:\PUTAWAN\ComputerProjects\ComArch\261304-AssemblySim\assembler\asm_ast.py", line 61, in evaluate
    if type(self.var) != int: raise Exception('I_ins immediate is not int')
Exception: I_ins immediate is not int

Expected output:

should pass, no exception

8454143

Exception: Instruction expected at:14

image

    lw 0 5 sstack   // stack = 30
    lw 0 6 one    //$(6) = 1
    lw 0 4 neq1 //&(4)  = -1
    addrfn     lw 5 1 0   // &(1) = #5[0]  .30
    lw 5 2 1   // $(2) = #5[1]  .31
    beq  1 2 jif   //if(n==r)  2if:
    beq  2 0 jif   //if(r==0)  2if: 
    add 1 4 1 // n-1
    add 5 6 5     // push stack
    add 5 6 5    // 5 += 2
    sw  5 1 0  // $(1) ->  #32
    sw  5 2 1  // $(2) ->  #33
    jalr 7 7
	beq 0 0 callfn
    add 2 4 2 // n-1
    add 5 6 5     // push stack
    add 5 6 5    // 5 += 2
    sw  5 1 0  // $(1) ->  #32
    sw  5 2 1  // $(2) ->  #33        
    jalr 7 7           
	beq 0 0 callfn
   beq 0 0 done               
   jif add 3 6 3         // return 1 (+1) // 3 += 1
   add 5 4 5     // pop stack
   add 5 4 5    // 5 += 2 
   add 0 7 6    // return pc+1
   beq 0 0 7    // back
   done    halt                        //end of program
   sstack .fill n 
   n .fill 3
   r .fill 2
   one    .fill  1
   neq1 .fill -1
   callfn  .fill   addrfn            //will contain the address of start

fix display memory

stack not dynamic
$5 ชี้ไปถึง address 55 ของ memory แล้ว
image

but numMemory still = 45 , number of initial memory line

beq to new pc instructions

(pc 11 -> pc13) แต่ pc 13 ไม่ได้ทำการ add ดูได้จาก ไม่ได้มีการ print ออกมา

image

image

แต่ pc 14 ยังคงทำงานได้

อาจมีข้อผิดผลาดในการ กระโดดซึ่งพอกระโดดแล้ว pc มีค่าที่ไม่ถูกต้อง ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.