.586 ; create 32 bit code
.model flat, stdcall ; 32 bit memory model
option casemap :none ; case sensitive
; include files
; ~~~~~~~~~~~~~~~~~~
; set here your path
; ~~~~~~~~~~~~~~~~~~
include z:\masm32\include\windows.inc
include z:\masm32\include\masm32.inc
include z:\masm32\include\kernel32.inc
include Z:\masm32\include\msvcrt.inc
include z:\masm32\macros\macros.asm ; masm32 macro file
; libraries
; ~~~~~~~~~~~~~~~~~~
; set here your path
; ~~~~~~~~~~~~~~~~~~
includelib z:\masm32\lib\masm32.lib
includelib z:\masm32\lib\kernel32.lib
includelib z:\masm32\lib\msvcrt.lib
; Declared procedures
WinMain PROTO
MAXBUF EQU 10
MAXINT EQU 2147483647
.data
two2neg32 QWORD 3DFD000000000000H ; 1.0 / $10000 / $10000; 2^-32
szCRLF BYTE 13, 10, 0
.data?
KeyIn INPUT_RECORD <>
buf1 DWORD MAXBUF dup(?)
buf2 DWORD MAXBUF dup(?)
ConsoleInput DWORD ?
RandSeed DWORD ?
min DWORD ?
f DWORD ?
.code
start:
invoke WinMain
invoke crt__exit, 0
;-----------------------------------------------------------
Random proc uses edx ; include from Delphi
; ->EAX Range
; <- Result in eax if Range > 0 else Result St(0)
.if eax
imul edx, RandSeed, 08088405H
inc edx
mov RandSeed, edx
mul edx
mov eax, edx
ret
.else
push ebx
xor ebx, ebx
imul edx, RandSeed, 08088405H
inc edx
mov RandSeed, edx
fld two2neg32
push 0
push edx
fild QWORD PTR [ESP]
add esp, 8
fmulp st(1), st(0)
pop ebx
ret
.endif
Random endp
;-----------------------------------------------------------
vvod proc uses ebx esi edi buf : DWORD
mov esi, buf
xor ebx, ebx
.repeat
imul edi, ebx, sizeof DWORD
add edi, esi
mov eax, MAXBUF
call Random
sub eax, 20
mov [edi], eax
inc ebx
.until ebx > MAXBUF
ret
vvod endp
;-----------------------------------------------------------
vivod proc uses ebx esi edi buf : DWORD
mov esi, buf
xor ebx, ebx
.repeat
imul edi, ebx, sizeof DWORD
add edi, esi
mov eax, [edi]
invoke crt_printf, SADD('%d '), eax ; Write(x, ' ');
inc ebx
.until ebx > MAXBUF
invoke crt_printf, ADDR szCRLF
ret
vivod endp
;-----------------------------------------------------------
WinMain proc
invoke ClearScreen
invoke crt_printf, ADDR szCRLF
invoke vvod, ADDR buf1
invoke vvod, ADDR buf2
invoke vivod, ADDR buf1
invoke vivod, ADDR buf2
mov f, 0
mov min, MAXINT
xor ebx, ebx
.repeat
xor esi, esi
.repeat
imul eax, ebx, sizeof DWORD
imul ecx, esi, sizeof DWORD
mov eax, buf1[eax]
.if eax == buf2[ecx]
mov f, 1
.endif
inc esi
.until esi > MAXBUF
.if !f
imul eax, ebx, sizeof DWORD
mov eax, buf1[eax]
.if SDWORD PTR eax < SDWORD PTR min
mov min, eax
.endif
.endif
mov f, 0
inc ebx
.until ebx > MAXBUF
invoke crt_printf, SADD('min=%d%s'), min, ADDR szCRLF
invoke crt_printf, SADD('Press any key to exit ....')
invoke crt__getch
ret
WinMain endp
;-----------------------------------------------------------
end start
помогите перевести с Pascal'я на ассемблер код
на паскале написать было не трудно, а вот на ассемблере... прошу помочь, очень надо)
Код:
uses crt;
const n=10;
Type
mas = array [1..n] of integer;
Var
a,b : Mas;
i, j, min ,f: integer;
Procedure vvod(Var X : mas);
Begin
For i :=1 to n do
x [ i ]:= random(n)-20;
end;
Procedure vivod(var x: mas);
Begin
For i :=1 to n do
Write ( x [ i ],' ');
writeln;
end;
BEGIN
clrscr;
vvod(a);
vvod(b);
vivod(a);
vivod(b);
f:=0;
min:=maxint;
for i:= 1 to n do begin
for j:= 1 to n do begin
if a=b[j] then
f:=1
end;
if f=0 then
if a<min then
min:=a;
f:=0;
end;
writeln('min=',min);
readln;
END.
const n=10;
Type
mas = array [1..n] of integer;
Var
a,b : Mas;
i, j, min ,f: integer;
Procedure vvod(Var X : mas);
Begin
For i :=1 to n do
x [ i ]:= random(n)-20;
end;
Procedure vivod(var x: mas);
Begin
For i :=1 to n do
Write ( x [ i ],' ');
writeln;
end;
BEGIN
clrscr;
vvod(a);
vvod(b);
vivod(a);
vivod(b);
f:=0;
min:=maxint;
for i:= 1 to n do begin
for j:= 1 to n do begin
if a=b[j] then
f:=1
end;
if f=0 then
if a<min then
min:=a;
f:=0;
end;
writeln('min=',min);
readln;
END.
Какого рода помощь требуется? Что уже есть готового?
Не пытался менять логику программы, просто транслировал на MASM. Логика программы просто ужасна и неверна.