Mini-Soft Assembler IBM PC 9. 4. -
:








Soft


MSDN




:



,


:
2014-03-11
2014-03-10
2014-03-10
2014-03-10
RSS ...




  .
9

9. 4


-

9.1.

     ASCII- .

     .

9.2.

- , , , , ASCII. , ASCII.

, , - , .

9.2.1.
16-

, () 1, . . 16- 8000h...0FFFFh. . 0000h ... 7FFFh . . 4.1 , DW.

4.1

16-

8- 16-

, (hex)

65535

...

32768

177777q=FFFFh

...

100000q=8000h

FFFF

...

8000

1

32767

...

127

...

1

0

77777q=7FFFh

...

177q=7Fh

...

1q=1h

0

7FFF

...

007F

...

0001

0000

2

-1

...

-128

...

-32768

-1q=-1h

...

-200q=-80h

...

-100000q=-8000h

FFFF

...

0080

...

8000

3

-32769

...

-65535

-65536

-100001q=-8001h

...

-177777q=-FFFFh

-200000q=-10000h

7FFF

...

0001

0000

4

 

. 4.1: 1 , 2 , 3 , 4 "-" . , , .

, . 0FFFFh , 1, . , , .

9.2.2. ASCII-

(2, 8, 10 16), , . ASCII- . ASCII- () , , , .

P, 2, 8, 10, P = 16.

. 4.2 , ASCII- ( ) ASCII- (A, B, ...F). 30h, 37h.

4.2

ASCII-

()

0

1

 

9

A

 

F

16-

ASCII-

30

31

 

39

41

 

46

( )

0000

0001

 

1001

1010

 

1111

 

n-  = anan-1...a1 :

anan-1...a2a1=((...(0 * P + an)P + an-1)P +...+a2)P + a1.

:  	 	 
02 03 07	(((0*10) + 02)*10 + 03)*10 + 07	11101101

n , : P ( 0) () .

: 237(10) = 11101101(2).

ASCII- , 4.1.

4.1. ASCII- (6  = + 5 ) bx 16- ax.

Comment /*

: ASCII- BX,

CX - ASCII- , '-'.

: "" .

: ax -16- ax,

cf=1, 32767 -32768, cf=0. */

proc #dec_bin

cmp [byte bx],'-' ; ?

jne positive

inc bx ;

dec cx ;

call conv ; .

; : ax ,

;f=1, 65535 (.. ax )

jc overflow ; > 65535?

cmp ax,32768

ja overflow ; >32768

neg ax ;

js good ;

positive: call conv ; .

jc overflow ; > 65535?

cmp ax,32767

jbe good ;< 32767

overflow: stc ;cf=1

jmp n_good ;

good: clc ;cf=0

n_good: ret

endp #dec_bin

proc conv ;

push dx di

xor ax,ax ;

mov di,10 ;10-

cycl: mul di ;dx:ax = ax*10

jc over_flow ;, CF=1

mov dl,[bx] ; ASCII-

sub dl,30h ;

add ax,dx ;

jc over_flow ;, CF=1

inc bx

loop cycl ;, cx>0

clc ;, CF=1

over_flow: pop di dx

ret

endp conv

9.2.3. ASCII-

. ASCII- (), ASCII-.

P. ASCII- ( , ). , , .

30h ( = 2, 8, 10 , , ASCII- 16- ). ASCII- A,B,...,F 37h. , ( ).

:    
     			ASCII- 
   10
