-
Notifications
You must be signed in to change notification settings - Fork 0
/
gordo.asm
1169 lines (946 loc) · 19 KB
/
gordo.asm
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
; Leitor de imagem FAT16
; arquivo: gordo.asm
; objetivo: Processar Arquivos organizados em FAT16
; e exibir CAT dos mesmos
; nasm -f elf64 gordo.asm ; ld gordo.o -o gordo.x
%define _exit 60
%define _write 1
%define _open 2
%define _read 0
%define _seek 8
%define _close 3
%define readOnly 0o ; flag open()
%define writeOnly 1o ; flag open()
%define readwrite 2o ; flag open()
%define openrw 102o ; flag open()
%define userWR 644o ; Read+Write+Execute
%define _cat 0x20544143
%define _ls 0x0000534c
%define _cd 0x00204443
%define _quit 0x54495551
section .data
argErrorS : db "Erro: Quantidade de Parâmetros incorreta", 10, 0
argErrorSL: equ $-argErrorS
arqErrorS : db "Erro: Arquivo não foi aberto", 10, 0
arqErrorSL: equ $-arqErrorS
argErrorC : db "Erro: Comando incorreto", 10, 0
argErrorCL: equ $-argErrorC
argErrorCAT: db "Erro: não é possível fazer CAT neste tipo", 10, 0
argErrorCATL: equ $-argErrorCAT
argErrorDIR: db "Erro: não é possível abrir diretório", 10, 0
argErrorDIRL: equ $-argErrorDIR
promptDialog: db 10, 10, "Pressione [Enter] para continuar", 10, 0
promptDialogL: equ $-promptDialog
strOla : db "Testi", 10, 0
strOlaL : equ $-strOla
jumpLine : db 10, 0
clearTerm : db 27,"[H",27,"[2J" ; <ESC> [H <ESC> [2J
clearTermL : equ $-clearTerm ; tamanho da string para limpar terminal
dotChar : db 0x2e, 0
tabChar : db 0x09, 0
trintaDois : dq 32
; moldura para print
firstLine : db "|", 0x09, "Nome", 0x09, 0x09, "|", 0x20, "Tipo", 0x20, "|", 0x09, "Tamanho", 0x09, 0x09, "|", 10 ,0
firstLineL : equ $-firstLine
initLine : db "|", 0x09, 0
initLineL : equ $-initLine
finishLine : db "|", 0x0a, 0
finishLineL : equ $-finishLine
typeSpace : db 0x09,"|", 0x20, 0
typeSpaceL : equ $-typeSpace
typeDir : db "DIR", 0x20, 0
typeArch : db "ARCH", 0
typeSize : db 4
typeFinish : db 0x20, "|", 0x09, 0
typeFinishL : equ $-typeFinish
dirSizeChar : db "-------", 0x09, 0x09, "|", 10, 0
dirSizeCharL : equ $-dirSizeChar
archFinish : db 0x09, "|", 10, 0
archFinishL : equ $-archFinish
beep : db 0x07, 0
section .bss
arquivo : resq 1
argv : resq 1
argc : resq 1
disassemble : resb 3 ; offset 0
OEMIdentifier : resb 8 ; offset 3
bytesPerSector : resb 2 ; offset 11
sectorsPerCluster : resb 1 ; offset 13
reservedSectors : resb 2 ; offset 14
FATNumber : resb 1 ; offset 16
directoryEntries : resb 2 ; offset 17
totalSectors : resb 2 ; offset 19
mediaDescriptor : resb 1 ; offset 21
sectorsPerFAT : resb 2 ; offset 22
sectorsPerTrack : resb 2 ; offset 24
headsOfStorage : resb 2 ; offset 26
hiddenSectors : resb 4 ; offset 28
largeTotalSectors : resb 4 ; offset 32
rootDirectoryInit : resq 1 ; posição no arquivo
dataClustersInit : resq 1 ; posição dos dados
firstFATTable : resq 1 ; posição da primeira FAT
readNow : resq 1 ; qual arquivo está sendo lido
stackPointerRead : resq 1 ; salvar onde estava a pilha no começo da leitura do diretório
totalEntrances : resq 1 ; entradas no diretório lido
clusterSize : resq 1 ; quantos bytes tem por cluster
clusterCount : resq 1
clustersPointer : resq 1
bus : resb 1
fileSize : resq 1
suClusterPointer : resq 1
commandType : resb 1
longI : resq 1
searcher : resb 128; leitor do terminal
tempSearcher : resb 128; reorganizar string lida
sizedChars : resb 32
section .text
global _start
_start:
mov rax, _write
mov rdi, 1
lea rsi, [beep]
mov rdx, 1
syscall
mov rax, _write
mov rdi, 1
lea rsi, [clearTerm] ; "limpar" terminal no começo do programa
mov rdx, clearTermL
syscall
mov r8, [rsp]
mov [argv], r8
cmp QWORD[argv], 2 ; Verifica a quantidade de argumentos
jne _argError
mov r8, rsp
add r8, 16
mov r9, [r8]
mov [argc], r9 ; Salvando endereço do argumento em variável
mov rax, _open
mov rdi, [argc]
mov rsi, readwrite
mov rdx, userWR
syscall
mov [arquivo], rax ; Salvar ponteiro do arquivo
cmp rax, 0 ; Verifica se o arquivo foi aberto
jl _arqError
mov rax, _read
mov rdi, [arquivo]
lea rsi, [disassemble]
mov rdx, 3
syscall
mov rax, _read
mov rdi, [arquivo]
lea rsi, [OEMIdentifier]
mov rdx, 8
syscall
mov rax, _read
mov rdi, [arquivo]
lea rsi, [bytesPerSector]
mov rdx, 2
syscall
mov rax, _read
mov rdi, [arquivo]
lea rsi, [sectorsPerCluster]
mov rdx, 1
syscall
mov rax, _read
mov rdi, [arquivo]
lea rsi, [reservedSectors]
mov rdx, 2
syscall
mov rax, _read
mov rdi, [arquivo]
lea rsi, [FATNumber]
mov rdx, 1
syscall
mov rax, _read
mov rdi, [arquivo]
lea rsi, [directoryEntries]
mov rdx, 2
syscall
mov rax, _read
mov rdi, [arquivo]
lea rsi, [totalSectors]
mov rdx, 2
syscall
mov rax, _read
mov rdi, [arquivo]
lea rsi, [mediaDescriptor]
mov rdx, 1
syscall
mov rax, _read
mov rdi, [arquivo]
lea rsi, [sectorsPerFAT]
mov rdx, 2
syscall
mov rax, _read
mov rdi, [arquivo]
lea rsi, [sectorsPerTrack]
mov rdx, 2
syscall
mov rax, _read
mov rdi, [arquivo]
lea rsi, [headsOfStorage]
mov rdx, 2
syscall
mov rax, _read
mov rdi, [arquivo]
lea rsi, [hiddenSectors]
mov rdx, 4
syscall
mov rax, _read
mov rdi, [arquivo]
lea rsi, [largeTotalSectors]
mov rdx, 4
syscall
xor rdx, rdx
xor rax, rax
xor rbx, rbx
mov ax, [bytesPerSector]
mov bx, [reservedSectors] ; reservados para boot record
mul rbx
mov rbx, rax
xor rax, rax
xor r9, r9
mov al, [FATNumber]
mov r9w, [sectorsPerFAT]
mul r9
mov r9w, [bytesPerSector] ; reservados pela FAT
mul r9
add rax, rbx
mov [rootDirectoryInit], rax
xor rdx, rdx
xor rax, rax
mov ax, [directoryEntries]
mul QWORD[trintaDois]
xor r15, r15
mov r15w, [bytesPerSector]
div r15
xor r14, r14
mov r14, rdx
xor rax, rax
mov ax, [directoryEntries]
mul QWORD[trintaDois]
mov rcx, r14
jecxz setorSemResto
xor rbx, rbx
mov bx, [bytesPerSector]
add rax, rbx
setorSemResto:
add rax, [rootDirectoryInit]
mov [dataClustersInit], rax
xor rbx, rbx
xor rax, rax
xor rdx, rdx
mov ax, [bytesPerSector]
mov bx, [reservedSectors]
mul rbx
mov [firstFATTable], rax
mov rax, [rootDirectoryInit]
mov [readNow], rax
xor rdx, rdx
xor rax, rax
xor rbx, rbx
mov al, [sectorsPerCluster]
mov bx, [bytesPerSector]
mul rbx
mov [clusterSize], rax
_readHead:
mov [stackPointerRead], rsp
xor r15, r15
xor r14, r14
xor r13, r13
_initRead:
mov rax, _seek
mov rdi, [arquivo]
mov rsi, [readNow]
add rsi, r15
xor rdx, rdx
syscall
add r15, 32
sub rsp, 32
mov rax, _read
mov rdi, [arquivo]
mov rsi, rsp
mov rdx, 32
syscall
inc r13
cmp BYTE[rsp], 0xe5
je naoExiste
cmp BYTE[rsp], 0x00
je fimDir
xor rbx, rbx
mov bl, [rsp + 11]
cmp ebx, 16
je noLongFile
cmp ebx, 32
je noLongFile
naoExiste:
add rsp, 32
jmp _initRead
noLongFile:
inc r14
cmp r13w, WORD[directoryEntries]
je fimLeitura
fimDir:
xor r10, r10
cmp r10b, BYTE[rsp]
je fimLeituraComRedimensionamento
jmp _initRead
fimLeituraComRedimensionamento:
add rsp, 32
fimLeitura:
mov [totalEntrances], r14
printDir:
mov rax, _write
mov rdi, 1
lea rsi, [firstLine]
mov rdx, firstLineL
syscall
xor r14, r14
xor r15, r15
xor r13, r13
xor r11, r11
mov r15, [stackPointerRead]
sub r15, 32
directoryPrint:
cmp r14, [totalEntrances]
je printEnd
mov rax, _write
mov rdi, 1
lea rsi, [initLine]
mov rdx, initLineL
syscall
mov r13, r15
xor rbx, rbx
printNoSpace:
cmp BYTE[r13], 0x20
je spaceMoment
mov rax, _write
mov rdi, 1
mov rsi, r13
mov rdx, 1
syscall
cmp rbx, 7
je spaceMoment
inc rbx
inc r13
jmp printNoSpace
spaceMoment:
mov r13, r15
add r13, 8
mov r11, 8
cmp BYTE[r13], 0x20
je endExtension
mov rax, _write
mov rdi, 1
lea rsi, [dotChar]
mov rdx, 1
syscall
printExtension:
cmp BYTE[r13], 0x20
je endExtension
cmp r11, 11
je endExtension
mov rax, _write
mov rdi, 1
mov rsi, r13
mov rdx, 1
syscall
inc rbx
inc r11
inc r13
jmp printExtension
endExtension:
cmp rbx, 6
jle oneTab
backTab:
mov rax, _write
mov rdi, 1
lea rsi, [typeSpace]
mov rdx, typeSpaceL
syscall
mov r13, r15
add r13, 11
cmp BYTE[r13], 0x10
je printDirType
cmp BYTE[r13], 0x20
je printArchType
mov rax, _write
mov rdi, 1
lea rsi, [jumpLine]
mov rdx, 1
syscall
returnPrintType:
sub r15, 32
inc r14
jmp directoryPrint
printDirType:
mov rax, _write
mov rdi, 1
lea rsi, [typeDir]
mov dl, [typeSize]
syscall
mov rax, _write
mov rdi, 1
lea rsi, [typeFinish]
mov rdx, typeFinishL
syscall
mov rax, _write
mov rdi, 1
lea rsi, [dirSizeChar]
mov rdx, dirSizeCharL
syscall
jmp returnPrintType
printArchType:
mov rax, _write
mov rdi, 1
lea rsi, [typeArch]
mov dl, [typeSize]
syscall
mov rax, _write
mov rdi, 1
lea rsi, [typeFinish]
mov rdx, typeFinishL
syscall
mov r13, r15
mov eax, [r13 + 28]
xor r11, r11
and QWORD[sizedChars], 0
and QWORD[sizedChars + 8], 0
and QWORD[sizedChars + 16], 0
and QWORD[sizedChars + 24], 0
divChar:
xor rdx, rdx
cmp rax, 10
jle endDiv
mov r13, 10
div r13
add rdx, 48
mov [sizedChars + r11], dl
inc r11
jmp divChar
endDiv:
inc r11
add rax, 48
mov [sizedChars + r11], al
mov r13, r11
mov rbx, r11
printSizedChars:
mov rax, _write
mov rdi, 1
lea rsi, [sizedChars + r13]
mov rdx, 1
syscall
dec r13
cmp r13d, -1
jne printSizedChars
cmp rbx, 9
jle oneTab2
backTab2:
mov rax, _write
mov rdi, 1
lea rsi, [archFinish]
mov rdx, archFinishL
syscall
jmp returnPrintType
oneTab:
mov rax, _write
mov rdi, 1
lea rsi, [tabChar]
mov dl, 1
syscall
jmp backTab
oneTab2:
mov rax, _write
mov rdi, 1
lea rsi, [tabChar]
mov dl, 1
syscall
jmp backTab2
printEnd:
preLecture:
xor r15, r15
functionLecture:
mov rax, _read
mov rdi, 0
lea rsi, [searcher + r15]
mov rdx, 1
syscall
cmp BYTE[searcher + r15], 0x0a
je caseCommands
inc r15
jmp functionLecture
caseCommands:
caseCAT:
xor r12, r12
mov r12d, [searcher]
mov BYTE[commandType], 0x01
xor r13, r13
lea r13, [searcher + 4]
and r12d, _cat
cmp r12d, _cat
je verifyParameter
caseLS:
xor r12, r12
mov r12d, [searcher]
mov BYTE[commandType], 0x02
xor r13, r13
lea r13, [searcher + 3]
and r12d, _ls
cmp r12d, _ls
je cleanParams
caseCD:
xor r12, r12
mov r12d, [searcher]
mov BYTE[commandType], 0x03
xor r13, r13
lea r13, [searcher + 3]
and r12d, _cd
cmp r12d, _cd
je verifyParameter
caseQUIT:
xor r12, r12
mov r12d, [searcher]
and r12d, _quit
cmp r12d, _quit
je _stop
caseERRO:
jmp errorCommand
_stop:
mov rax, _close
mov rdi, [arquivo]
syscall
_end:
mov rax, _exit
mov rdi, 0
syscall
_arqError:
mov rax, _write
mov rdi, 1
lea rsi, [arqErrorS]
mov rdx, arqErrorSL
syscall
jmp _end
_argError:
mov rax, _write
mov rdi, 1
lea rsi, [argErrorS]
mov rdx, argErrorSL
syscall
jmp _end
verifyParameter:
and QWORD[longI], 0
xor r15, r15
mov r15, [stackPointerRead]
sub r15, 32
xor r11, r11
xor r8, r8
forCompare:
xor rbx, rbx
mov bl, BYTE[r13 + r11]
cmp r8, 0 ;
je ponto ; teste para ponto
preTestPonto: ; e ponto + ponto
cmp bl, 0x2e
je posPonto
cmp bl, 0x0a
je posPonto
mov BYTE[tempSearcher + r8], bl
inc r11
inc r8
cmp r11, 8
je posPonto
jmp forCompare
moreSpace:
mov BYTE[tempSearcher + r8], 0x20
inc r8
cmp r8, 8
jne moreSpace
posPonto:
cmp r8, 8
jl moreSpace
inc r11
continue:
cmp BYTE[r13 + r11], 0x0a
je moreSpacePoint
cmp BYTE[r13 + r11], 0
je moreSpacePoint
xor rbx, rbx
mov bl, BYTE[r13 + r11]
mov BYTE[tempSearcher + r8], bl
inc r8
inc r11
cmp r8, 11
jl continue
moreSpacePoint:
cmp r8, 11
jge preForSearch
mov BYTE[tempSearcher + r8], 0x20
inc r8
jmp moreSpacePoint
ponto: ;
cmp bl, 0x2e ;
jne preTestPonto ;
cmp byte[r13 + 1], 0x2e ; tramento especial
je pontoPonto ; para condições de
inc r8 ; navegação em arquivo
mov BYTE[tempSearcher], 0x2e ;
jmp moreSpacePoint ;
;
pontoPonto: ;
add r8, 2 ;
mov BYTE[tempSearcher], 0x2e ;
mov BYTE[tempSearcher + 1], 0x2e ;
jmp moreSpacePoint ;
preForSearch:
and QWORD[longI], 0
mov r14, [totalEntrances]
xor rcx, rcx
xor rdx, rdx
mov rcx, [tempSearcher]
mov edx, [tempSearcher + 8]
xor rbx, rbx
forSearch:
cmp QWORD[longI], r14
je endSearch
mov ebx, [r15 + 8]
and ebx, 0x00ffffff
cmp QWORD[r15], rcx
je firstEqual
inc QWORD[longI]
sub r15, 32
jmp forSearch
firstEqual:
cmp ebx, edx
je endSearch
inc QWORD[longI]
sub r15, 32
jmp forSearch
endSearch:
cmp r14, QWORD[longI]
je errorCommand
jmp cleanParams
errorCommand:
mov rax, _write
mov rdi, 1
lea rsi, [argErrorC]
mov rdx, argErrorCL
syscall
mov BYTE[commandType], 0
jmp cleanParams
cleanParams:
xor rcx, rcx
mov rcx, 16
forClear:
dec rcx
mov QWORD[searcher + rcx * 8], 0
mov QWORD[tempSearcher + rcx * 8], 0
jecxz fimClear
jmp forClear
fimClear:
cmp BYTE[commandType], 0x02
je lsCommand
cmp BYTE[commandType], 0x01
je catCommand
cmp BYTE[commandType], 0x03
je cdCommand
jmp preLecture
lsCommand:
mov rax, _write
mov rdi, 1
lea rsi, [clearTerm]
mov rdx, clearTermL
syscall
mov BYTE[commandType], 0
jmp printDir
catCommand:
mov rax, _write
mov rdi, 1
lea rsi, [clearTerm]
mov rdx, clearTermL
syscall
mov r14, [longI]
xor rdx, rdx
xor rax, rax
inc r14
imul r14, 32
mov r15, [stackPointerRead]
sub r15, r14
xor r14, r14
cmp BYTE[r15 + 11], 0x20
jne errorFormat
mov r14w, [r15 + 26]
xor r13, r13
mov QWORD[fileSize], 0
mov r13d, [r15 + 28]
mov [fileSize], r13
xor rax, rax
xor rdx, rdx
mov rax, r13
mov rbx, [clusterSize]
div rbx
mov [clusterCount], rax
cmp rdx, 0
je noResto
inc QWORD[clusterCount]
noResto:
mov rax, [clusterCount]
inc rax
shl rax, 1
sub rsp, rax
mov [clustersPointer], rsp
mov [rsp], r14w
and QWORD[longI], 0x0
forClusters:
mov rax, [firstFATTable]
xor rdx, rdx
mov r14, QWORD[longI]
mov bx, [rsp + r14 * 2]
cmp bx, 0xFFF8
jae endClustrers
shl rbx, 1
add rax, rbx
inc QWORD[longI]
mov r14, [longI]
mov rsi, rax
mov rax, _seek
mov rdi, [arquivo]
xor rdx, rdx
syscall
mov rax, _read
mov rdi, [arquivo]
lea rsi, [rsp + r14 * 2]
mov rdx, 2
syscall
jmp forClusters
endClustrers:
and QWORD[longI], 0
xor r13, r13
xor r12, r12
printArchive:
mov r14, QWORD[longI]
xor rax, rax
mov ax, [rsp + r14 * 2]
cmp ax, 0xfff8
jae printFinalize
sub rax, 2
xor rdx, rdx
xor rbx, rbx
mul QWORD[clusterSize]
add rax, [dataClustersInit]
inc QWORD[longI]
mov rsi, rax
mov rax, _seek
mov rdi, [arquivo]
xor rdx, rdx
syscall
xor r12, r12
xor r15, r15
readerGuest:
cmp r12, QWORD[clusterSize]
je readerEnd
mov rax, _read
mov rdi, [arquivo]
lea rsi, [bus]
mov rdx, 1
syscall
mov rax, _write
mov rdi, 1
lea rsi, [bus]
mov rdx, 1
syscall
inc r12
inc r13
cmp r13, [fileSize]
je readerEnd
jmp readerGuest
readerEnd:
jmp printArchive
errorFormat:
mov rax, _write
mov rdi, 1
lea rsi, [argErrorCAT]
mov rdx, argErrorCATL
syscall
mov BYTE[commandType], 0
jmp printDir
printFinalize:
add rsp, 2
shl QWORD[clusterCount], 1
add rsp, [clusterCount]
mov QWORD[clusterCount], 0
and BYTE[bus], 0
mov QWORD[clustersPointer], 0
mov BYTE[commandType], 0
mov rax, _write
mov rdi, 1
lea rsi, [promptDialog]
mov rdx, promptDialogL
syscall
printConfirm:
mov rax, _read
mov rdi, 0
lea rsi, [bus]
mov rdx, 1
syscall
cmp BYTE[bus], 0x0a
jne printConfirm
mov rax, _write
mov rdi, 1
lea rsi, [clearTerm]
mov rdx, clearTermL
syscall
jmp printDir
cdCommand:
mov r14, [longI]
xor rdx, rdx
xor rax, rax
inc r14
imul r14, 32
mov r15, [stackPointerRead]
sub r15, r14
xor r14, r14
cmp BYTE[r15 + 11], 0x10
jne errorDirType
mov r14w, [r15 + 26]
cmp r14, 0
je rootDirJMP
mov rax, r14
sub rax, 2
xor rdx, rdx
mul QWORD[clusterSize]