[Asm] Małe pytanko...

0

Jestem w asm dość początkujący i chciałbym spytać o 2 rzeczy.

  1. Jak zrobić prockę, która co jedną sekundę dokłada do stosu jakąś liczbę.
  2. Jak sprawić, aby w asm wyłączył się monitor?
0

ad.2 - Wygaszanie polega na wyłączeniu odświerzania, a właściwie na blokowaniu wyswietlania. Jeden ze sposobów.

.model small

.stack 100h

.data
  copyright db "2003 (c) no-body :] !",13,10,10,"You have to press <esc> to proceed",13,10,'$'

.code
screenon PROC
  mov al,01h
  mov dx,03c4h
  out dx,al
  mov dx,03c5h
  in  al,dx
  and al,0dfh
  out dx,al
  ret
screenon ENDP

screenoff PROC
  mov al,01h
  mov dx,03c4h
  out dx,al
  mov dx,03c5h
  in  al,dx
  or  al,20h
  out dx,al
  ret
screenoff ENDP

press_esc PROC
  @1:
  xor ah,ah
  int 16h         ; wait for keyboard
  xor ax,011bh    ; esc pressed ?
  jnz @1          ; repeat until esc
  ret
press_esc ENDP

Startprogramu:

  mov  ax,@data
  mov  ds,ax
  mov  dx,OFFSET copyright
  mov  ah,09h
  int  21h

  call press_esc
  call screenoff
  call press_esc
  call screenon
  call press_esc

  mov  ax,4c00h             ; return code 0
  int  21h                  ; bye

END Startprogramu
0

Ad. 2) inny sposób:

OFF

mov    ah,12h
mov    bl,36h
mov    al,1
int    10h

ON

mov    ah,12h
mov    bl,36h
mov    al,0
int    10h
0

Ad 1. Na stos co sekundę wrzucane jest coś ;)

.model huge
.stack 100h

.data
  copyright db "2003 (c) no-body :]",13,10
            db 10,"You have to press <spacebar> to terminate"
  crlf      db 13,10,'$'
  terminate db 13,10,10,"yeah, that",39,"s right ! she",39,"s stupid !"
            db 13,10,10,"normal program termination",13,10,'$'
  userbreak db 13,10,10,"user abort",13,10,'$'
  byebye    db "bye, cya",13,10,'$'
  sekunda   db (?)
  alamakota db "ala ma kota$"
  empty     db 13,"           ",13,'$' ; wyczyscic tlo.
  popflag   db 0

.code

stackwrite proc
  mov dx,offset empty
  mov ah,09h
  int 21h                ; clear the line
  mov di,0feh            ; for huge/large..., for tiny 100h
  mov ah,0eh             ; video service: write tty
  mov bx,0007h           ; hi:active page,lo:color for graph mode
  @w1:                   ; while [ss:di]<>'$' do write [ss:di]
  mov al,byte ptr ss:[di]
  cmp al,'$'
  je  @w2
  int 10h                ; video service: write tty
  dec di                 ; -2 because of ...
  dec di                 ; word allignment on the stack
  jmp @w1
  @w2:
  ret
stackwrite endp

go:
  mov  ax,@data
  mov  ds,ax            ; data segment, initialize ds

  mov  dx,offset copyright
  mov  ah,09h
  int  21h              ; write string$

  mov  ah,2ch           ; dos service get time
  int  21h              ; return: seconds in dh
  mov  byte ptr ds:[sekunda],dh

  xor  bx,bx            ; short pointer

  @a:
  mov  ah,2ch
  int  21h
  cmp  dh,byte ptr ds:[sekunda]
  je   @y               ; jump if stil the same second
  mov  byte ptr ds:[sekunda],dh
  test byte ptr ds:[popflag],01h
  jnz  @c               ; push or pop?

  @b:                   ; pushing out to stack
  mov  ax,word ptr ds:[alamakota+bx]
  push ax               ; stack word allignment
  inc  bx               ; pointer++
  cmp  al,'$'           ; last sign of string?
  jne  @d               ; not yet
  mov  byte ptr ds:[popflag],01h
  dec  bx             
  pop  ax

  @c:                   ; popping in from stack
  dec  bx               ; --pointer
  pop  ax

  @d:
  mov  al,'$'
  push ax
  push bx               ; save pointer
  call stackwrite       ; write data stored on stack
  pop  bx               ; restore pointer
  pop  ax

  mov  dx,offset terminate
  test bx,bx            ; is stack free?
  je   @z               ; or jz ; if yes -> quit

  @y:                   ; keyboard block
  mov  ah,11h
  int  16h              ; any key pressed ?
  jz   @a               ; repeat if not
  mov  ah,10h
  int  16h              ; get pressed key
  xor  al,20h           ; spacebar pressed ?
  jnz  @a               ; repeat until spacebar

  mov  dx,offset userbreak
  @z:
  mov  ah,09h
  int  21h
  mov  dx,offset byebye
  mov  ah,09h
  int  21h

  mov  ax,4c00h         ; return code 0
  int  21h              ; bye

end go
0

Dzięki za wszystko. Miłego dnia...

1 użytkowników online, w tym zalogowanych: 0, gości: 1