I'm given a IF statement like this:
if( (Ch > ‘g’) && (Ch < ‘m’)) || ((A>=0) && (A<=100))
condition = 1;
else
condition = 0;
Where Ch is a char, A is a int, and condition is a short int.
I'm trying to put this into assembly language as such:
Org $8000
CLR.W DO
CLR.W D1
CMPI.B #$67,ch
BGT ;something here...
Org $9000
ch DC.B 'a'
A DC.L 0
condition DS.W 1
I believe I've gotten the first if condition, where 67 is the hex value for the ascii code, for the letter 'g'. But I have no idea how to implement the AND statement here, I guess the or statement could be treated like an else? Since either one part of the if executes or the other does. Any help would be appreciated.
If you really have a flowchart that works, it should be a trivial matter to turn that into assembly.
I am not going to draw it for you, just give a pseudocode rendering of it:
if Ch <= 'g' goto check_second_term
if Ch < 'm' goto result_one
check_second_term:
if A < 0 goto result_zero
if A > 100 goto result_zero
result_one:
condition := 1
goto done
result_zero:
condition := 0
done:
I trust you can turn these into cmp
+bcc
pairs.