return, reserve, align

This commit is contained in:
pommicket 2021-11-13 14:13:16 -05:00
parent 147fb9ccca
commit 2507f4b196
3 changed files with 150 additions and 4 deletions

View file

@ -16,12 +16,12 @@ x4b
:label :label
1B=C 1B=C
; :l ba b ; :l ba b
;J=d0 J=d0
A=d60 A=d60
syscall x3c syscall x3c
;;;;;;;;;;;;;;;;;;;;;;;align align
:label :label
;;;;;;;;;;;;;;;;;;;;;;;reserve d1000 reserve d1000
B+=J B+=J
B<=d9 B<=d9
B-=J B-=J
@ -30,7 +30,7 @@ B-=J
?A>B:label ?A>B:label
A=:label A=:label
x3c x3c
;;;;;;;;;;;;;;;;;;;;;;;return return
;;;;;;;;;;;;;;;;;;;;;;;*- ;;;;;;;;;;;;;;;;;;;;;;;*-
;;;;;;;;;;;;;;;;;;;;;;;/- ;;;;;;;;;;;;;;;;;;;;;;;/-
;;;;;;;;;;;;;;;;;;;;;;;*+ ;;;;;;;;;;;;;;;;;;;;;;;*+

142
03/in02
View file

@ -233,6 +233,51 @@ im
##1. ##1.
je je
:-st :-st
im
--RE "reserve"
IA
im
--LI
JA
im
--s=
cl
BA
im
##1.
je
:-re
im
##a.
CA set '\n' as terminator
im
--RT "return"
IA
im
--LI
JA
im
--s=
cl
BA
im
##1.
je
:-rt
im
--AL "align"
IA
im
--LI
JA
im
--s=
cl
BA
im
##1.
je
:-al
jm jm
:-ex :-ex
// handle += instruction // handle += instruction
@ -1834,6 +1879,30 @@ im
cl cl
jm jm
:-rl next line :-rl next line
// handle "reserve <number>"
::re
im
##8.
BA
im
--LI
+B
BA
im
--nu
cl
IA offset
im
##4. output fd
JA
im
##1. whence = SEEK_CUR
DA
im
##8. syscall 8 = lseek
sy
jm
:-rl next line
// handle "syscall <number>" // handle "syscall <number>"
::sy ::sy
im im
@ -2047,6 +2116,55 @@ jm
::x$ ::x$
AJ AJ
re return re return
// deal with "return"
::rt
im
--Rt
IA
im
##1.
DA
im
--wr
cl
jm
:-rl next line
// deal with "align"
::al
// first get current address
im
##4. output fd
JA
zA
IA offset = 0
im
##1. whence = SEEK_CUR
DA
im
##8. syscall 8 = lseek
sy
BA
im
##8.
+B
BA
im
##fffffffffffffff8.
&B
// okay rax now holds address we should seek to
IA offset
zA
DA whence = SEEK_SET
im
##4. output fd
JA
im
##8. lseek
sy
jm
:-rl next line
::Rt
re
// bad instruction // bad instruction
::!i ::!i
im im
@ -2169,6 +2287,30 @@ jm
't 't
'r 'r
20 20
::RE "reserve" text
'r
'e
's
'e
'r
'v
'e
20
::RT "return" text
'r
'e
't
'u
'r
'n
\n
::AL "align" text
'a
'l
'i
'g
'n
\n
::IF input file name ::IF input file name
'i 'i
'n 'n

View file

@ -1,3 +1,7 @@
return
str Hi
align
return
J=d1 J=d1
I=:hello_world I=:hello_world
D=:hello_world_end D=:hello_world_end