-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.asm
More file actions
2775 lines (2386 loc) · 51.2 KB
/
index.asm
File metadata and controls
2775 lines (2386 loc) · 51.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
def ABSOLUTE_CINEMA, 0
ifdef ABSOLUTE_CINEMA
link "test/p.asm"
link "test/g.asm"
fi
.data
string PrintThisLaterLol: "Test string"
intg len2 : $ - PrintThisLaterLol
.start
align 3
int 0x4
;cls
:startofprog
using "ios"
using "fs/host"
using "chrono"
using "cmanip"
using "mem"
using "net"
using "thread"
using "txtop"
using "ext"
using "tcp"
using "tuple"
using "http"
using "math"
.start
sysenter "cfg"
mov fdx, 1
mov rax, 1
syscall
mov rax, 1
syscall
fetch std::ios::writeln ; set the this ptr
jmp skiplol
./std
./lol
proc testproc
mov tlr, 1
mov fdx, 1
sysenter "ios"
syscall
halt 0
end
./!lol
./!std
call std::lol::testproc
:skiplol
.data
intg myintgber: 736
float mydecimal: 243.3
string mytext: "Hello World"
string shit: "LOL"
string return_vals: "null"
ref testreference: &return_vals ; we must provide a valid value
string threadarg : "hello from thread"
.start
jmp LMAOOOOOOOOOO
mov tlr, 24.234234.243
sysenter "math"
mov fdx, 1
mov tlr, *tlr
syscall ; -> error
:LMAOOOOOOOOOO
thread testthread -> {
__say 0,"thread debug 1"
__say 0,"thread debug 3"
__say 0,"thread debug 5"
__say 0,"thread debug 6"
__say 0,"thread debug 7"
__say 0,"thread debug 8"
__say 0,"thread debug 9"
__say 0,"thread debug 10"
mov tlr, "Hello from thread\n"
mov stl, 0c1
mov fdx, 1
sysenter "ios"
syscall
;db stl
;db tlr
;db fdx
;__say 0,"syscall ios"
mov fdx, 1
sysenter "chrono"
syscall
;__say 0,"syscall chrono"
mov fdx, 2
mov stl, 0c1
sysenter "ios"
syscall
mov tlr, "hi again"
mov fdx, 1
syscall
__say 0, "thread done"
mov tlr, "this was returned"
mov &shit, *tlr
retf shit
; this doesn't get executed !
sysenter "ios"
mov tlr, "YOU SHOULD NOT SEE THIS"
mov stl, 0c1
mov fdx, 1
syscall
}
thread testthread2 -> {
__say 0,"thread debug 2"
__say 0,"thread debug 4"
mov tlr, "hello from thread 2\n"
mov bos, 5
mov stl, 0c1
mov fdx, 1
sysenter "ios"
syscall
}
thread testthread3 -> {
mov tlr, "hello from thread 3\n"
mov bos, 5
mov stl, 0c1
mov fdx, 1
sysenter "ios"
syscall
}
int 0x3; auto bos
await &testthread ; wait for the thread to finish immediatelly
;if the thread doesn't finish, we will get ExpectedAwait error
sysenter "thread"
mov fdx, 1
mov tlr, &testthread
syscall ; display the thread output
mov fdx, 2
syscall ; fetch returned value
__say 0, "dbg 1"
sysenter "ios"
__say 0, "dbg 2"
mov stl, 0c1
__say 0, "dbg 3"
mov fdx, 1
__say 0, "dbg 4"
db tlr
syscall
__say 0, "dbg 5"
;db tr0
;db tr1
zero stl
mov tlr , mytext ;test
;mov stl , 0c1
mov fdx , 1
sysenter "ios"
syscall
mov tlr , 0c1
mov fdx , 5
syscall
mov tlr , mydecimal ; test comment again
mov fdx , 2
syscall
mov tlr , 0c1
mov fdx , 5
syscall
mov tlr , myintgber ; lol
mov fdx , 2
syscall
mov tlr , 0c1
mov fdx , 5
syscall
mov tlr, 87
;int 0x1 ; realloc
nop
nop
mov tlr, 1
;int 0x2
jmp label3543 ; skip diabolical error check below
mov tlr, yes
mov stl, 0c1
mov fdx, 1
sysenter "ios"
syscall
:label3543
;mipazuzuzu
.start
proc PROCEDURETEST
__say 0, "PROCEDURETEST called"
mov tlr , "Proc works"
__say 0, "mov tlr, proc works"
mov fdx , 1
__say 0, "mov fdx,1"
sysenter "ios"
__say 0, "sysenter 'ios'"
db tlr
db fdx
syscall
__say 0, "syscall"
mov tlr , 0c1
mov fdx , 5
syscall
halt "this was, in fact, returned"
end
nop
nop
nop
call PROCEDURETEST
sysreq &return_vals -> string
mov &return_vals, *psx
mov tlr , return_vals
mov fdx , 1
syscall
mov tlr , 0c1
mov fdx , 5
syscall
push "TEST"
.data
string testret : "0"
.start
pop &testret
mov tlr , testret
mov fdx , 1
syscall
__say 0,"debug1"
mov tlr , 0c1
mov fdx , 5
syscall
__say 0,"debug2"
mov fdx , 873
mov &myintgber, *fdx
__say 0,"debug3"
mov fdx , 3
syscall
__say 0,"debug4"
db tlr
mov fdx , 1
db tlr
db fdx
syscall
__say 0,"debug5"
mov tlr , 0c1
mov fdx , 5
syscall
__say 0,"debug6"
mov fdx , 4
syscall
mov fdx , 2
mov stl , 0c1
syscall
zero stl
push 6
pop nil
mov tlr , "LABEL TEST"
mov fdx , 1
syscall
mov tlr , 0c1
mov fdx , 5
syscall
jmp label2
:label
mov tlr , "label called"
mov fdx , 1
syscall
mov tlr , 0c1
mov fdx , 5
syscall
mov fdx , 72
jmp label3
ret fdx
:label2
mov tlr , "label2 called"
mov fdx , 1
syscall
mov tlr , 0c1
mov fdx , 5
syscall
jmp label
:label3
mov tlr , "label3 called"
mov fdx , 1
syscall
mov tlr , 0c1
mov fdx , 5
syscall
;pop %nl
push 863
heap 4
heap -3
.data
intg register_test : 0
.start
zero tlr
mov tlr , "stk is: "
mov fdx , 1
syscall
mov ®ister_test, *stk
mov tlr , register_test
mov fdx , 2
syscall
mov tlr , 0c1
mov fdx , 5
syscall
mov tlr , "hea is: "
mov fdx , 1
syscall
mov ®ister_test, *hea
mov tlr , register_test
mov fdx , 2
syscall
mov tlr , 0c1
mov fdx , 5
syscall
heap -1
mov tlr , "hir"
mov stl , 0c1
mov fdx , 1
syscall ; hii
db tlr
proc halttest
__say 0,"halttest called"
mov tlr , "proc called"
mov stl , 0c1
mov fdx , 1
syscall ; hi
halt "halt works"
end
zero stl
zero psx
call halttest
mov &mytext, *psx
mov tlr , mytext
mov stl , 0c1
mov fdx , 1
syscall ; test43
zero stl
mov tlr, "WORKS"
mov stl, 0c1
mov fdx , 1
syscall
proc resetstuff
mov stl , "loloool"
halt 1
end
.data
string teststring : "83"
float testdecimal : 0.0
float testfloat2 : 3.0
.start
call resetstuff
mov &teststring, *stl
zero stl
mov stl , 0c1
mov tlr , teststring
mov fdx , 1
syscall
jmp labeldownthere
: labeluphere
mov stl , 0c1
mov tlr , "Hi from up here !"
mov fdx , 1
syscall
jmp endofprog
: labeldownthere
mov stl , 0c1
mov tlr , "Hi from down here !"
mov fdx , 1
syscall
jmp labeluphere
: endofprog
mov stl , 0c1
mov tlr , "Bye !"
mov fdx , 1
syscall
;retn 0 , myintgber
mov tlr , "heapalloc test"
mov fdx , 1
syscall
; heap 0 , 1 -> no need for this because:
; hea : 0
; Addresses start from 0, heap pointer is by default at 0
; so to be memory efficient, we don't need to allocate
; more space if we already have 1 cell allocated
; DEPRECATED; NOW WE USE REAL HEAP
; If the suffix of the LOAD instruction is `*`,
; then we will update the value in the address heap pointer
; is pointing to - HOWEVER, if the suffix is `&`, then we will
; store the value in the address heap pointer is pointing to
; into some variable in `.data`
malloc 4 ; allocate 4 bytes
mov hea, [0] ; set hea to the first byte inside malloc
; floats take up 4 bytes
mov imm, 1
load 736.38 ; hea = something
mov imm, 2
load &testdecimal ; myvar = hea
free nil ; be responsible
mov tlr , testdecimal
mov stl , 0c1
mov fdx , 2
syscall
; Allocate more space:
malloc 4
mov hea, [0]
mov imm, 1
load 9821.38 ; hea : 63
mov imm, 2
load &testfloat2 ; myvar : hea
mov tlr , testfloat2
mov stl , 0c1
mov fdx , 2
syscall
mov tlr, *hea
;mov hea , 0 ; manually access the first address ----------> very bad idea
mov hea, [0]
heap 4
heap -4 ; for testing
mov imm, 2
load &testfloat2 ; myvar : hea
free nil
mov tlr , testfloat2
mov stl , 0c1
mov fdx , 2
syscall
; ANOTHER BAD IDEA mov hea , 1 ; manually access the second address
malloc 4
mov hea, [0]
mov imm, 2
load &testfloat2 ; myvar : hea
mov tlr , testfloat2
mov stl , 0c1
mov fdx , 2
syscall
free nil
;heap -1 ; let all the memory go VERY UNACCURATE
stor stl , &testreference
mov tlr , testreference
mov fdx , 6
mov stl , 0c1
syscall ; test2342343
mov stl , &testreference
stor stl , &testreference
mov tlr , testreference
mov fdx , 6
mov stl , 0c1
syscall ; test2342343
proc reftestproc
halt ®ister_test
end
call reftestproc
stor psx , &testreference
mov tlr , testreference
mov stl , 0c1
mov fdx , 6
syscall
mov tlr , 5 8
cmp tlr , 1
;je equal
;jne notequal
jl less
jg greater
;jle lesseq
;jge greatereq
: equal
mov tlr , "EQUAL"
mov fdx , 1
mov stl , 0c1
syscall
jmp endprogliol
: notequal
mov tlr , "NOT EQUAL"
mov fdx , 1
mov stl , 0c1
syscall
jmp endprogliol
: less
mov tlr , "LESS"
mov fdx , 1
mov stl , 0c1
syscall
jmp endprogliol
: greater
;KOMENT
mov tlr , "GREATER"
mov fdx , 1
mov stl , 0c1
syscall
jmp endprogliol
: lesseq
mov tlr , "LESS OR EQUAL"
mov fdx , 1
mov stl , 0c1
syscall
jmp endprogliol
: greatereq
mov tlr , "GREATER OR EQUAL"
mov fdx , 1
mov stl , 0c1
syscall
jmp endprogliol
: endprogliol
.data
intg cmp_result : 0
.start
mov &cmp_result, *cpr
mov tlr , cmp_result
mov fdx , 2
mov stl , 0c1
syscall
: looool443
mov cr0 , 3 0
cmp cr0 , 1 3
jmp xd
: _lol
mov tlr , "lessssss"
mov stl , 0c1
mov fdx , 1
syscall
jmp endprog3
: xd
jl _lol
: endprog3
nop
mov cr0 , 2
mov cr1 , 3
exp
nop
.data
float exptest: 0.0
.start
mov tlr, "\n\nexptest:"
call this
mov &exptest, *cr0
mov tlr, exptest
call this
mov tlr, "\n\n"
call this
mov br0 , 0
mov br1 , 87878747
not
mov &cmp_result, *br0
mov tlr , cmp_result
mov stl , 0c1
mov fdx , 2
syscall
mov cr0 , -3 4
exit
;mov br0, "HI"
proc repl
mov tlr, "Called from repl"
mov stl, 0c1
mov fdx, 1
sysenter "ios"
syscall
mov fdx, "HI"
call PROCEDURETEST
halt 1
end
mov tlr , "HI AGAIN"
mov stl , 0c1
mov fdx , 1
sysenter "ios"
syscall
jmp c3454345343f
mov prp , &halttest
mov stl , 0c1
mov fdx , 6
dec prp
:c3454345343f
nop
nop
nop
nop
nop
nop
.data
ref prptest : &PROCEDURETEST
ref uninref: nil
ref reference74298374: nil
float logtest : 0.0
.start
jmp raspalekidarre
stor prp , &prptest
mov tlr, prptest
sysenter "ios"
syscall
:raspalekidarre
nop
nop
nop
nop
nop
nop
mov cr0 , 8.0
mov cr1 , 2.0
log
mov &logtest, *cr0
mov tlr , logtest
mov stl , 0c1
mov fdx , 2
sysenter "ios"
syscall
./LMAOOOOOOOOOO
proc hihi
halt 0
end
./!LMAOOOOOOOOOO
.data
obj mystruct : { ;comment
intg lol : 98
float decimal : 2.3
string text : "hi from struct"
}
obj mystruct2 : { ;comment
intg lol : 45
float decimal : 833.4
string text : "hi from struct again"
ref reference : &LMAOOOOOOOOOO::hihi
}
.start
mov tlr , mystruct{text}
mov stl , 0c1
mov fdx , 1
syscall
mov tlr , mystruct{decimal}
mov fdx , 2
syscall
mov tlr , mystruct{lol}
mov fdx , 2
syscall
mov tlr , mystruct2{text}
mov stl , 0c1
mov fdx , 1
syscall
mov tlr , mystruct2{decimal}
mov fdx , 2
syscall
mov tlr , mystruct2{lol}
mov fdx , 2
syscall
mov tlr , mystruct2{reference}
mov fdx , 6
syscall
mov stl , 45657
stor stl , &mystruct2{lol}
mov tlr , mystruct2{lol}
mov fdx , 2
mov stl , 0c1
syscall
mov psx , "HIII243"
stor psx , &mystruct{text}
mov tlr , mystruct{text}
mov fdx , 1
mov stl , 0c1
syscall
sysenter "fs/host"
mov tlr , "unique_ptrtest"
mov fdx , 1
syscall
mov tlr , "unique_ptrtest/file.string"
mov stl , "text append"
mov fdx , 6
syscall
.data
char character : 'a'
obj test_struct : {
char charlol : ','
}
.start
sysenter "ios"
mov tlr , character
mov stl , 0c1
mov fdx , 7
syscall
mov tlr , test_struct{charlol}
syscall
mov tlr , '"'
syscall
mov fdx , 8
syscall
mov stl , 0c1
mov fdx , 7
syscall
mov tlr , character
cmp tlr , 'a'
je chareq
jl charle
jg chargr
:chareq
mov tlr , "equal"
mov stl , 0c1
mov fdx , 1
syscall
jmp endprogcharxd
:charle
mov tlr , "less"
mov stl , 0c1
mov fdx , 1
syscall
jmp endprogcharxd
:chargr
mov tlr , "greater"
mov stl , 0c1
mov fdx , 1
syscall
jmp endprogcharxd
:endprogcharxd
malloc 1
mov hea, [0]
mov imm, 1
load 'p'
mov imm, 2
load &character
free nil
mov tlr , character
mov stl , 0c1
mov fdx , 7
syscall
proc charreturn
halt '>'
end
call charreturn
mov &character, *psx
mov tlr , character
mov stl , 0c1
mov fdx , 7
syscall
proc emptyproc
halt 0
end
.data
cont testbitarr : ?bit_arr
.start
mov tlr , "TEST"
mov fdx , 1
syscall
mov tlr , * / testenv
mov fdx , 1
syscall
mov tlr , */testenv2
syscall
testlib
sayhi
sysenter "cmanip"
mov cpt , &testbitarr
mov tlr , 2
mov stl , 1
mov fdx , 4
syscall
mov tlr , 1
mov fdx , 5
syscall
mov fdx , 2
mov stl , 0c1
syscall
mov tlr , 2
mov fdx , 5
syscall
mov fdx , 2
syscall
mov tlr , "Moving on to binary tress "
mov stl , 0c1
sysenter "ios"
mov fdx , 1
syscall
.data
cont testbintree : ? bin_tree
.start
mov cpt , &testbintree
sysenter "cmanip"
mov tlr , 0
mov stl , 33
mov fdx , 7
syscall
;;;;;;;;;;;
mov tlr , 0
mov fdx , 9
syscall
mov stl , 0c1
mov fdx , 2
sysenter "ios"
syscall
;;;;;;;;;;;;;;;;;;;;;;;;;;
sysenter "cmanip"
mov tlr , 1
mov fdx , 9
syscall
sysenter "ios"
mov stl , 0c1
mov fdx , 2
syscall
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
mov tlr , 2
sysenter "cmanip"
mov fdx , 9
syscall
sysenter "ios"
mov stl , 0c1
mov fdx , 2
syscall
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
sysenter "cmanip"
mov tlr , 3
mov fdx , 9
syscall
sysenter "ios"
mov stl , 0c1
mov fdx , 2
syscall
jmp shjfjsdhfj
proc __exit_proc
mov tlr, "Hiiii"
call this
db tlr
mov tlr , "exit proc called"
mov stl , 0c1
mov bos, 16
;mov bos, 100
mov fdx , 1
sysenter "ios"
syscall
halt 0
end
:shjfjsdhfj
evt 'termination' -> {
mov tlr, "Hiiii"
call std::ios::writeln
db tlr
mov tlr , "exit proc called"
mov stl , 0c1
mov bos, 16
;mov bos, 100
mov fdx , 1
sysenter "ios"
syscall
}
db cpt
db tlr
db hea
db stk
mov tlr , "hello "
mov stl , "world"
mov fdx , 1
sysenter "txtop"
syscall
sysenter "ios"
mov stl , 0c1
syscall
sysenter "txtop"
mov tlr , " this is text "
mov fdx , 2
syscall
sysenter "ios"
mov fdx , 1
syscall
internettest
netconf
sysenter "net"
mov tlr , "hi com"
mov stl , "hi string"
mov fdx , 1
syscall