Jump to content
GIGN Forum

Vajadziiga Palidziiba :(


bloodlord
 Share

Recommended Posts

mekleju kadu cilveeku/s ,kas kaut ko saprot no paskaalja , paskalja asamblera un palidzeetu man uztaisiit paris darbus , parada nepalikshu smile.gif

Aizmirsu piebilst ka butu forshi ja butu pierakstiiti ari komentari , ko kas dara.

ps : JA NEVARI PALIDZEET VARI TE NEKO NERAKSTIT

1) kaut kas saistiits ar LOOP

Atrast visu pāra skaitļus intervāla no m lidz n summu , kur m un n ievada lietotājs.

2) tjip asm , lidz 26

Aizpildīt masīvu ar nepāra skaitļiem , kas sākas no 1 un atrast masīva elementu summu

Edited by bloodlord
Link to comment
Share on other sites

mekleju kadu cilveeku/s ,kas kaut ko saprot no paskaalja , paskalja asamblera un palidzeetu man uztaisiit paris darbus , parada nepalikshu smile.gif

ps : JA NEVARI PALIDZEET VARI TE NEKO NERAKSTIT

1) kaut kas saistiits ar LOOP

Atrast visu pāra skaitļus intervāla no m lidz n summu , kur m un n ievada lietotājs.

2) tjip asm , lidz 26

Aizpildīt masīvu ar nepāra skaitļiem , kas sākas no 1 un atrast masīva elementu summu

Varu palidzet, bet isti nesaprotu, ko tev vajag?

kada pskala? turbo? un pricom asamplers?

Beefs

nu primais un otrais nevajag pat ciklu, bet ok

1)

res :=0;

