Added negative offset case for JALR
This commit is contained in:
		
							
								
								
									
										19
									
								
								tests/jalr.s
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								tests/jalr.s
									
									
									
									
									
								
							@@ -12,17 +12,19 @@ _start:
 | 
				
			|||||||
    # Try to call two imbricated functions
 | 
					    # Try to call two imbricated functions
 | 
				
			||||||
    jal fn0
 | 
					    jal fn0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # Jump to 'just_after'
 | 
				
			||||||
    auipc ra, 0
 | 
					    auipc ra, 0
 | 
				
			||||||
    jalr 12(ra)
 | 
					    jalr 16(ra)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # Jump far to test jalr with negative offset
 | 
				
			||||||
 | 
					    jal fnfar
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ebreak
 | 
					    ebreak
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# just_after : address is 12 bytes after auipc
 | 
					# just_after : address is 16 bytes after auipc
 | 
				
			||||||
just_after:
 | 
					just_after:
 | 
				
			||||||
    # ra must still be the old address
 | 
					    # ra must still be the old address
 | 
				
			||||||
    addi a0, zero, 0
 | 
					 | 
				
			||||||
    ret
 | 
					    ret
 | 
				
			||||||
    addi a0, zero, 1
 | 
					 | 
				
			||||||
    ebreak
 | 
					    ebreak
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# fn0 : function that calls fn1 and returns
 | 
					# fn0 : function that calls fn1 and returns
 | 
				
			||||||
@@ -46,3 +48,12 @@ fn0:
 | 
				
			|||||||
fn1:
 | 
					fn1:
 | 
				
			||||||
    ret
 | 
					    ret
 | 
				
			||||||
    ebreak
 | 
					    ebreak
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					fnneg:
 | 
				
			||||||
 | 
					    addi a0, zero, 0
 | 
				
			||||||
 | 
					    ebreak
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					fnfar:
 | 
				
			||||||
 | 
					    auipc ra, 0
 | 
				
			||||||
 | 
					    jalr -8(ra)
 | 
				
			||||||
 | 
					    ebreak
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user