ASSEMBLY LANGUAGE FOR X86 (MASM) Please use modify the code below, it is just a
ID: 3872699 • Letter: A
Question
ASSEMBLY LANGUAGE FOR X86 (MASM) Please use modify the code below, it is just a loop of 10 years......DON NOT USE A JAVA DISASSEMBLER OF BUTCHERS ALGORITHIM.
Use Butcher's algorithm to calculate Easter for the next ten years in x86 assembly language. Use the code below to start
TITLE MASM Template (main.asm)
; Description:
;
; Revision date:
INCLUDE Irvine32.inc
COMMA=2ch
.data
march BYTE "March ",0
april BYTE "April ",0
y DWORD 2017
a dWORD ?
b DWORD ?
cc DWORD ?
.code
main PROC
call Clrscr
mov ecx, 10
NEXT:
mov eax, y
call WriteDec
call crlf
inc eax
mov y, eax
dec ecx
jnz NEXT
mov edx,offset march
call WriteString
mov al, COMMA
call WriteChar
call CRLF
exit
main ENDP
END main
Explanation / Answer
ANSWER::
double ParseAtom(char*& expr)
{
char* end_ptr;
double res = strtod(expr, &end_ptr);
expr = end_ptr;
return res;
}
double ParseFactors(char*& expr) {
double num1 = ParseAtom(expr);
for(;;)
{
char op = *expr;
if(op != '/' && op != '*')
return num1;
expr++;
double num2 = ParseAtom(expr);
if(op == '/')
num1 /= num2;
else
num1 *= num2;
}
}
double ParseSummands(char*& expr)
{
double num1 = ParseFactors(expr);
for(;;) {
char op = *expr;
if(op != '-' && op != '+')
return num1;
expr++;
double num2 = ParseFactors(expr);
if(op == '-')
num1 -= num2;
else
num1 += num2;
}
}
double EvaluateTheExpression(char* expr)
{
return ParseSummands(expr);
};