-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhddhackr.s
2869 lines (2149 loc) · 59.6 KB
/
hddhackr.s
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
;
[ORG 0x100]
MOV AX, DS
MOV ES, AX ; let ES = DS
mov ax, 3
int 10h ;clear screen
mov ah, 9
mov dx, introtext ; show introtext
int 0x21
mov si,80h
cmp byte [si], 3 ;size => 3 = space + 2 chars
jne optionerror
inc si
inc si
cmp word [si], '-u'
jne noU
mov byte [option], 1 ;-u = 1 = undo
jmp Optiongood
noU:
cmp word [si], '-d'
jne noD
mov byte [option], 2 ;-d = 2 = dump
jmp Optiongood
noD:
cmp word [si], '-f'
jne optionerror
mov byte [option], 3 ;-f = 3 = file (flash from file)
jmp Optiongood
optionerror:
mov ah, 9
mov dx, option_error
int 0x21
jmp exit
Optiongood:
cmp word [mprt], 'MP'
je normalop
mov ah, 9
mov dx, manualmode ; show introtext
int 0x21
mov byte [pcount], 2
mov bx, portlist
mov ax, word [mprt]
mov byte [bx],byte ah
mov byte [bx+1],byte al
mov ax, word [mprt+2]
mov byte [bx+2],byte ah
mov byte [bx+3],byte al
jmp contop
normalop:
mov ah, 9
mov dx, detecting
int 0x21
call Findports
contop:
CLI ;disable interupts
mainlus:
nop
nop
nop
nop
nop
nop
mov bx, portlist
add bx, word [testcounter] ;aantal ports dat ie al heeft getest
add bx, word [testcounter] ;2x, omdat het om words gaat
mov dx, [bx]
mov word [basereg], dx
MOV DX, word [basereg];device/head register
add dx, 6
MOV AL, 0xA0 ; select device 0 (master)
OUT DX, AL
MOV DX, word [basereg] ;command register
add dx, 7
MOV AL, 0ECh ;"IDENTIFY DRIVE" command
OUT DX, AL ;sends the command!
call Wait_For_NBSY2
cmp ax, 1
je ietsgevonden
;now try same again, but for slave mode.
mov bx, portlist
add bx, word [testcounter] ;aantal ports dat ie al heeft getest
add bx, word [testcounter] ;2x, omdat het om words gaat
mov dx, [bx]
mov word [basereg], dx
MOV DX, word [basereg];device/head register
add dx, 6
MOV AL, 0xB0 ; select device 0 (slave)
OUT DX, AL
MOV DX, word [basereg] ;command register
add dx, 7
MOV AL, 0ECh ;"IDENTIFY DRIVE" command
OUT DX, AL ;sends the command!
call Wait_For_NBSY2
cmp ax, 1
je slavefound
jmp searchndrv
slavefound:
mov byte [head], 0xB0 ;set head to slave
ietsgevonden:
mov dx, word [basereg]
add dx, 7
in al, dx
cmp al, 58h
jz gevonden
jmp searchndrv
gevonden:
mov ah, 9
mov dx, devicefoundtext ; show introtext
int 0x21
gevondenx:
;----------------------------------------------------------------------------
call processEC ;read EC reply and copy the relevant data to vars
;----------------------------------------------------------------------------------------
;safe EC buffer
mov bx, buff ;dx = pointer to buffer (ds:dx)
mov dx, ecFilename
mov cx, 512
call SaveFile
cmp byte [option], 1
je startundo
jmp notoption1
startundo:
;User wants to flash undo.bin, so let's do that
mov ah, 9
mov dx, ECserialstring
int 0x21
mov ah, 9
mov dx, ECModelstring
int 0x21
mov ah, 9
mov dx, ECBiosstring
int 0x21
mov ah, 9
mov dx, suretoundomsg
int 0x21
mov ah,0
int 16h ;get a key, returned in AX
;AL is the ASCII part
;AH is the SCAN CODE
push ax
mov dl,al
mov ah,2
int 21h ;print character in dl
pop ax
cmp al,"Y" ;was the character a 'Y'?
je Yesx2 ;nope it was Not Equal
cmp al,"y" ;was the character a 'Y'?
je Yesx2 ;nope it was Not Equal
mov dx, NoyesMessage
mov ah,9
int 21h
jmp exit
Yesx2:
call readundofile
cmp word [secDbuff], 'RO'
je secDok
invalidFile:
mov dx, invalidFileErr
mov ah,9
int 21h
jmp exit
secDok:
cmp word [sec2buff], 'RO'
je sec2ok
jmp invalidFile
sec2ok:
call SetNativeStatus
jmp FlashFW
;--------------------------------------------------
notoption1:
cmp byte [option], 2
je dump_sec16_22
jmp Startflashproc
;---------------------------------------------------------------------------------------------
;User selected to dump the sectors 16 to 22, so let's do that.
dump_sec16_22:
call readsec16_22
call verify16_22
cmp byte [dataokbool], 1
je savetobin
mov ah, 9
mov dx, dataerr
int 0x21
jmp exit
savetobin:
mov bx, sec16
mov dx, hddssFilename
mov cx, 3584
call SaveFile ;save modified modID 2e, for checking
mov ah, 9
mov dx, donesaving
int 0x21
jmp exit
;----------------------------------------------------------------------------------------------
Startflashproc: ;Main procedure that reads the hddss.bin file, saves it to the sectors 16-22 and then flashes the FW
call readsec16_22
call verify16_22
;cmp byte [dataokbool], 1
;je dontwrite
call readhdssfile ;read the hddss.bin
call verify16_22
cmp byte [dataokbool], 1
je datagood
mov ah, 9
mov dx, datafileerr
int 0x21
jmp exit
datagood:
call writesectors
mov ah, 9
mov dx, wrotedata
int 0x21
jmp cmp16vsEC
dontwrite:
mov ah, 9
mov dx, datawasok
int 0x21
call readhdssfile ;read the hddss.bin
call verify16_22
cmp byte [dataokbool], 1
je cmp16vsEC
mov ah, 9
mov dx, datafileerr
int 0x21
jmp exit
cmp16vsEC:
mov bx, sec16 ;point to serial
mov di, 0
copys16serial:
mov ax, [bx]
mov [s16serial+di], ax
add bx, 2
add di,2
cmp di, 20
jne copys16serial
mov ah, 9
mov dx, ECserialstring
int 0x21
mov ah, 9
mov dx, s16serialstring
int 0x21
;------------------------------------
; copy the s16 model to the var
mov bx, sec16
add bx, 28 ;point to model
mov di, 0
copys16Model:
mov ax, [bx]
mov [s16Model+di], ax
add bx, 2
add di,2
cmp di, 40
jne copys16Model
mov ah, 9
mov dx, ECModelstring
int 0x21
mov ah, 9
mov dx, s16Modelstring
int 0x21
;------------------------------------
; copy the bios version to the var
mov bx, sec16
add bx, 20 ;point to bios
mov di, 0
copys16Bios:
mov ax, [bx]
mov [s16Bios+di], ax
add bx, 2
add di,2
cmp di, 8
jne copys16Bios
mov ah, 9
mov dx, ECBiosstring
int 0x21
mov ah, 9
mov dx, s16Biosstring
int 0x21
;--------------------------------------------
; copy the sect count to the var
mov bx, sec16
add bx, 88 ;point to sector count
mov di, 0
copys16scount:
mov ax, [bx]
mov [s16scount+di], ax
add bx, 2
add di,2
cmp di, 4
jne copys16scount
MOV AX, DS
MOV ES, AX ; Let ES equal DS
MOV DI, s16serial
MOV SI, ECserial
CLD
MOV CX, 20
REPE CMPSB
JNZ notequall
MOV DI, s16Model
MOV SI, ECModel
CLD
MOV CX, 40
REPE CMPSB
JNZ notequall
MOV DI, s16Bios
MOV SI, ECBios
CLD
MOV CX, 8
REPE CMPSB
JNZ notequall
MOV DI, s16scount
MOV SI, ECscount
CLD
MOV CX, 4
REPE CMPSB
JZ equallx
MOV DI, s16scount
MOV SI, ECscount2
CLD
MOV CX, 4
REPE CMPSB
JnZ notequall
equallx:
mov ah, 9
mov dx, equal
int 0x21
jmp exit
notequall:
mov ah, 9
mov dx, notequal
int 0x21
mov ah,0
int 16h ;get a key, returned in AX
;AL is the ASCII part
;AH is the SCAN CODE
push ax
mov dl,al
mov ah,2
int 21h ;print character in dl
pop ax
cmp al,"Y" ;was the character a 'Y'?
je Yes ;nope it was Not Equal
cmp al,"y" ;was the character a 'Y'?
je Yes ;nope it was Not Equal
mov dx, NoyesMessage
mov ah,9
int 21h
jmp exit
Yes:
call SetNativeStatus
; Now read the FW Module D ***************************************************************************
call Wait_For_DRDY
call Wait_For_NBSY
call SEND_cfgsect_ATA ;Tell drive that the Key sector is coming
call Wait_For_NBSY
mov DX, [basereg]
add DX, 7 ;status register
in al, dx
cmp al, 58h
jz DRQOK1
jmp DRQERR
DRQOK1:
call Wait_For_DRDY
MOV bx, SCT_Packet_rD
call send_Key_sector ;send the key sector
call Wait_For_NBSY
mov DX, [basereg]
add DX, 7 ;status register
in al, dx
call Wait_For_DRDY
mov al, 0xD5 ;features, set to 'read'
mov Bl, 1 ;sector count
call send_Get_sector ; Send request for transfer of data
call Wait_For_NBSY
mov DX, [basereg]
add DX, 7 ;status register
in al, dx
cmp al, 58h
jz DRQOK3
jmp DRQERR
DRQOK3:
mov cx, 0
mov DI, secDbuff
LOOP3x:
mov DX, [basereg]
add dx, 7
in al,dx
test al,8 ;Wait for sector buffer ready.
jz LOOP3x
mov DX, [basereg]
mov cx,0x100 ;One sector /2
mov dx, [basereg] ;Data port - data comes in and out of here.
rep insw
call Wait_For_NBSY
mov DX, [basereg]
add DX, 7 ;status register
in al, dx
;cmp al, 58h
;jnz DRQERR
;...And now we can display the contents of buff!
; MOV BX, secDbuff
;
; MOV CX, 256
; MOV AH, 2 ;"display output" option for INT 21
;LOOP4:
; MOV DL, [BX] ;moves the contents of the byte from "buff" into DL
; INT 21h
; INC BX
; LOOPNZ LOOP4 ;does this 256 times, because CX was set to 256
;-------------
; Now read the FW Module 2 ***************************************************************************
call Wait_For_DRDY
call Wait_For_NBSY
call SEND_cfgsect_ATA ;Tell drive that the Key sector is coming
call Wait_For_NBSY
mov DX, [basereg]
add DX, 7 ;status register
in al, dx
cmp al, 58h
jz DRQOK2
jmp DRQERR
DRQOK2:
call Wait_For_DRDY
MOV bx, SCT_Packet_r2
call send_Key_sector ;send the key sector
call Wait_For_NBSY
mov DX, [basereg]
add DX, 7 ;status register
in al, dx
call Wait_For_DRDY
mov al, 0xD5 ;features, set to 'read'
mov Bl, 2 ;sector count
call send_Get_sector ; Send request for transfer of data
call Wait_For_NBSY
mov DX, [basereg]
add DX, 7 ;status register
in al, dx
cmp al, 58h
jz DRQOK5
jmp DRQERR
DRQOK5:
mov cx, 0
mov DI, sec2buff
LOOP3xx:
mov DX, [basereg]
add dx, 7
in al,dx
test al,8 ;Wait for sector buffer ready.
jz LOOP3xx
mov DX, [basereg]
IN AX, DX
stosw
inc cx
cmp cx, 0x200 ; read 2 sectors
jnz LOOP3xx
call Wait_For_NBSY
mov DX, [basereg]
add DX, 7 ;status register
in al, dx
;cmp al, 58h
;jnz DRQERR
;...And now we can display the contents of buff!
; MOV BX, sec2buff
; MOV CX, 512
; MOV AH, 2 ;"display output" option for INT 21
;LOOP4x:
; MOV DL, [BX] ;moves the contents of the byte from "buff" into DL
; INT 21h
; INC BX
; LOOPNZ LOOP4x ;does this 256 times, because CX was set to 256
askquestion: ; ASK if user wants to create an undo file
mov ah, 9
mov dx, undoquestion
int 0x21
mov ah,0
int 16h ;get a key, returned in AX
;AL is the ASCII part
;AH is the SCAN CODE
push ax
mov dl,al
mov ah,2
int 21h ;print character in dl
pop ax
cmp al,"Y" ;was the character a 'Y'?
je Yesx ;nope it was Not Equal
cmp al,"y" ;was the character a 'Y'?
je Yesx ;nope it was Not Equal
cmp al,"n" ;was the character a 'Y'?
je Nox ;nope it was Not Equal
cmp al,"N" ;was the character a 'Y'?
je Nox ;nope it was Not Equal
mov dx, InvalidMessage
mov ah,9
int 21h
jmp askquestion
Yesx:
mov dx,undoFilename ; put address of filename in dx
mov al,0 ; access mode - read only
mov ah,3Dh ; function 3Dh -open a file
int 21h ; call DOS service
jc createit ; if error opening, then it is ok and we can create it
mov dx, Fileexistmsg
mov ah,9
int 21h
jmp exit
createit:
mov bx, secDbuff ;dx = pointer to buffer (ds:dx)
mov dx, undoFilename
mov cx, 1536
call SaveFile ;save modified modID 2e, for checking
Nox:
;**************************************************************************************************************************
; Now copy the vars from the FW
; First see if the EC string can be found in sector 2. The FW code adds spaces to the BEGINNING. so remove these first:
mov di, 0
removespaces:
mov bx, ECserial
mov al, [bx+di]
cmp al, 20h
jnz startserzooi
inc di
jmp removespaces
startserzooi:
mov dx, di ; save number of spaces to dx
mov word [serialpos], 0
mov bx, 0
seriallus:
MOV DI, sec2buff
add di, bx
MOV SI, ECserial
add si, dx
CLD
MOV CX, 7 ; => compare only first 7 bytes, it's possible that the string in FW is shorter than EC string
REPE CMPSB
jnz serialnotfoundyet
mov word [serialpos], bx
mov bx, 1003 ; EXIT AFTER THE FIRST MATCH !!!
serialnotfoundyet:
add bx, 1
cmp bx, 1004 ;1024-length of string
jne seriallus
cmp word [serialpos], 0
jne serialfound
mov ah, 9
mov dx, serialerrorstring
int 0x21
jmp exit
serialfound:
;Now make sure that there is space in FW for the string !
;algo: search for first 0 byte, then look for the first byte after his one that is NOT zero. Max length is one less than this.
mov bx, sec2buff ; so search for first 0 byte in FW serial string ...
add bx, word [serialpos]
mov word [serialzero], 0
mov cx,0
serspace:
mov bx, sec2buff
add bx, word [serialpos]
add bx, cx
mov al, [bx]
cmp al, 0
jne nozero
mov word [serialzero],cx
mov cx, 20 ; EXIT AFTER FIRST MATCH !!!
nozero:
add cx, 1
cmp cx, 21
jne serspace
;So, we found the first 0 byte, now look for the first byte that is NOT zero
testzero:
mov bx, sec2buff
add bx, word [serialpos]
add bx, word [serialzero]
mov al, [bx]
cmp al, 0
jne nozero2
inc word [serialzero]
jmp testzero
nozero2: ; now max size of serial is [serialzero] - 1
; so now calculate how long much space we need, thus see
; how long the serial from sec16 EX spaces in the end is ...
; algo: look at FIRST character of the string, check for a 'space', if so,
; check next. Needed size is 20 - number of spaces
mov cx, 0
serspac:
cmp cx, 20
jne nok
jmp Fatalerrorstring ; Source contains ONLY spaces, this aint good !!
nok:
mov bx, s16serial
add bx, cx
mov al, [bx]
inc cx
cmp al, 20h ; check for a 'space' character
je serspac
sourcechecked: ;Now check if there is enough space for the serial
mov ax, word [serialzero]
;sub ax, 1 ;ax now contains the free length in FW
mov dx, 20
sub cx, 1 ;cx was one too high, so substract it
sub dx, cx ;dx now contains the length of the source
cmp ax, dx ;dx now contains the needed length
JA serialisok
serrerr:
mov ah, 9 ;if not, display error and exit
mov dx, noserspacestring
int 0x21
jmp exit
serialisok: ; Now copy the serial from sec16 into the FW.
cmp dx, 21
JB sizeisok
fataler:
mov ah, 9
mov dx, Fatalerrorstring ; If it wants to copy more than 20 bytes, than exit this stuff !!
int 0x21
jmp exit
;Now we're going to copy the serial from sec 16 EX the spaces !
;cx still contains the number of spaces !!
sizeisok:
mov di, 0
copysec2serial:
mov bx, s16serial
add bx, cx ;add number of spaces, we dont want them copied !
mov al, [bx+di]
mov bx, sec2buff
add bx, word [serialpos]
mov byte [bx+di], al
inc di
cmp di, dx ;dx still contains the length
jne copysec2serial
;now zero the rest of the OLD string, if this was longer !
;so check if next byte is 0, if not, zero it !!
zeroit:
mov bx, sec2buff
add bx, word [serialpos]
mov al, [bx+di]
cmp al, 0
je domodel
mov byte [bx+di], 0
inc di
jmp zeroit
;NOW DO THE MODEL *******************************************************************
domodel:
mov word [modelpos], 0
mov bx, 0
modellus:
MOV DI, sec2buff
add di, bx
MOV SI, ECModel
CLD
MOV CX, 10 ; => compare only first 10 bytes,possible that the string in FW is shorter than EC string
REPE CMPSB
jnz modelnotfoundyet
mov word [modelpos], bx
mov bx, 1003 ; EXIT AFTER THE FIRST MATCH !!!
modelnotfoundyet:
add bx, 1
cmp bx, 1004 ;1024-length of string
jne modellus
cmp word [modelpos], 0
jne modelfound
mov ah, 9
mov dx, modelerrorstring
int 0x21
jmp exit
modelfound:
; Check length of Modelstring from sec 16. Start at byte 40, look for first character that is NOT a space.
; Then check length of space in FW: Look for first zero byte and then for the first next NON zero byte after this one.
;so first check length of source string => find last byte that is NOT a space
mov cx, 40
modspac:
dec cx
cmp cx, 0
jne modn
jmp modspacerr ; Source contains NO spaces, this ain't never gonna fit
modn:
mov bx, s16Model
add bx, cx
mov al, [bx]
cmp al, 20h ; check for a 'space' character
je modspac
add cx, 1
mov word [lengths16modstring], cx ;save length of source string
; now calculate available space
;algo: search for first 0 byte, then look for the first byte after his one that is NOT zero. Max length is one less than this.
mov bx, sec2buff ; so search for first 0 byte in FW model string ...
add bx, word [modelpos]
mov word [modelzero], 0
mov cx,0
serspacee:
mov bx, sec2buff
add bx, word [modelpos]
add bx, cx
mov al, [bx]
cmp al, 0
jne nozeroo
mov word [modelzero],cx
mov cx, 40 ; EXIT AFTER FIRST MATCH !!!
nozeroo:
add cx, 1
cmp cx, 41
jne serspacee
;So, we found the first 0 byte, now look for the first byte that is NOT zero
testzeroo:
mov bx, sec2buff
add bx, word [modelpos]
add bx, word [modelzero]
mov al, [bx]
cmp al, 0
jne nozeroo2x
inc word [modelzero]
jmp testzeroo
nozeroo2x: ; now max size of model is [modelzero] - 1
; so compare availabe size to needed size now ...
mov ax, word [modelzero]
sub ax, 1 ;ax contains available size
mov bx, word [lengths16modstring] ;bx contains needed size
cmp ax, bx
JA copymodeltoFW
mov ah, 9
mov dx, nomodspacestring
int 0x21
jmp exit
copymodeltoFW: ;now finally copy the string into the FW
mov di, 0
mov dx, word [lengths16modstring]
copysec2model:
mov bx, s16Model
mov al, [bx+di]
mov bx, sec2buff
add bx, word [modelpos]
mov byte [bx+di], al
inc di