I have an assigment to multiply an unsigned number of almost any size (i.e. 0x123456789ABCDEF) that's in one file by another number 0x0-F given by parameter, and display the result in another file.
I have the files open and multiplier stored in a variable already, but I can't figure out how to multiply numbers that don't fit in a single (or even two) register. What is the most simple way to do it?
I'll include my code just in case:
.MODEL SMALL
.STACK 100h
.DATA
data_file_name db 150 dup (0)
result_file_name db 150 dup (0)
data_handle dw ?
result_handle dw ?
data_buffer db 100 dup (?)
result_buffer db 100 dup (?)
multiplier db ?
help_message db "Three parameters must be provided: names of the data file, multiplier, name of the result file.$"
no_result_file db "No result file was provided.$"
not_txt db "Provided files must have .txt file extension.$"
error_opening_data_file_message db "Something went wrong trying to open the data file.$"
error_opening_result_file_message db "Something went wrong trying to open the result file.$"
.CODE
mov ax, @data
mov ds, ax
mov bx, 82h ; Pointer to parameter
mov si, offset data_file_name
; Print help message if no parameters were provided
cmp byte ptr es:[80h], 0
je print_help
; Print help message if "/?" parameter was provided
cmp es:[82h], '?/'
je print_help
main:
CALL get_file_name
cmp byte ptr es:[bx], 13
je print_help
CALL open_data_file
inc bx
mov al, byte ptr es:[bx]
mov multiplier, al
inc bx
mov si, offset result_file_name
inc bx
CALL get_file_name
CALL open_result_file
; get result
; write result
; close data file
; close result file
jmp exit
print_help:
mov ah, 9
mov dx, offset help_message
int 21h
jmp exit
print_no_result_file:
mov ah, 9
mov dx, offset no_result_file
int 21h
jmp exit
print_txt:
mov ah, 9
mov dx, offset not_txt
int 21h
jmp exit
error_opening_data_file:
mov ah, 9
mov dx, offset error_opening_data_file_message
int 21h
jmp exit
error_opening_result_file:
mov ah, 9
mov dx, offset error_opening_result_file_message
int 21h
; close data file
jmp exit
exit:
mov ah, 4Ch
int 21h
proc get_file_name
get_next_character:
; Check if end of file name
cmp byte ptr es:[bx], 32
je return
cmp byte ptr es:[bx], 13
je return
; Get and store the next character of the file name
mov al, byte ptr es:[bx]
mov [si], al
inc bx
inc si
jmp get_next_character
return:
ret
endp get_file_name
proc open_data_file
CALL is_text_file
mov ah, 3Dh ; Open file
mov al, 0 ; with read access
mov dx, offset data_file_name
int 21h
jc error_opening_data_file
mov data_handle, ax
ret
endp open_data_file
proc open_result_file
CALL is_text_file
mov ah, 3Dh ; Open file
mov al, 1 ; with write access
mov dx, offset result_file_name
int 21h
jc error_opening_result_file
mov result_handle, ax
ret
endp open_result_file
proc is_text_file
cmp byte ptr [si-1h], 't'
jne print_txt
cmp byte ptr [si-2h], 'x'
jne print_txt
cmp byte ptr [si-3h], 't'
jne print_txt
cmp byte ptr [si-4h], '.'
jne print_txt
ret
endp is_text_file
END
I've spent a good 4-8 hours looking everywhere for how to do it, but I can't seem to find the solution.