1.6 פסיקות פתרון
תרגיל 1 – print_A.asm
IDEAL
MODEL small
STACK 100h
CODESEG
start:
mov ah, 02h ; DOS – תו יחיד
mov dl, 'A'
int 21h
mov ax, 4C00h ; סיום תקני
int 21h
END start
תרגיל 2 – echo_char.asm
IDEAL
MODEL small
STACK 100h
CODESEG
start:
mov ah, 01h ; DOS: קלט תו
int 21h ; AL ← התו
mov ah, 0Eh ; BIOS TTY output
mov bh, 0
mov bl, 7
int 10h ; מציג את AL
mov ax, 4C00h
int 21h
END start
תרגיל 3 – print_string.asm
IDEAL
MODEL small
STACK 100h
DATASEG
msg db 'Hello, DOS!$',0
CODESEG
start:
mov ax, @data
mov ds, ax
mov dx, offset msg
mov ah, 09h
int 21h ; הדפסה
mov ax, 4C00h
int 21h
END start
תרגיל 4 – read_and_print.asm
IDEAL
MODEL small
STACK 100h
DATASEG
buffer db 19 ; מקסימום‑אורך (עד 19)
db 0 ; DOS ירשום כאן את האורך בפועל
db 19 dup (0) ; מקום לאותיות
dollar db '$',0 ; נשתמש ל‑terminator
CODESEG
start:
mov ax, @data
mov ds, ax
; --- קריאה ---
mov dx, offset buffer
mov ah, 0Ah
int 21h
; --- הוספת ‘$’ לסיום ---
mov bl, [buffer+1] ; אורך שהוקלד
mov bh, 0
mov si, offset buffer
add si, 2
add si, bx ; SI מצביע אחרי התווים
mov byte ptr [si], '$'
; --- הדפסה ---
mov dx, offset buffer+2
mov ah, 09h
int 21h
mov ax, 4C00h
int 21h
END start
תרגיל 5 – custom_int60.asm
IDEAL
MODEL small
STACK 100h
DATASEG
old_off dw ?
old_seg dw ?
CODESEG
start:
cli ; בטיחות
; --- שמירת ה‑Vector הישן ---
mov ax, 0
mov es, ax ; ES=0000h -> IVT
mov bx, 60h
shl bx, 2 ; BX = 60h*4 = 0180h
mov ax, word ptr es:[bx]
mov old_off, ax
mov ax, word ptr es:[bx+2]
mov old_seg, ax
; --- התקנת Handler חדש ---
mov ax, seg myHandler
mov word ptr es:[bx+2], ax
mov ax, offset myHandler
mov word ptr es:[bx], ax
sti
; --- קריאה פעמיים ל‑INT 60h ---
int 60h
int 60h
; --- שחזור ה‑Vector הישן ---
cli
mov ax, old_seg
mov word ptr es:[bx+2], ax
mov ax, old_off
mov word ptr es:[bx], ax
sti
; סיום
mov ax, 4C00h
int 21h
; ----- Handler: מדפיס '*' -----
myHandler:
push ax
mov ah, 0Eh
mov al, '*'
mov bh, 0
mov bl, 7
int 10h
pop ax
iret
END start