pretty much done 03 compiler!

This commit is contained in:
pommicket 2021-11-13 14:32:00 -05:00
parent 2507f4b196
commit c664b4e61b
3 changed files with 145 additions and 9 deletions

View file

@ -31,10 +31,10 @@ B-=J
A=:label A=:label
x3c x3c
return return
;;;;;;;;;;;;;;;;;;;;;;;*- imul
;;;;;;;;;;;;;;;;;;;;;;;/- idiv
;;;;;;;;;;;;;;;;;;;;;;;*+ mul
;;;;;;;;;;;;;;;;;;;;;;;/+ div
:funciton :funciton
call A call A
str Here is some text which will be put in the executable! str Here is some text which will be put in the executable!

140
03/in02
View file

@ -278,8 +278,64 @@ im
##1. ##1.
je je
:-al :-al
im
--U* "mul"
IA
im
--LI
JA
im
--s=
cl
BA
im
##1.
je
:-u*
im
--S* "imul"
IA
im
--LI
JA
im
--s=
cl
BA
im
##1.
je
:-s*
im
--U/ "div"
IA
im
--LI
JA
im
--s=
cl
BA
im
##1.
je
:-u/
im
--S/ "idiv"
IA
im
--LI
JA
im
--s=
cl
BA
im
##1.
je
:-s/
jm jm
:-ex :-!i
// handle += instruction // handle += instruction
::+= ::+=
im im
@ -2165,6 +2221,66 @@ jm
:-rl next line :-rl next line
::Rt ::Rt
re re
// deal with "mul"
::u*
im
--+*
IA
im
##3.
DA
im
--wr
cl
jm
:-rl next line
// deal with "imul"
::s*
im
---*
IA
im
##3.
DA
im
--wr
cl
jm
:-rl next line
// deal with "div"
::u/
im
--+/
IA
im
##3.
DA
im
--wr
cl
jm
:-rl next line
// deal with "idiv"
::s/
im
---/
IA
im
##3.
DA
im
--wr
cl
jm
:-rl next line
::+*
+*
::-*
-*
::+/
+/
::-/
-/
// bad instruction // bad instruction
::!i ::!i
im im
@ -2311,6 +2427,28 @@ jm
'g 'g
'n 'n
\n \n
::U* "mul" text
'm
'u
'l
\n
::S* "imul" text
'i
'm
'u
'l
\n
::U/ "div" text
'd
'i
'v
\n
::S/ "idiv" text
'i
'd
'i
'v
\n
::IF input file name ::IF input file name
'i 'i
'n 'n

View file

@ -1,10 +1,8 @@
return ; write to stdout
str Hi
align
return
J=d1 J=d1
I=:hello_world I=:hello_world
D=:hello_world_end D=:hello_world_end
; calculate length by subtracting end from start
D-=I D-=I
syscall d1 syscall d1
J=d42 J=d42