0

Hi everyone.

I'm trying to convert an assembly code to its corresponding regular expression. I'm trying to match program patterns to discover anomalies. Being a novice in assembly language, i thought i would try to first convert a simple addition program to its corresponding expression before moving onto other code. Could someone please help me in this regard?

3
Contributors
11
Replies
13
Views
5 Years
Discussion Span
Last Post by freddyk
0

Do you either have the ASM code or the Regular Expression you're trying to create?

Not really. I just took the following program off the internet.
It adds 2 numbers and stores the result in a third variable. What i now need is a method to convert this into its corresponding regular expression. I do not have any matching regular expression to compare this with.

TITLE	A04ASM1 (EXE)  Move and add operations
; ---------------------------------------------
STACK	SEGMENT PARA STACK 'Stack'
	DW	   32 DUP(0)
STACK	ENDS
; ----------------------------------------------
DATASEG	SEGMENT PARA 'Data'
	FLDD		DW	   215
	FLDE		DW	   125
	FLDF		DW	   ?
DATASEG	ENDS
; -----------------------------------------------
CODESEG	SEGMENT PARA 'Code'
MAIN		PROC    FAR
		ASSUME  SS:STACK,DS:DATASEG,CS:CODESEG
		MOV     AX,DATASEG		;Set address of data 
		MOV     DS,AX		;  segment in DS 
		MOV	   AX,FLDD		;Move 0215 to AX
		ADD	   AX,FLDE		;Add  0125 to AX
		MOV	   FLDF,AX		;Store sum in FLDF
		MOV	   AX,4C00H		;End processing
		INT	   21H
MAIN		ENDP			;End of procedure
CODESEG	ENDS			;End of segment
		END	   MAIN		;End of program
0

Not really. I just took the following program off the internet.
It adds 2 numbers and stores the result in a third variable. What i now need is a method to convert this into its corresponding regular expression. I do not have any matching regular expression to compare this with.

TITLE	A04ASM1 (EXE)  Move and add operations
; ---------------------------------------------
STACK	SEGMENT PARA STACK 'Stack'
	DW	   32 DUP(0)
STACK	ENDS
; ----------------------------------------------
DATASEG	SEGMENT PARA 'Data'
	FLDD		DW	   215
	FLDE		DW	   125
	FLDF		DW	   ?
DATASEG	ENDS
; -----------------------------------------------
CODESEG	SEGMENT PARA 'Code'
MAIN		PROC    FAR
		ASSUME  SS:STACK,DS:DATASEG,CS:CODESEG
		MOV     AX,DATASEG		;Set address of data 
		MOV     DS,AX		;  segment in DS 
		MOV	   AX,FLDD		;Move 0215 to AX
		ADD	   AX,FLDE		;Add  0125 to AX
		MOV	   FLDF,AX		;Store sum in FLDF
		MOV	   AX,4C00H		;End processing
		INT	   21H
MAIN		ENDP			;End of procedure
CODESEG	ENDS			;End of segment
		END	   MAIN		;End of program

Admins / Members,
Any suggestions on how I can proceed with this? I seem to be stuck. :(

0

I'm trying to truly understand how that piece of code would match a regular expression.
If that's what you truly mean.
When I saw the term regular expression, I was expecting you to need either:
1) Some ASM code that does pattern matching of a string (equivalent to a Regex)
2) A Regex that could substitute for ASM code that does pattern matching of a string.

Is this assumption incorrect?

0

I'm trying to truly understand how that piece of code would match a regular expression.
If that's what you truly mean.
When I saw the term regular expression, I was expecting you to need either:
1) Some ASM code that does pattern matching of a string (equivalent to a Regex)
2) A Regex that could substitute for ASM code that does pattern matching of a string.

Is this assumption incorrect?

Sorry for the delayed response.

What i was looking for was to create a program that identifies the working of other programs. The asm i run should be able to verify the functionality of another program

for example if there are codes for addition, subtraction, multiplication, etc. the code i run should be able to identify if the input program is an addition program. This verification needs to be done using regular expression.

0

That could be a lot of code.
How much time do you have?

Yea.. I figured that a lot of code would be involved and i guess i have enough time. How much do you think i will need? And any suggestions on how to proceed with this?

0

Can you show me the regular expression you want to use to find a program that does addition?

Regular expressions are usually compared to strings.
Should I assume you are only going to look for the + character to determine it's an "addition" program?

How are you going to tell the difference between a minus - and a hyphen - ?

0

What i figured after a lot of thought was that the whole program boils down to how i'm going to read a program. I figured i'd temporarily get the input program source code and verify +,-,*,/ bounded by a string on either side. In that case the hyphen does not come into the picture. But the problem comes when the source code contains strings like ++,--, etc. in which case i am stumped.

0

Programs perform a lot of arithmetic in code, if reading human readable
source code check for an
abundance of these operators (+-*/) and () [] pairs, or look for red-tape
directives such as #include .include include .i386, to identify
the probability of the source-code being a valid program.

0

The thing is, I just have the program mnemonics. I need to find out the working of the program (ie.) what the program actually does and i need to do this using automated code. I thought i'd use a simple addition program as a test sample but it looks like it not simple at all. As suggested i checked it out on human readable code where "string + string" sequence implies addition program where the string is not a special character and it seems to work. But how can i check this for mnemonics? How do i even start this?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.