Add value directives and strings

.string, .zstring, .u64, .u32, .u16, .u8 are used before an ImmValue to
determine how the memory should be laid out for that value.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2020-02-11 17:49:17 -05:00
parent 95d4eb0a60
commit cf9ba376aa
8 changed files with 158 additions and 24 deletions

45
examples/strings.asm Normal file
View File

@@ -0,0 +1,45 @@
data $0x1000 .. $0x1100 {
zstr: .zstring "This is a zero-terminated string"
.export zstr
}
code $0x0 {
zstr_len:
storeimm32 %r15, $0xFF
storeimm32 %r16, $1
storeimm64 %r20, zstr_next
storeimm64 %r21, exit_zstr
regcopy %r10, %r00
zstr_next:
load %r11, %r10
and %r11, %r15
cmpeq %r11, %null
jnz %r21
add %r10, %r16
jmp %r20
main:
storeimm64 %r05, zstr_len
storeimm64 %r00, zstr
jmp %r05
exit_zstr:
regcopy %status, %r10
halt
ineg %r00
add %r10, %r00
regcopy %status, %r10
end:
halt
.export main
}
meta {
entry: main
}