现在的位置: 首页 > 综合 > 正文

some functions in assembly

2013年01月09日 ⁄ 综合 ⁄ 共 1406字 ⁄ 字号 评论关闭

show_str:
              show_str:;show a string dh=row number,dl=colum number,cl=color,ds:si point to the string
              PUSH      AX
              PUSH      BX
              PUSH      ES
             
              MOV       BX,0b800h
              MOV       ES,BX
             
              MOV       AL,DH
              MOV       DH,0a0h
              MUL       DH
             
              MOV       DH,0
              ADD       DL,DL
              ADC       DH,0
              ADD       AX,DX
             
              MOV       BX,AX
             
              do:
              CMP       BYTE PTR DS:[SI],0
              JE        sret
              MOV       AL,DS:[SI]
              MOV       ES:[BX],AL
              INC       SI
              INC       BX
              MOV       ES:[BX],CL
              INC       BX
              JMP       do
             
              sret:
              pop  es
              pop  bx
              pop ax
              RET

the step program of int 0

assume cs:code

code segment

main:

step: mov ax,cs
 mov ds,ax
 mov  si,offset int_0 
 
 mov ax,0
 mov  es,ax
 mov di,200h
 mov  cx,offset int_0_end - offset int_0

 cld 
 rep  movsb

set: mov ax,0
 mov es,ax
 mov  word ptr es:[0],200h
 mov  word ptr es:[2],0h

ok: mov ax,4c00h
 int 21h

int_0: jmp  int_0_begin
 msg:  db 'efish: div overflow'
int_0_begin:
 mov  ax,cs
 mov  ds,ax
 mov  si,202h

 mov  ax,0b800h
 mov  es,ax
 mov  di,12*160+36*2
 
 mov  cx,20
do: mov  al,[si]
 mov  es:[di],al
 inc  si
 add  di,2
 loop  do
 
 mov  ax,4c00h
 int  21h 

int_0_end:nop

code ends

end main

抱歉!评论已关闭.