Jump to Subroutine & Jump Return instruction on DLX Program
Example code
Jal subroutine name
Sub routine
Jr r31 to return to main program
Example Jump to Subroutine & Jump Return instruction on DLX Program
.start main ;Start program and jump to label main
main:
jal calculator;jump and link to calculator
halt ; halt program after executing calculator sub routine
calculator: ;calculator sub routine
add r1,r2,r3
jr r31 ;back to main method and execute halt statement
0 comments:
Post a Comment