<¾î¼Àºí¸®¾î 6,7°>
1.pr16bitÀÇ ¿ë¹ý¿¡ ´ëÇؼ...
ÇÁ·Î½ÃÀúÀÎ pr16bit´Â MYLIB1.LIB»ó¿¡ Á¸ÀçÇÑ´Ù.
±×·³ MYLIB1.LIB¿¡¼ pr16bit ³»¿ëÀ» »ìÆ캸¸é
;PR16.ASM
PUBLIC PR16BIT
CODE SEGMENT PUBLIC
ASSUME CS:CODE,DS:DATA,SS:DATA
PUBLIC _HERE
_HERE:
PR16BIT proc NEAR
push ax ;·¹Áö½ºÅ͸¦ ÀúÀåÇÑ´Ù(½ºÅÿ¡ Àӽà ÀúÀå)
push bx
push cx
push dx
push di
;
mov cx,0 ;ÀÚ¸®¼ö¸¦ 0À¸·Î ¼³Á¤
lea di,DIGIT_BUF+6
mov bx,10 ; 10À¸·Î ³ª´©¾î¾ß ÇÔ
DIVALL:
mov dx,0 ; ÇÇÁ¦¼ö¸¦ 0À¸·Î µÒ
div bx ; AX¸¦ 10À¸·Î ³ª´®
or dl,30h ; ³ª¸ÓÁö¸¦ ¾Æ½ºÅ°ÄÚµåȽÃÅ´
dec di
mov [di],dl ; ¾Æ½ºÅ°ÀÚ¸®¼ö¸¦ ¼³Á¤ÇÏ¿© °ªÀ» ³ÖÀ½
inc cx ; ÀÚ¸®¼ö¸¦ Áõ°¡½ÃÅ´
or ax,ax ; ¸òÀÌ 0Àΰ¡?
jnz DIVALL ; 0ÀÌ ¾Æ´Ï¸é OK.
;
PRT: mov ah,2 ; ¼ýÀÚ¹®ÀÚ¸¦ Ãâ·ÂÇ϶ó
mov dl,[di] ; ¹®ÀÚ¸¦ ¹öÆÛ·Î ºÎÅÍ ¾òÀ» °Í.
int 21h
inc di ; ´ÙÀ½ ÀÚ¸®¼ö·Î °¡¼ ¹Ýº¹ÇÔ
loop PRT
pop di ;·¹Áö½ºÅ͸¦ º¹¿øÇÑ´Ù.
pop dx
pop cx
pop bx
pop ax
RET
PR16BIT endp
Áï PR16BIT¸¦ CALL¸í·É¿¡ ÀÇÇØ ºÒ·¯¿À¸é AX¿¡ ÀÖ´Â °ªÀ» ¾Æ½ºÅ° ÄÚµåÈ ½ÃÄѼ Ãâ·ÂÇÏ
°Ô µÈ´Ù. ¿¹·Î ¸¸¾à AX Register ¿¡ ÀÖ´Â °ªÀÌ 50h À̸é 'P'·Î ȸé Ãâ·ÂÀÌ ³ªÅ¸³ª°Ô µÈ´Ù.
¿©±â¼ ÁÖÀÇ ÇØ¾ß ÇÒ Á¡Àº ÇÁ·Î±×·¥»ó¿¡¼ PR16BITÀÇ »ç¿ë½Ã link ÇÏ´Â °úÁ¤¿¡¼ lib file
À» ¹°À» ¶§ MYLIB1.LIB¸¦ ¿¬°á½ÃÄÑÁà¾ßÇÑ´Ù.
2.¶óÀ̺귯¸®ÀÇ ÀåÁ¡
¾î¼Àºí¸® ¾ð¾î¸¦ »ç¿ëÇØ ÇÁ·Î±×·¥À» ÀÛ¼ºÇϴµ¥ ÀÖ¾î ¸î °¡Áö Ưº°ÇÑ ±â´ÉÀ» ¼öÇàÇÏ´Â ·çƾ
À» Á¦¿ÜÇÏ°í´Â ÀÚÁÖ ¾²ÀÌ´Â °£´ÜÇÏ°í ±âº»ÀûÀÎ ·çƾµéÀ» ¸ð¾Æ ³õÀº °ÍÀÌ ¶óÀ̺귯¸®¶ó ÇÏ°Ú
´Ù. ÀÌ small assembler¿¡¼ Á¦°øÇÏ´Â mylib1.libÀÇ °æ¿ì°¡ ±× ¿¹ÀÌ´Ù. ÀÌ ¶óÀ̺귯¸®ÀÇ °æ¿ì
ax·¹Áö½ºÅÍ¿¡ ÀÖ´Â 16Áø¼ö°ªÀ» °ÅÀÇ ¿Ïº®ÇÏ°Ô 10Áø¼ö·Î ¹Ù²Ù¾î Ãâ·ÂÇØ ÁØ´Ù.ÀÌ·± ·çƾµéÀ»
¸ð¾ÆµÐ ÈÀÏÀÎ ¶óÀ̺귯¸®ÀÇ °æ¿ì ¼¼ºÐÈÇÏ¿© ¸ÅÅ©·Î¿¡ ´ëÇÑ ¸ÅÅ©·Î ¶óÀ̺귯¸®, À©µµ¿ì ¶ó
À̺귯¸®, ÇÑ±Û ¶óÀ̺귯¸®µî ¿©·¯°¡Áö°¡ ÀÖ´Ù. Áï ¶óÀ̺귯¸®¸¦ »ç¿ëÇϸé ÀÚÁÖ ¾²ÀÌ´Â ¼ºê
·çƾµéÀ» ÀÏÀÏÀÌ ÄÚµùÇÏÁö ¾Ê°í ¶óÀ̺귯¸®¿¡ ÀúÀåÇؼ ¸µÅ©¸¦ ÇÒ ¶§¿¡ À̸¦ °°ÀÌ ¸ñÀû ÆÄ
ÀÏ¿¡ ¿¬°áÇÏ¿© »ç¿ëÇϱ⸸ ÇÏ¸é µÈ´Ù. ±×·¯¹Ç·Î ÇÁ·Î±×·¡¸Ó°¡ ÀÏÀÏÀÌ ±× ·çƾ¿¡ ´ëÇؼ ½Å
°æ¾²Áö ¾Ê¾Æµµ µÇ°í ±× ¸¸Å ºü¸¥ ½Ã°£³»¿¡ ÇÁ·Î±×·¥À» º¸´Ù È¿À²ÀûÀ¸·Î ÀÛ¼ºÇÒ ¼ö ÀÖ´Ù.
3.¸ÅÅ©·Î¸¦ ÀÌ¿ëÇÑ ÇÁ·Î±×·¥À» ÀÛ¼º....
1.)
data segment
a db 'kim jin ho'
data ends
kim macro hoon ;'kim'À̶ó´Â ¸ÅÅ©·Î ¼±¾ð
mov si,o
Lea bx,a
rept hoon ;ÀÇ»ç ¸í·É¾î rept¼±¾ð
mov dl,[bx+si] ;¹üÀ§ ÁöÁ¤(¹Ýº¹¼öÇà)
mov ah,2
int 21h
inc si ;¿©±â¼ inc´Â increment ¸í·É¾î...
endm ;reptÀÇ»ç ¸í·É¾î Á¾°á
endm ;¸ÅÅ©·Î Á¾°á
code segment
assume cs:code, ds:data
begin;
mov ax,data
mov ds,ax
kim 12
mov ah,4ch
int 21h
code ends
end begin
2.)
main segment
assume cs:main
;-------------------------- MASM version
;putme2 macro arg1,arg2,arg3
; mov dl,&arg1
; mov ah,&arg2
; int &arg3
; endm
;-------------------------- ASM version
putme2 macro arg1,arg2,arg3
mov dl,?1
mov ah,?2
int ?3
endm
;--------------------------
putme2 61H,2,21h
mov ah,4ch
int 21h
main ends
end