Language
Bash script
Compiler
bash 5.0.17(1)-release
Options
gcc -o test test.s driver.c
./test
.global my_subroutine
my_subroutine:
pushq %rbp
movq %rsp, %rbp
subq $64, %rsp
movq %rdi, -64(%rbp)
# try to print the first character
movq -64(%rbp), %rdi # restore the saved pointer
#movzx (%rdi), %edi # read a character
movzb (%rdi), %rdi
call putchar
# try to print the second character
movq -64(%rbp), %rdi # restore the saved pointer
movzx 1(%rdi), %edi # read a character
call putchar
movq %rbp, %rsp
popq %rbp
ret
void my_subroutine(const char*);
int main(void) {
my_subroutine("Hello World!");
return 0;
}
$ bash prog.sh
He
Exit Code:
0