for x:=m to n do if not odd(yay.gif then inc(res,yay.gif;

2)

for x:=1 to 26 do mas[x]:=x*2-1;

Edited by 0xDEAD BEEF
Link to comment
Share on other sites

Ja pareizi sapratu, tad vajag atrast visu pāra skaitļu summu, intervālā no m līdz n.

Ja lielotājs ievada m = 1 un n = 10, tad 2+4+6+8 būs pāru skaitļu summa intervālā no 1 līdz 10. Am I right ?

Cik steidzami Tev šo vajag ?

Link to comment
Share on other sites

man vajag lai uztaisa abas programmas , vienagla kada paskaali , un cik atceros tad tas otrais bija jataisa ar asm , bet varbuut ari kludos smile.gif

Blja nu izdoma, ko tev vajag, a to pizdi dabusi! wink.gif

pirma programa turbo paskala -

uses crt;

var m,n,x,res:integer;

begin

write('Ievadiet m un n:');

readln(m,n);

if not (m<n) then

begin

writeln('m jabut mazak par n!');halt;

end;

res:=0;

for x:=m to n do if not odd(x ) then inc(res,x );

writeln('rezultats ir ', res);

end.

Un par otro izdoma, ko tev isti vajag! Asamblera vai paskala. Un ja asamblera, tad nevaru palidzet ar ievadu un izvadu, jo tas asablers ir tik anarhaisks, ka man vina nemaz vairak nav, bet varu iedot kodu paskala, ko vari parverst asamblera un pec tam izpipe, ka uztaisit ievadu un izvadu taja miskaste.

Beefs

Edited by 0xDEAD BEEF
Link to comment
Share on other sites

te buus viens uzdevums .

lietpotaajs ievada veselos skaitljus a un x, kaa arii tiek

ievadiits f(yay.gif}

program funkcija;

uses crt;

var x,a,f:integer;

label l1,l2,l3;

begin

clrscr;

writeln ('a/x,x<-2');

writeln ('2x,-2<=x<=500');

writeln ('ax, x>500');

writeln('ievadiet x');

readln (yay.gif;

writeln ('ievadiet a');

readln (a);

asm

cmp x,-2;

JNL l1 {x>=-2 iet uz l1}

mov AX,a {x<-2}

mov BX,1{reizinaam ax ar 1, lai buutu drosi, par dx saturu}

imul BX

mov BX,x

idiv BX {(AX:BX)}

mov f, AX

JMP l3

l1:cmp x,-2 {x nav <-2, taatad -2<=x}

JL l2 {x<=500}

mov AX, 2

imul x

mov f,AX

JMP l3

l2:cmp x,500

JG l3 {x>500}

mov AX, x

mul a

mov f,AX

l3:end;

writeln ('f(yay.gif=',f) ;

readln;

end.

Link to comment
Share on other sites

te buus viens uzdevums .

lietpotaajs ievada veselos skaitljus a un x, kaa arii tiek

ievadiits f(yay.gif}

program funkcija;

uses crt;

var x,a,f:integer;

label l1,l2,l3;

begin

clrscr;

writeln ('a/x,x<-2');

writeln ('2x,-2<=x<=500');

writeln ('ax, x>500');

writeln('ievadiet x');

readln (yay.gif;

writeln ('ievadiet a');

readln (a);

asm

cmp x,-2;

JNL l1 {x>=-2 iet uz l1}

mov AX,a {x<-2}

mov BX,1{reizinaam ax ar 1, lai buutu drosi, par dx saturu}

imul BX

mov BX,x

idiv BX {(AX:BX)}

mov f, AX

JMP l3

l1:cmp x,-2 {x nav <-2, taatad -2<=x}

JL l2 {x<=500}

mov AX, 2

imul x

mov f,AX

JMP l3

l2:cmp x,500

JG l3 {x>500}

mov AX, x

mul a

mov f,AX

l3:end;

writeln ('f(yay.gif=',f) ;

readln;

end.

karoce - panejm tad pasaklu, nokomile debug versiju. ieliec breakpointu un tad, kad nobreiko, tad atver cpu un redzesi asm kodu. nokope visu, izmet lieku un bus tev asm kods vajadzigas! wink.gif

Beefs

p.s. es to nevaru izdarit, jo man nav pieejams paskals. varu tikai uzrakstit kodu paskala.

Link to comment
Share on other sites

nja ,butu labi ja es kaut ko saprastu no tava rakstiita smile.gif

tu tacu datorus stude.. :/ tev jasaprot! smile.gif

Karoce - ta programa kura programe, vina var izveleties nokompilet debug rezima programu. Tu maki vispar kompilet un palaist programu.. :/

Ka tad tu ucukam paradisi to kodu?

Beefs

Link to comment
Share on other sites

karoce - panejm tad pasaklu, nokomile debug versiju. ieliec breakpointu un tad, kad nobreiko, tad atver cpu un redzesi asm kodu.

nu shito es nesapratu smile.gif paareejais nebij tik gruuts smile.gif

PS beefi negribi paliidzeet scaraa uztaisiit programminju ?

Link to comment
Share on other sites

nu shito es nesapratu smile.gif paareejais nebij tik gruuts smile.gif

PS beefi negribi paliidzeet scaraa uztaisiit programminju ?

sorry.. sadirsu..

karoce options debuger jaiekekse standalone sebuging. tad tool-> turbo debuger. tad view -> cpu

un rezultats

PROGRAM.10: for x:=m to n do if not odd(x ) then inc(res,x );

cs:00B3 A15400 mov ax,[0054]

cs:00B6 8946FE mov [bp-02],ax

cs:00B9 A15200 mov ax,[0052]

cs:00BC 3B46FE cmp ax,[bp-02]

cs:00BF 7F1F jg PROGRAM.11 (00E0)

cs:00C1 A35600 mov [0056],ax

cs:00C4 EB04 jmp 00CA

cs:00C6 FF065600 inc word ptr [0056]

cs:00CA A05600 mov al,[0056]

cs:00CD D0E8 shr al,1

cs:00CF 7207 jb 00D8

cs:00D1 A15600 mov ax,[0056]

cs:00D4 01065800 add [0058],ax

cs:00D8 A15600 mov ax,[0056]

cs:00DB 3B46FE cmp ax,[bp-02]

cs:00DE 75E6 jne 00C6

nav erti, tapec parakstisim bisku kodu! wink.gif

nu re - te viss skaidri redzam! 18.gif)

PROGRAM.10: for x:=m to n do

cs:00B3 A15400 mov ax,[0054] //n

cs:00B6 8946FE mov [bp-02],ax

cs:00B9 A15200 mov ax,[0052] //m

cs:00BC 3B46FE cmp ax,[bp-02]

cs:00BF 7F1F jg PROGRAM.13 (00E0)

cs:00C1 A35600 mov [0056],ax //x:=m

cs:00C4 EB04 jmp PROGRAM.11 (00CA)

cs:00C6 FF065600 inc word ptr [0056] //x:=x+1

PROGRAM.11: if not odd(x ) then

cs:00CA A05600 mov al,[0056]

cs:00CD D0E8 shr al,1 // al = x / 2

cs:00CF 7207 jb 00D8 //ja nav odd, tad ejam uz cikla beigam

PROGRAM.12: inc(res,x );

cs:00D1 A15600 mov ax,[0056] //ax = x

cs:00D4 01065800 add [0058],ax //res = res + x (ax)

cs:00D8 A15600 mov ax,[0056] //cikla beigas. ax = x

cs:00DB 3B46FE cmp ax,[bp-02] //vai ax = n??? btw n tiek tagad glabats steka!

cs:00DE 75E6 jne 00C6

Link to comment
Share on other sites

tagad no musu koda aiznemsimies vertigo ifu! smile.gif

mov al,x

shr al,1

jb notodd

mov ax,x

add res,ax

:notodd

un izdomasim loopu

mov cx,n //ieliekam cx n

dec cx,m //atnemam no cx m

:loops

loop loops //loopojam kamer cx nav 0le! 18.gif)

tagad saliksim visu kopa! 18.gif

asm

mov res,0

mov ax,m

mov x,ax

mov cx,n

sub cx,m

inc cx

loops:

mov ax,x

shr al,1

jb notodd

mov ax,x

add res,ax

notodd:

inc x

loop loops

end;

Link to comment
Share on other sites

jaatdzist, ka tas ir viss tizlakais veids, kada var lietot loopu.. sad.gif((

var m,n,x,res:integer;

label loops,notodd;

begin

write('Ievadiet m un n:');

readln(m,n);

if not (m<n) then

begin

writeln('m jabut mazak par n!');halt;

end;

res:=0;

for x:=m to n do

if not odd(x ) then

inc(res,x );

writeln('rezultats ir ', res);

asm

mov res,0

mov ax,m

mov x,ax

mov cx,n

sub cx,m

inc cx

loops:

mov ax,x

shr al,1

jb notodd

mov ax,x

add res,ax

notodd:

inc x

loop loops

end;

writeln('rezultats asma ir ', res);

end.

Link to comment
Share on other sites

Te bus otra proga.

Karoce

PROGRAM.5: res:=0;

cs:0030 31C0 xor ax,ax

cs:0032 A35400 mov [0054],ax

PROGRAM.6: for x:=1 to 26 do

cs:0035 C70652000100 mov word ptr [0052],0001

cs:003B EB04 jmp PROGRAM.8 (0041)

cs:003D FF065200 inc word ptr [0052]

PROGRAM.8: mas[x]:=x*2-1;

cs:0041 A15200 mov ax,[0052]

cs:0044 D1E0 shl ax,1 //x* 2

cs:0046 48 dec ax //x-1

cs:0047 8B3E5200 mov di,[0052]

cs:004B D1E7 shl di,1

cs:004D 89855400 mov [di+0054],ax

PROGRAM.9: inc(res,mas[x]);

cs:0051 8B3E5200 mov di,[0052]

cs:0055 D1E7 shl di,1

cs:0057 8B855400 mov ax,[di+0054]

cs:005B 01065400 add [0054],ax

PROGRAM.10: end;

cs:005F 833E52001A cmp word ptr [0052],001A

cs:0064 75D7 jne 003D

un rezultata kods! wink.gif

var x,res:integer;

mas:array[1..26] of integer;

label loops,notodd;

begin

res:=0;

for x:=1 to 26 do

begin

mas[x]:=x*2-1;

inc(res,mas[x]);

end;

writeln('rezultats ir ', res);

asm

mov res,0

mov cx,26

loops:

mov ax,cx

shl ax,1

dec ax

mov di,cx

shl di,1

mov [di+offset mas],ax

add res,ax

loop loops

end;

writeln('rezultats asma ir ', res);

end.

p.s. es tikai nezinu, vai tas asma klucis pareizi aizpilda masivu... vajadzetu kaut kadu kodinu vel piemest, kas izvada to masivu uz ekrana, bet man slinkums! tongue.gif

Edited by 0xDEAD BEEF
Link to comment
Share on other sites

karoce vajag bisku pielabot sito rindinu

mov [di+offset mas],ax

jabuut

mov [di+offset mas-2],ax

jo uz cx 0 sitais kods neiziet un tapec neaizpilds masiva 0to elemtnu

Beefs

edit beigas vari piemest

for x:=1 to 26 do write(mas[x],' ');

tad redzesi, kas ir taja masiva salikts ieksa!

Parliecibas pec gan tad vajadzetu izkomentet augsejo kodu, kas darbojas ar masivu, lai butu ticamibas moments, ka masivu aizpilda asm nevis paskala kods.

EDIT: un vispar tev pizdata paveicas, ka man uz kompja vel paskals vecais metajas! ja?! wink.gif

Edited by 0xDEAD BEEF
Link to comment
Share on other sites

;)

Beefs

Kr4 scar ir programmeeshanai domaata proga :)

pamataa uz pascall baazes, bet nu daudz piemeerotaaka darbiibai ar win... tb var image lasiit, rakstiit

man caur vinju vajadzeetu uztaisiit progu kas nolasa skaitljus no skaitlju regenereetaaja un ievada laukaa !!! diemzeel nokopeet vinjus nevar un tad jau arii tev paliidziibu neprasiitu ! :)

PS. SCAR ir lv izveidota proga un vinju var inetaa novilkt !!

Edited by mader
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...