Ali Kemal Tanrıverdi
Ali Kemal Tanrıverdi

Reputation: 13

Using Functions in the LC3 Assembly Language

I need to know how to write a simple function in LC3 and using it in the main program.

Upvotes: 0

Views: 1671

Answers (1)

Chris M
Chris M

Reputation: 651

It's just a matter of creating a label and then jumping to it. Once you're done with that subroutine then return back to the main code.

.orig x3000

    AND R0, R0, #0      ; clear R0

    JSR FUNCTION
    PUTc
    HALT                ; TRAP x25

FUNCTION
    ADD R0, R0, #10     ; Store the value of 10 into R0
    RET                 ; return back to the main code

.end

Upvotes: 2

Related Questions