1	(((0*10)+02)*10 + 03	07	37h (. )
2	((0*10) + 02)	03	33h
3	0	02	32h (. )
   ASCII-: 32 33 37.

: 11101101(2)=237(10).

ASCII- , 4.2.

4.2. 16- ASCII- dec_buf (+5). bx.

Comment /*

: ax 16- ,

bx dec_buf ASCII- 6 .

: ASCII- dec_buf (+5),

ax .

: ASCII - , , .*/

Proc Bin_#dec

push dx di cx

push ax ;

mov cx,6 ;

Blank: mov [byte bx],' ' ; , ..

inc bx

loop Blank

dec bx ;

mov di,10 ;

or ax,ax ; SF

jns trans ; , SF=0

neg ax ;

trans: sub dx,dx ; dx=0

div di ;ax=quot(dx:ax/10), dx=rem(dx:ax/10)

add dl,'0' ; ASCII-

mov [byte bx],dl ;

dec bx ;

or ax,ax ; ?

jnz trans ;, >0

pop ax ; ,

or ax,ax ;

jns out_ trans ; , SF=0

mov [byte bx],'-' ; '-'

pop cx di dx

out_trans: ret

Endp Bin_#dec

End

9.2.4. .

1-7 (. 4.3).

4.3

1-7

ASCII

1

16- , ,

1

2

16- , ,

1

3

16- ,

,

ASCII-

4

16- ,

,

ASCII-

5

16- , ,

ASCII

6

16- , ,

7

16- , ,

 

.

1.   ASCII- ( 32768 32767) 16- ( ).

2.   ASCII- , (). ( ) .

3.   ASCII- .

8-14 (. 4.4).

, , . (). . , .

4.4

8-14

-

8

+ - *

EQ

True/false

9

/ + -

NE

True/false

10

- * /

GE

True/false

11

* / +

GT

True/false

12

- * /

GE

True/false

13

+ - *

LT

True/false

14

/ + -

LE

True/false

 

(add, sub, imul, idiv, cwd), cmp . 16-- 32 ;
16- 32 .

( 14 ).

     (. . 9.2.5);

     32768 32767, ;

     . "" ( ), . <Enter>.

     "8"-,"10"- "16"-e (.. ), 16- . ( ) .

     . :

     , 16- , , ;

     .

     , .

     , , .

     . .

9.2.5.

, . , .

():

     (8-,10-,16-), ASCII-, ( "ASCII- P");

     ASCII- P ;

     .

, ( ). , "" , . . :

     Stack;

    

Start: mov ax,@data

mov ds,ax

     End, Start, .

, :

     ;

     ;

     .

, , . , - . . .

: , .

Extrn <>:<>,,< >:<>.

.

     : byte, word, dword, tbyte

     : abs ( =)

     : near,far

     : proc

, () , -

Public <>, ,<>

, 16- . , .

%Title "#dec_bin.asm"

; 10- ASCII- 16- -

; .

;: ASCII- "10"

; -32768 32767. "-

;" . d.

;: - 16- ,

; CF- : -32768...32767, .

Ideal

Model small

Dataseg

In_buf db 8,?,8 dup(?) ;5- +" "+ " "+"CR"

Codeseg

public ASCIIdec_bin

proc ASCIIdec_bin

..

ret

endp ASCIIdec_bin

End

%Title "Bin_#bin.asm"

; . ASCII-

; .

;: - .

;: - ,

; Bin_buf 16 ASCII- .

Ideal

Model small

Dataseg

public Bin_buf

Bin_buf DB 16 dup(?)

Codeseg

public Bin_ASCIIbin

proc Bin_ASCIIbin

..

endp Bin_ASCIIbin

End

%Title "Bin_#dec.asm"

; ASCII-

; "10" d.

;: - .

;: - ,

; 7- Dec_buf . ( +

;5 + -).

Ideal

Model small

Dataseg

public Dec_buf

Dec_buf db 7 dup(?) ;

Codeseg

public Bin_ASCIIdec

proc Bin_ASCIIdec

.

endp Bin_ASCIIdec

End

, . , 2. BIOS. , .

%Title"#10bin10.asm"

;

;( -32768...32767) .

; , .

 

Ideal

Model small

Stack 256

%nomacs ;

Macro out_str$ mes ; mes

..

Endm out_str$

Macro out_buf buf,number ; buf

;number

..

Endm out_buf

Dataseg

extrn Bin_buf:byte:16, Dec_buf:byte:7

mes1 DB 13,10,' -'

DB 13,10,' d -32768d 32767d: $'

mes2 DB 13,10,' : $'

mes3 DB 13,10,' :$'

mes4 DB 13,10,' : $'

mes5 DB 13,10,' <F1>, <F10>? $'

Codeseg

extrn ASCIIdec_bin:proc, Bin_ASCIIbin:proc, Bin_ASCIIdec:proc

Start: mov ax,@data ; ds

mov ds,ax ;

call screen ;

; (. . . 3)

Again: out_str$ mes1 ; mes1

call ASCIIdec_bin ; -

;

jc Abort ; ?

call Bin_ASCIIbin ;. ASCII- ;

out_str$ mes3 ; mes3

out_buf Bin_buf,16 ;

call Bin_ASCIIdec ; ASCII- ;

out_str$ mes4 ; mes4

out_buf Dec_buf,7 ; ;

; . <F1>, -<F10>.

Exit mov ax,4C00h ; DOS 4h:

int 21h ; DOS.

Abort: out_str$ mes2 ; mes2

jmp Again ;

END Start ; /

9.2.6. .

, . 9.2.5 , tasm , . , main.asm x.asm y.asm. ( ):

tasm main.asm

tasm x.asm

tasm y.asm

.asm, tasm *.asm. tlink. , ( ), ( ):

Tlink main.obj x.obj y.obj

, , calculator :

Tlink main.obj x.obj y.obj ,calculator

¨ ¨ ¨

. , , ( ) , . tlib (Turbo Library) (). .lib, , , . , , Call, Extrn. tlink , . , tlib . :

TLIB 4.00 Copyright (c) 1987, 1996 Borland International

Syntax: TLIB libname [/C] [/E] [/P] commands, listfile

Libname ( )

/C

/E .

-

/Psize

Commands ()

+

*

+ +

* *

listfile

Turbo Library

     mylib.lib x.obj y.obj:

Tlib/E mylib +x.obj +y.obj

     mylib.lib . (), :

Tlib/E mylib +x.obj +y.obj, mylib.lst

     mylib.lst mylib.lib:

Tlib mylib, mylib.lst

     x.obj y.obj: Tlib mylib +x.obj y.obj

, x.obj y.obj , main.obj, main ( ):

Tlink main.obj ,,, mylib.lib

, . , :

Tlink main.obj ,,, mylib1.lib mylib2.lib

9.3.

1.       ASCII- .

2.       ASCII- .

4.       ?

5.       , ?

6.       .

7.       , ?

8.       , ?

9.       , mta.lib a.obj, b.obj c.obj.

10.   main.obj, mylib.

 

 

: |
  Mini-Soft Assembler IBM PC 9. 4. -
cloud server, cloud hosting, VPS server
Mini-Soft.ru  
Copyright © Mini-Soft 2003-2009 mini-soft@narod.ru