《迴圈程式設計》
1.如何輸出自定義變數
2.21h中斷 1號輸入 2號輸出 (乙個字元)
data segment
man db 0
woman db 0
count equ 10
disp db 0dh, 0ah, 'man or woman 1/0?', '$'
disp1 db 0dh, 0ah, 'man:', '$'
disp2 db 0dh, 0ah, 'woman:', '$'
data ends
code segment
assume cs:code, ds:data
start:
mov ax, data
mov ds, ax
mov cx, count
input:
mov dx, offset disp
mov ah, 9
int 21h
mov ah, 1
int 21h
cmp al, '1'
jz mancount
cmp al, '0'
jz womancount
jmp input
mancount:
inc man
jmp loopnext
womancount:
inc woman
loopnext:
loop input
mov dx, offset disp1
mov ah, 9
int 21h
mov bx, offset man
mov dl, [bx]
cmp dl, 10
jb hehe
add dl, 7
hehe:
add dl, 30h
mov ah, 2
int 21h
mov dx, offset disp2
mov ah, 9
int 21h
mov bx, offset woman
mov dl, [bx]
cmp dl, 10
jb haha
add dl, 7
haha:
add dl, 30h
mov ah, 2
int 21h
mov ah,1
int 21h
mov ah, 4ch
int 21h
code ends
end start
/*矩陣相乘
* */
assume cs:code, ds:data, ss:stack
data segment
s1 db 255, 2, 26, 251, 2, 1, 3, 4, 6, 5, 8, 9, 8, 2, 5, 7
s2 db 224, 2, 7, 4
re dw 4 dup(0)
temp dw 0
temp1 dw 0
data ends
stack segment
dw 15 dup(0)
stack ends
code segment
start:
mov ax, data
mov ds, ax
mov ax, stack
mov ss, ax
mov sp, 0010h
lea si, s1
lea di, s2
lea bx, re
mov dx, 0
mov cx, 4
outer:
push cx
mov cx, 4
inner:
mov al, [si]
mul ds:byte ptr[di] ;結果存入ax
add dx, ax
inc si
inc di
loop inner
mov ds:[bx], dx
mov di, 16
mov dx, 0
inc bx
inc bx
pop cx
loop outer
;show
mov cx, 4
lea si, re
show:
mov bx, [si]
call putouthex
inc si
inc si
push dx
push ax
mov dl, 0dh
mov ah, 2
int 21h
mov dl, 0ah
mov ah, 2
int 21h
pop ax
pop dx
loop show
mov ax, 4c00h
int 21h
putouthex proc
push cx
mov temp, bx
mov temp1, bx
mov cl, 8
shr temp, cl
mov bx, temp
call main1
and temp, 00ffh
mov bx, temp1
call main1
pop cx
retmain1 proc
mov al, bl
mov cl, 4
shr al, cl
cmp al, 10
jb kk
add al, 7
kk:mov dl, al
cmp dl, 0
je kk2
add dl, 30h
mov ah, 2
int 21h
and bl, 0fh
kk2:
cmp bl, 10
jb kk1
add bl, 7
kk1:
mov dl, bl
add dl, 30h
mov ah, 2
int 21h
ret
main1 endp
putouthex endp
code ends
end start
考題:
/* 將字串中的小寫字母轉換為大寫字母
* **/assume cs:code, ds:data
data segment
pkey db 'please input strings ','$'
instr db 20 dup(0)
temp dw 0
data ends
code segment
start:
mov ax, data
mov ds, ax
mov dx, offset pkey
mov ah, 9
int 21h
push dx
push ax
mov dl, 0ah ;回車換行
mov ah, 2
int 21h
mov dl, 0dh
mov ah, 2
int 21h
pop ax
pop dx
mov cx, 0
lea si, instr
loop1:
mov ah, 1
int 21h
cmp al, '$'
je over
mov byte ptr[si], al
inc si
inc cx
jmp loop1
over:
push dx
push ax
mov dl, 0ah ;回車換行
mov ah, 2
int 21h
mov dl, 0dh
mov ah, 2
int 21h
pop ax
pop dx
lea si, instr
compl:
mov bl, [si]
cmp bl, 'a'
jb nol
cmp bl, 'z'
ja nol
sub bl, 32
mov dl, bl
mov ah, 2
int 21h
nol:
inc si
loop compl
mov ah, 1
int 21h
mov ah, 4ch
int 21h
code ends
end start
組合語言 實驗三
一 實驗目的 掌握彙編程式設計規範,熟悉程式設計環境。二 實驗內容 1 編寫子程式把字串中的小寫字母轉變為大寫字母 參見教材實驗11 2 編寫0號中斷處理程式,使得在除法溢位發生時在螢幕中間顯示 divide error 參見教材實驗12 請預習第12章並完成實驗,時間不夠則在課後完成 三 實驗步驟...
彙編實驗(二)
test 和 and 區別在於不改變op1 shr 如果要多移幾次 mov cl,4 shr dl,cl 判斷陣列裡正負數 並分開存放 assume cs code,ds data data segment m db 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17...
彙編求和實驗
設在a b和d字單元中分別存放著三個數。若三個數都不是0,則求出三個數的和並存放在s單元中 若其中有乙個數為0,則把其他兩個單元也清零。如有錯誤,請各位大神指導!如下 datas segment a dw 1 b dw 2 d dw 6 count dw a 2 tip db the number ...