2

OK so i have two assembly .s files

the first function prototype is

void printCharacter( char c )

and in it I call printf to print the character

./global printCharacter

.section ".data"
format: .asciz "%c"

.section ".text"

printCharacter:
    save     %sp, -96, %sp

    set      format, %o0
    mov      %i0, %o1
    call     printf
    nop

The problem is that I'm calling this function from another file. In the other file, I have this at the top declared

    NewLine: .byte '\n'

and I use it like this

    set      NewLine, %o0
    call     printCharacter
    nop

In my other function 'printCharacter' it uses

    mov      %i0, %o1 

           instead of

    set      %i0, %o1

    since I use printCharacter function for normal characters
    as well so I can't use set

How do I use one function for both ASCII characters and something like \n that needs the 'set' command instead of mov?

The problem I get at the moment is that when I try to print a new line it prints out a ? in the terminal

4

0 回答 0