This is supposed to find the GCD
gcd:= number1;
remainder := number2;
repeat
dividend := gcd;
gcd := remainder;
remainder := dividend mod gcd;
until (remainder = 0);
using windows32 write a program that uses dialog boxes to prompt for and input values for number1 and number2, implements the above design to find their GCD and uses a message box to display the GCD.
Any help with this please???
gcd:= number1;
remainder := number2;
repeat
dividend := gcd;
gcd := remainder;
remainder := dividend mod gcd;
until (remainder = 0);
using windows32 write a program that uses dialog boxes to prompt for and input values for number1 and number2, implements the above design to find their GCD and uses a message box to display the GCD.
Any help with this please???
1. read about win32 programming in general
2. read about dialog boxes
3. write this function
2. read about dialog boxes
3. write this function
1. pay attention in class
2. ????
3. profit!
...if you actually put in some effort of your own but have trouble getting things to work, you're more likely to receive help fixing things up. But don't expect us to do your homework for you.
2. ????
3. profit!
...if you actually put in some effort of your own but have trouble getting things to work, you're more likely to receive help fixing things up. But don't expect us to do your homework for you.
who gives this stupid homework in assembly? this should be better done in a somewhat high level language, at least java or better scheme or something..
who gives this stupid homework in assembly? this should be better done in a somewhat high level language, at least java or better scheme or something..
Especially if you're working on a one-register load/store no-named-labels architecture, it's fun :)
I have managed to come up with this code so far but now I am stuck on what I am missing or did wrong.
.586
.MODEL FLAT
INCLUDE io.h ; header file for input/output
.STACK 4096
.DATA
number1 DWORD ?
number2 DWORD ?
gcd DWORD ?
prompt1 BYTE "Number 1?", 0
prompt2 BYTE "Number 2?", 0
string BYTE 40 DUP (?)
gcdLbl BYTE "Answer:", 0
.CODE
_MainProc PROC
input prompt1, string, 40 ; read ASCII characters
atod string ; convert to integer
mov number1, eax ; store in memory
input prompt2, string, 40 ; read ASCII characters
atod string ; convert to integer
mov number2, eax ; store in memory
mov eax, number1 ; gcd := number1
mov ebx, number2 ; remainder := number2
until: mov ecx, eax ; dividend := gcd
mov eax, ebx ; gcd := remainder
div eax ; dividend mod gcd
mov ebx, ecx ; remainder := dividend mod gcd
cmp ebx, 0 ; remainder = 0
jnz until ; go check condition again
endUntil:
dtoa gcd, eax ; convert to ASCII
output gcdLbl, gcd ; output label and GCD
mov eax, 0 ; exit with return code 0
ret
_MainProc ENDP
END ; end of source code
see http://www.penguin.cz/~literakl/intel/d.html#DIV
If "input, output, atod and dtoa" are procedures, you will need to add the word "invoke" to the beginning of the lines which mention them.
And you will need to INCLUDE the .inc (and INCLUDELIB the .lib) files for the Libraries which contain those procedures, OR, include the sourcecode for those procedures, so that the assembler (and linker) can know what they look like (ie the #params, and where to find them).
And you will need to INCLUDE the .inc (and INCLUDELIB the .lib) files for the Libraries which contain those procedures, OR, include the sourcecode for those procedures, so that the assembler (and linker) can know what they look like (ie the #params, and where to find them).