- -

» - -

- -


1.

3: - - .

PASCAL :

var

res i: integer;

begin

res:=0;

for i:=1 to 10 do

if i mod 2 <> 0 then

begin

res:=i;

writeln (res);

end;

end.

2.

ALTER ( ):

Turbo Assembler Version 4.1 12/12/08 00:18:57 Page 1

11. ASM

1 0000 .Model Small

2 0000 .Stack 100h

3 0000 .Data

4 0000 FF*(??) __bufrw db 255 dup (?)

5_________________________;_res_____ dw_____?

6_________________________;_i_____ dw_____?

5 6

7 00FF .Code

8 0000 Main proc

9 0000 B8 0000s mov ax @data

10 0003 8E D8 mov ds ax

11 ; _res

12__________; mov _res 0_____; _____ _res_____0

12 mov ax 0

13 0005 B8 0000

14 ; FOR 1

15 ; _i

16____________________; mov _i 1_____; _____ _i 1

17____________________; mov bx _i; BX _i

16 17 mov bx 1

18 0008 BB 0001

19 000B B9 000A mov cx 10 ; cx 10

20 000E EB 01 jmp $+3 ; 3

21 0010 for_b_1:

22 0010 43 inc bx ; 򠠠 BX

23__________; push bx_______________; BX

24_______________; push cx_______________; CX

23 24 push bx cx

25 0011 53 51

26_____; mov _i bx__________; _i BX

26

27 ; ࠠ 1

28 ;

29 ; mov ax _i ; AX _i

30 0013 8B C3 mov ax bx

31 0015 53 push bx

32 0016 BB 0002 mov bx 2 ; BX 2

33 0019 33 D2 xor dx dx ; DX

34 001B F7 F3 div bx ;

35 001D 92 xchg ax dx ; 堠 AX BX

36 001E 8B D8 mov bx ax ; bx ax

37 ; 頠

38 0020 BA 0000 mov dx 0 ; dx 0

39 0023 3B DA cmp bx dx ; BX c DX

40 0025 5B pop bx

41 0026 74 0F je else_1

42 ; _res

43__________; mov ax _i__________; _____AX _i

mov ax bx

44 0028 8B C3

45_____; mov _res ax_____; _____ _res_____AX

45

46 ; ࠠ WRITE

47__________; mov ax _res_____; _____AX _res

45

48 002A E8 0014 call sl_itoa ;

49 002D B4 02 mov ah 2 ; AH

50 002F B2 0D mov dl 13 ; 頠

51 0031 CD 21 int 21h ; DOS

52 0033 B2 0A mov dl 10 ; 頠

53 0035 CD 21 int 21h ; DOS

54 0037 else_1:

55 ; 1

56__________; pop cx__________; CX

57_______________; pop bx__________; BX

pop cx bx

Turbo Assembler Version 4.1 12/12/08 00:18:57 Page 2

11.ASM

58 0037 59 5B

59 0039 3B D9 cmp bx cx ; BX CX

60 003B 75 D3 jne for_b_1 ;

61 ; FOR 1

62 003D B4 4C mov ah 4ch

63 003F CD 21 int 21h

64 0041 endp

65 0041 sl_itoa proc

66 0041 50 53 51 52 push ax bx cx dx

67 0045 3D 0000 cmp ax 0

68 0048 7D 0A jge Doit

69 004A 50 push ax

70 004B B2 2D mov dl '-'

71 004D B4 02 mov ah 2

72 004F CD 21 int 21h

73 0051 58 pop ax

74 0052 F7 D8 neg ax

75 0054 E8 0011 DoIt: call puti2

76 0057 5A 59 5B 58 pop dx cx bx ax

77 005B C3 ret

78 005C sl_itoa endp

79

80 005C sl_utoa proc

81 005C 50 53 51 52 push ax bx cx dx

82 0060 E8 0005 call PutI2

83 0063 5A 59 5B 58 pop dx cx bx ax

84 0067 C3 ret

85 0068 sl_utoa endp

86

87 0068 Puti2 proc

88 0068 BB 000A mov bx 10

89 006B 33 D2 xor dx dx

90 006D F7 F3 div bx

91 006F 0B C0 or ax ax

92 0071 74 05 jz Done

93 0073 52 push dx

94 0074 E8 FFF1 call Puti2

95 0077 5A pop dx

96 0078 Done:

97 0078 80 CA 30 or dl '0'

98 007B B4 02 mov ah 2

99 007D CD 21 int 21h

100 007F C3 ret

101 0080 PutI2 endp

102

103 end Main

Turbo Assembler Version 4.1 12/12/08 00:18:57 Page 3

Symbol Table

Symbol Name Type Value

?? DATE Text 12/12/08

?? FILENAME Text 11

?? TIME Text 00:18:56

?? VERSION Number 040A

@32BIT Text 0

@CODE Text _TEXT

@CODESIZE Text 0

@CPU Text 0101H

@CURSEG Text _TEXT

@DATA Text DGROUP

@DATASIZE Text 0

@FILENAME Text 11

@INTERFACE Text 000H

@MODEL Text 2

@STACK Text DGROUP

@WORDSIZE Text 2

DOIT Near _TEXT:0054

DONE Near _TEXT:0078

ELSE_1 Near _TEXT:0037

FOR_B_1 Near _TEXT:0010

MAIN Near _TEXT:0000

PUTI2 Near _TEXT:0068

SL_ITOA Near _TEXT:0041

SL_UTOA Near _TEXT:005C

__BUFRW Byte DGROUP:0000

Groups & Segments Bit Size Align Combine Class

DGROUP Group

STACK 16 0100 Para Stack STACK

_DATA 16 00FF Word Public DATA

_TEXT 16 0080 Word Public CODE


3. -

- :

1)  .

2)  .

3)  .

4)  .

4. -

- :

1. .. .

2. . . .

3. .


660 640 .

:

  i res ax bx - .

 

pop x

pop bx

pop x bx;

push cx

push bx

push bx cx;

.