📄 asm_2_htm.asm
字号:
mov ebx, offset szWord
add bl, Word_Spot
dec ebx
mov al, BYTE PTR [ebx]
mov ecx, hDest_Memory
mov BYTE PTR [ecx], al
;=====================================
; Increment the pointers
;=====================================
inc written
inc hDest_Memory
;======================================
; Set the final char in buffer to zero
;======================================
mov ebx, offset szWord
add bl, Word_Spot
mov BYTE PTR [ebx], 0
;===============================
; Set the Word_Spot to zero
;===============================
mov Word_Spot, 0
;===============================
; Buffer is empty so we can now
; process the comment
;===============================
mov ebx, hSrc_Memory
mov al, BYTE PTR [ebx]
.while al != 13
;======================
; Write the char out
;======================
invoke WriteChar, al
;======================
; Increment source mem
;======================
inc hSrc_Memory
;=======================
; Get the character
;=======================
mov ebx, hSrc_Memory
mov al, BYTE PTR [ebx]
.endw
;==================================
; We are finished with the comment
; so close the font color
;==================================
invoke wvsprintfA, hDest_Memory, ADDR szEndFont, 0
;=====================================
; Add the number written and advance
; the memory handle by that amount
;=====================================
add written, eax
add hDest_Memory, eax
.elseif bl == 34 || bl == 39
;=================================
; Process a string
;=================================
;====================================
; Save our character so we know what
; to test against later on
;====================================
push ebx
;======================================
; If buffer has more than one char then
; empty it
;======================================
.if Word_Spot > 1
;=======================
; Has chars so empty it
;=======================
mov eax, 0
xor edx, edx
mov dl, Word_Spot
dec dl
.while al < dl
;============================
; Write them out to the file
;============================
push eax
mov ebx, offset szWord
add ebx, eax
mov cl, BYTE PTR [ebx]
mov BYTE PTR [ebx], 0
push edx
invoke WriteChar, cl
pop edx
pop eax
inc al
.endw
.endif
;======================================
; Setup and write out the string color
; and the delimiter
;======================================
mov dwArgs, offset szDEFAULT_STRING
invoke wvsprintfA,ADDR szFontBuffer,ADDR szFontTemp, offset dwArgs
invoke wvsprintfA, hDest_Memory, ADDR szFontBuffer, 0
;=====================================
; Add the number written and advance
; the memory handle by that amount
;=====================================
add written, eax
add hDest_Memory, eax
;======================================
; Write out the string symbol
;======================================
mov ebx, offset szWord
add bl, Word_Spot
dec ebx
mov al, BYTE PTR [ebx]
mov ecx, hDest_Memory
mov BYTE PTR [ecx], al
;=====================================
; Increment the pointers
;=====================================
inc written
inc hDest_Memory
;======================================
; Set the final char in buffer to zero
;======================================
mov ebx, offset szWord
add bl, Word_Spot
mov BYTE PTR [ebx], 0
;===============================
; Set the Word_Spot to zero
;===============================
mov Word_Spot, 0
;===============================
; Put our old charcter into ecx
;===============================
pop ecx
;===============================
; Buffer is empty so we can now
; process the string
;===============================
mov ebx, hSrc_Memory
mov al, BYTE PTR [ebx]
.while al != cl
;======================
; Save the character
;======================
push ecx
;======================
; Write the char out
;======================
invoke WriteChar, al
;======================
; Increment source mem
;======================
inc hSrc_Memory
;=======================
; Get the character
;=======================
mov ebx, hSrc_Memory
mov al, BYTE PTR [ebx]
;========================
; Restore the charcter
;========================
pop ecx
.endw
;======================
; Write the final char
; of the string out
;======================
invoke WriteChar, al
;======================
; Increment source mem
;======================
inc hSrc_Memory
;==================================
; We are finished with the string
; so close the font color
;==================================
invoke wvsprintfA, hDest_Memory, ADDR szEndFont, 0
;=====================================
; Add the number written and advance
; the memory handle by that amount
;=====================================
add written, eax
add hDest_Memory, eax
;======================================================
; Did we hit a non alphanumeric or special char?
;======================================================
;==============================
; Eliminate Non AlphaNumeric
;==============================
.elseif (bl < 64 || bl > 90) && (bl < 97 || bl > 122) && \
(bl < 48 || bl > 57) && bl != 95 && bl != 46
;=====================================
; No it wasn't so empty the buffer
;=====================================
mov eax, 0
xor edx, edx
mov dl, Word_Spot
.while al < dl
;============================
; Write them out to the file
;============================
push eax
mov ebx, offset szWord
add bl, al
mov cl, BYTE PTR [ebx]
mov BYTE PTR [ebx], 0
push edx
invoke WriteChar, cl
pop edx
pop eax
inc al
.endw
;=====================================
; Set Word Spot to zero
;=====================================
mov Word_Spot, 0
.endif
;=======================================
; If the buffer has reached it's limit
; then empty it
;=======================================
.if Word_Spot == (MAX_WORD_SIZE)
;========================================
; We have so write out the chars and set
; everything to zero
;========================================
xor ecx, ecx
mov cl, 0
mov ebx, offset szWord
.while cl < MAX_WORD_SIZE
push ebx
push ecx
invoke WriteChar, BYTE PTR [ebx]
pop ecx
pop ebx
mov BYTE PTR [ebx], 0
inc ebx
inc cl
.endw
;================================
; Set the Word_spot to zero
;================================
mov Word_Spot, 0
.endif
;======================================
; Go back to the top and do again
;======================================
jmp top
.endif
;======================================
; If buffer has any chars in it
; then empty it
;======================================
.if Word_Spot != 0
;=======================
; Has chars so empty it
;=======================
mov eax, 0
xor edx, edx
mov dl, Word_Spot
dec dl
dec dl
.while al < dl
;============================
; Write them out to the file
;============================
push eax
mov ebx, offset szWord
add bl, al
mov cl, BYTE PTR [ebx]
mov BYTE PTR [ebx], 0
push edx
invoke WriteChar, cl
pop edx
pop eax
inc al
.endw
.endif
;=====================================
; Now write out our finishing header
;=====================================
invoke wvsprintfA, hDest_Memory, ADDR szEnding,0
;=====================================
; Add the number written and advance
; the memory handle by that amount
;=====================================
add written, eax
add hDest_Memory, eax
;========================================
; Set processing to false
;========================================
mov Processing, FALSE
done:
return 1
err:
return 0
ConvertFile endp
;########################################################################
; END of ConvertFile
;########################################################################
;########################################################################
; IsKeyword Function
;########################################################################
IsKeyword proc string:DWORD, str_size:BYTE
;================================================
; This tests the passed string to see if it is
; a keyword that needs highlighting or not
; if so it highlights the string it and
; writes it out if not it returns zero
;================================================
;================================
; Local variables
;================================
LOCAL Base:BYTE
;================================
; Initialize Base to zero
;================================
mov Base, 0
;================================
; Loop until we reach the end of
; the keywords
;================================
.while Base < NUM_KEYWORD
;================================================
; Load in our current keyword we want to test
;================================================
mov eax, KEYWORD_BASE
add al, Base
invoke LoadString, hInst, eax, ADDR szTestString, 15
;==========================================
; Compare it to the string that was passed
;==========================================
invoke lstrcmpi, string, offset szTestString
;====================================================
; If we succceeded write it out and clear the buffer
;====================================================
.if eax == 0
;=====================================
; Do we need to make the string caps
;=====================================
.if MakeCaps == TRUE
;==============================
; Yes so make a call and do it
;==============================
invoke CharUpper, string
mov string, eax
.endif
;=====================================
; Set the string into the buffer
;=====================================
mov eax, string
mov dwArgs, eax
invoke wvsprintfA, ADDR szBoldBuffer, ADDR szBoldTemp, offset dwArgs
;=====================================
; Now write out our first header
;=====================================
invoke wvsprintfA, hDest_Memory, ADDR szBoldBuffer,0
;=====================================
; Add the number written and advance
; the memory handle by that amount
;=====================================
add written, eax
add hDest_Memory, eax
;=================================
; Clear out the chars
;=================================
xor eax, eax
.while al < str_size
;========================
; Setup the current char
;========================
mov ebx, string
add bl, al
;============================
; Set Cur Char back to 0
;============================
mov BYTE PTR [ebx], 0
;==============================
; increment the counter
;==============================
inc eax
.endw
;==================================
; Jump to found and leave function
;==================================
jmp found
.else
;====================
; NOPE GOTO NEXT ONE
;====================
.endif
;===============================
; Increment the base pointer
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -