This is my solution for using global variables and EBX in a sub:
include "asm.inc"
window 400,300,1
'global
int data[6]
string outp <= {
"Square of input is ",
"Cube of input is ",
"Cube of input times 25 is ",
"Quotient of cube/100 is ",
"Remainder of cube/100 is ",
"The negation of the remainder is "
}
sub do_math(int num)
'local
int datas[6]
pushad ' save registers
mov eax, num
xor edx, edx
imul eax ; edx:eax = eax * eax
mov datas[0], eax
mov ebx, eax ; save answer in ebx
imul ebx, num ; ebx *= [num]
mov eax,ebx
mov datas[1], eax
imul ecx,ebx, 25 ; ecx =ebx*25
mov datas[2], ecx
mov eax,ebx
mov ecx, 100 ; can't divide by immediate value
div ecx ; edx:eax / ecx
mov ecx, eax ; save quotient into ecx
mov datas[3], ecx
mov eax, edx
mov datas[4], eax
neg edx ; negate the remainder
mov datas[5], edx
popad
'store global
for x=0 to 5
data[x]=datas[x]
next
end sub
do_math(15)
for x=0 to 5
text 10, (20+x*20) ,10, outp[x]
text 280, (20+x*20) ,10, data[x]
next
backcolor 0,0,255
text 10,160, 20, "OKAY!"
waitkey
winEnd
There might be a better approach, but for me it is important to know that it is possible to use ebx with global variables in a sub also.
Roland
.