Hey, im trying to make an assembly program which encodes a file using base64.
Anyway I have a program that works in converting the word "Man" to TWFu. Problem is it does not convert anything else but a few 3 letter words like Tan and Ban probally because of its similarity with Man. Below is a code snippet I am using to run the encode, taking 3 bytes from the read file and converting it to 4 bytes writing it to the file then grabbing another 3 bytes and doing the same thing. If anyone could help me figure out what I am doing wrong here help would be appreciated. I am completely stumped at this point and spent the weekend stuck on this one issue.
By the way this is x86 Assembly code, 16 bit. I am using Masm as my compiler.
Encode64: ;Read Input File (3 bytes) mov ah, 3fh mov bx, input_handle mov cx, Buff3b;seting the size to read at a time mov dx, offset input_pointer ;pointing the buffer where to store int 21h jc End_Program ;Appends a 0 if the number of bytes read is less then 3 ;ax = amount of read bytes cmp ax, 2 jne start0 mov input_pointer, 0 start0: cmp ax, 1 jne end0 mov input_pointer,0 mov input_pointer,0 end0: or ax, ax jz done2 ;jump to done2 if ax=0 ;;;;;;;;;;Convert the 3byte data into 4 byte data ;;;;;;;;;;Storing the output into a buffer for writing B1: mov al, input_pointer shr al, 2 add al,65d mov output_pointer,al B2: mov ax, word ptr input_pointer xchg al, ah shl ax, 6 shr ax, 10 add al, 65d mov output_pointer, al B3: mov ax, word ptr input_pointer xchg al, ah shl ax, 4 shr ax, 10 add al, 65d mov output_pointer,al B4: mov al, input_pointer shl al, 4 shr al,2 add al, 61d mov output_pointer, al ;;;;;;;;;;;;;;;;;;;;;;;;; write 4b encoded data to output file mov cx, buff4b;set number of bye to write mov ah, 40h mov bx, output_handle mov dx, offset output_pointer ;write from buffer int 21h jc end_program jmp Encode64