31 lines
557 B
NASM
31 lines
557 B
NASM
.section data $0x1000 .. $0x1100 {
|
|
zstr: .zstring "This is a string"
|
|
str: .string "This is a string"
|
|
|
|
.export zstr
|
|
.export str
|
|
}
|
|
|
|
.section code $0x0 {
|
|
; Take the length of a zstr without those fancy "function calls" and "stack frames"
|
|
; %r0: the input string (in)
|
|
; %r1: the return address (in)
|
|
; %r2: the length of the string (out)
|
|
|
|
zstrlen:
|
|
mov %r2, %r0
|
|
ztrlen_loop:
|
|
cmpeq (%r2)u8, $0
|
|
zstrlen_end:
|
|
jmp %r1
|
|
|
|
main:
|
|
halt
|
|
|
|
.export main
|
|
}
|
|
|
|
.meta {
|
|
entry: main
|
|
}
|