Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IndexError while running AssemblyConverter().convert(file) #10

Open
Doomsk opened this issue Jul 4, 2021 · 2 comments
Open

IndexError while running AssemblyConverter().convert(file) #10

Doomsk opened this issue Jul 4, 2021 · 2 comments

Comments

@Doomsk
Copy link

Doomsk commented Jul 4, 2021

I was just using the example from the documentation

from riscv_assembler.convert import AssemblyConverter
cnv = AssemblyConverter(output_type="bp")
cnv.convert("test.s")

but with my own assembly code. Then this index error raises:

IndexError                                Traceback (most recent call last)
<ipython-input-2-5a83df4fad26> in <module>
      1 from riscv_assembler.convert import AssemblyConverter
      2 cnv = AssemblyConverter(output_type="bp")
----> 3 cnv.convert("test.s")

~/<dir>/python3.9/site-packages/riscv_assembler/convert.py in convert(self, filename)
    578                 self.filename = filename
    579                 self.code = self.__read_in_advance()
--> 580                 self.instructions = self.__get_instructions()
    581 
    582                 if self.hexMode:

~/<dir>/python3.9/site-packages/riscv_assembler/convert.py in __get_instructions(self)
    413                         line = self.code[i]
    414 
--> 415                         response = self.__interpret(line,i)
    416                         if -1 not in response:
    417                                 instructions.extend(response)

~/<dir>/python3.9/site-packages/riscv_assembler/convert.py in __interpret(self, line, i)
    458                         #print(res)
    459                 elif clean[0] in self.S_instr:
--> 460                         res.append(self.S_type(clean[0], self.__reg_map(clean[3]), self.__reg_map(clean[1]), clean[2]))
    461                         #print(res)
    462                 elif clean[0] in self.SB_instr:

IndexError: list index out of range
@kcelebi
Copy link
Owner

kcelebi commented Jul 4, 2021

The code seems to be identifying a function that I had not included, if your test.s file is not too long could you reply with a screenshot? Otherwise, send me an email and we can continue this discussion privately.

@Doomsk
Copy link
Author

Doomsk commented Jul 4, 2021

No problem, it's short so I'll past it here:

.section .text
.align 2
.global start


.equ GPIOA_BASE_ADDR, 0x40010800

.equ GPIOA_OCTL, 0x0C
.equ GPIOA_OCTL_VAL, 0x01

.equ GPIOA_OCTL_RES, 0x0D

.equ GPIOA_CTL0_ADDR_OFFSET, 0x00
.equ GPIOA_OUTPUT_EN, 0x05

.equ PA1_GREEN_LED, 0x01
.equ PA2_BLUE_LED, 0x02


start:

	addi sp, sp, -16
	sd ra, 0(sp)
	
	li t0, GPIOA_BASE_ADDR

	
	li t1, GPIOA_OUTPUT_EN(PA1_GREEN_LED)
	sw t1, GPIOA_OCTL_RES(t0)
	

	ld ra, 0(sp)
	addi sp, sp, 16
	ret

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants