Skip to content

PratikMante/Simple-Assembler-in-Python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple-Assembler-in-Python

This is a simple 2 pass assembler code written in Python

Algorithm

  1. Read starting address from file and store it in a variable
  2. Write address, check mnemonic + register opcode and write them accordingly(hardcode mo & ro and check)
  3. if STOP in statement > write string & address
  4. if flag==1 > decrement address, update address as per ORIGIN
  5. if ele of SYMBOL in line > update symtab, address, value and length accordingly
  6. if “=” equals words[0] > update literal table
  7. if “=” ! in words & if lit count != 0 > update pool table
  8. increment address
  9. if ! END goto step 2 else close all files 10.Open all closed files in read mode and create pass2 file
  10. In loop of file2 > if Address in words > continue
  11. In loop of file1 > if words1[-1] == words2[-1] > write(words1[0]+words2[0]+words1[-1]) > flag=1
  12. if flag==0 > write(words1[0]+_________+words1[-1])
  13. Similarly check lit table with file1 & write to pass2
  14. goto 11 until loop ends
  15. Close all files

Flowchart

About

This is a simple assembler code written in Python

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages