Hi everyone!

I'm a newbie about assembly, just started out. I did a coupple of exercise pretty well, but now I'm stuck on one that is quite hard for me.

I have to create 2 vectors of N insigned int coded on 64bits. N is on 8 bits.
then i have to do a scalar product and save it on res1 memory address and the bytes number in memory address res2...It doesn't give out the right ammount of bytes....

I'm kinda lost......any help would be appreciated as i spent all day on it and I have to finish it for tomorrow.






CPU 386

GLOBAL main
EXTERN afficherUns32

SECTION .data
N DB 2
X DD 0xffffffff,0xffffffff,65536,0xffffffff
Y DD 65536,0xffffffff,65536,65536
RES1 DD 0,0,0,0,0
RES2 DB 16

SECTION .text

main:

XOR EBP,EBP
DEBUT:
XOR EAX,EAX
MOV AL,[N]
CMP AX,BP
JE NEAR FIN
MOV EBX,[X+EBP*8]
MOV EAX,[Y+EBP*8]
XOR EDI,EDI
XOR ESI,ESI
XOR ECX,ECX
MUL EBX
ADD [RES1],EAX
ADD EDI,EDX
MOV EAX,[Y+EBP*8+4]
MUL EBX
ADD EDI,EAX
ADC ESI,0
ADD ECX,EDX
MOV EBX,[X+EBP*8+4]
MOV EAX,[Y+EBP*8]
MUL EBX
ADD EDI,EAX
ADC ESI,0
ADD [RES1+4],EDI
ADD [RES1+8],ESI
XOR ESI,ESI
XOR EDI,EDI
ADD ECX,EDX
ADC ESI,0
MOV EAX,[Y+EBP*8+4]
MUL EBX
ADD ECX,EAX
ADC ESI,0
ADD EDI,EDX
ADD [RES1+8],ECX
ADC ESI,0
ADD [RES1+12],ESI
XOR ESI,ESI
ADD [RES1+12],EDI
ADC ESI,0
ADD [RES1+16],ESI
INC BP
JMP DEBUT
FIN:
MOV EAX,[RES1+16]
CMP EAX,0
JE NEAR AFFICHER
ADD BYTE[RES2],1
AFFICHER:
MOV AL,[RES2]
PUSHA
PUSH EAX
CALL afficherUns32
POP EAX
POPA

MOV EBX,0
MOV EAX,1
INT 0x80

Posted on 2004-03-17 14:58:27 by Halford
INT 0x80 ???

This is not a Windows program!
(Win32ASM community)

Learn Windows assembly programming :grin:
Begin by the Iczelion's tutorials
Posted on 2004-03-18 05:15:55 by Opcode
Opcode: This section of the board is about algorithms. It is not about any particular system. And if someone wanted to learn Windows programming, don't you think they would be better off reading the manual? It can be browsed online at msdn.microsoft.com. And then if they still don't get it, they can have it spoonfed to them with one of those tutorials.

Halford: I can spot a couple of errors. You are discarding the carry in some places.
Try this instead, and see if it works:


CPU 386

GLOBAL main
EXTERN afficherUns32

SECTION .data
N DB 2
X DD 0xffffffff,0xffffffff,65536,0xffffffff
Y DD 65536,0xffffffff,65536,65536
RES1 DD 0,0,0,0,0
RES2 DB 16

SECTION .text
main:
xor ebx,ebx
debut:
mov eax,[X+ebx*8]
mov ebp,eax
mov ecx,[Y+ebx*8]
mul ecx
push eax
mov esi,edx
mov eax,[X+ebx*8+4]
push eax
mul ecx
add esi,eax
mov edi,edx
mov eax,ebp
mov ecx,[Y+ebx*8+4]
pop ebp
adc edi,0
mul ecx
add esi,eax
pop eax
adc edi,edx
add [RES1],eax
adc [RES1+4],esi
mov eax,ebp
pushfd
mul ecx
add edi,eax
adc edx,0
popfd
inc ebx
adc [RES1+8],edi
adc [RES1+12],edx
adc byte [RES1+16],0
cmp [n],bl
jnz near debut
movzx eax,byte [RES2]
cmp byte [RES1+16],1
sbb al,-1
push eax
call afficherUns32
xor eax,eax
xor ebx,ebx
inc eax
int 128
Posted on 2004-03-18 13:04:04 by Sephiroth3

Opcode: This section of the board is about algorithms. It is not about any particular system. And if someone wanted to learn Windows programming, don't you think they would be better off reading the manual? It can be browsed online at msdn.microsoft.com. And then if they still don't get it, they can have it spoonfed to them with one of those tutorials.


Yes, I really agree that is not about any particular system.
But Win32ASM (the name of the forum) remembers me WINDOWS, not LINUX assembly programming.
And if the people that uses this board, began to put in the "Algorithms" sections some algorithms
involving int 0x80 functions.
Do you will translate this functions to us ?

Maybe translate the Win32ASM to (W/L)in32ASM should solve the trouble.

Can I put algorithms written in assembler of other processors different of x86 architeture?
They will still be algorithms.
Posted on 2004-03-18 13:41:03 by Opcode
The int 0x80 is not relevant for the algorithm itself. I dunno what it is (yay for magic numbers - idiot coders), but I assume it's the same as ExitProcess or "mov ah, 0x4c / int 0x21" under dos.

Btw, what happened to "we don't do other people's homework", and isn't "algorithms & source" meant for working algos/source snippets posted for review & improvement? This thread should have gone in main or heap.
Posted on 2004-03-18 13:48:05 by f0dder
the int 0x80 is for that, like you say, and yes, is not relevant for the algo, they are only call to the OS, like when you use a MessageBox, also see that this calls (functions) are defined for memory, process, access to disck and other basic things (there are like more than 120 and less than 220 functions, dont remember).

By the way, the number passed on eax, is the function to call, also if I am not wrong Lin is only one interrupt based (0x80 or other variants).

In the programm is only used one interrupt, if you see at the end, is for return to the OS the number passed on ebx (end the programm).

About other processors, I dont know but I think in the electronic forum are diferent mnemonics used for programm other type of electronics, flash things and others.
Posted on 2004-03-19 07:34:38 by rea



Yes, I really agree that is not about any particular system.
But Win32ASM (the name of the forum) remembers me WINDOWS, not LINUX assembly programming.
And if the people that uses this board, began to put in the "Algorithms" sections some algorithms
involving int 0x80 functions.
Do you will translate this functions to us ?

Maybe translate the Win32ASM to (W/L)in32ASM should solve the trouble.

Can I put algorithms written in assembler of other processors different of x86 architeture?
They will still be algorithms.

INT 0x80 is used in the same way as INT 0x21 that is it is a gateway to the sys calls

a good place to look for info on linux assembly programming is http://linuxassembly.org


BTW this is the heap the unrescrted part of the forum If someone wants to talk linux this is the place to do it ( it even says so in the tag line of the main forum menu)
Posted on 2004-03-24 13:29:16 by rob.rice
"BTW this is the heap" --- the original thread was posted in the algorithm section, but moved later on.
Posted on 2004-03-24 13:58:20 by f0dder
thankx a thousands for the replyes, I wasn't able to reply before, no net.

Sephiroth3--> thanks a lot, it's good ;)

thankz again.

H.
Posted on 2004-04-24 10:08:45 by Halford