- [游客] 如果不加ds:就是相当于一下的语句 mov al,16 mov al,17 mov al,18 10/31 00:12
- [chinatree] 编译器不错,支持@@了。当然程序也不错。 10/15 01:48
- [hitlerdsaf] 中间跳转的时候二级跳了,提示jump out of range ,我晕倒。二级跳显得非常不好看。唉 10/12 18:40
- [chinatree] 作业类型有编辑文章的功能,你可以修改下。 09/30 20:15
- [hitlerdsaf] 6、1 1 2 2 4 7、512 256 第6、7题答案更正 09/30 17:28
- [hitlerdsaf] MOV AL 02H ADD AL, AL ADD AL, AL ADD AL, AL 09/29 15:26
- [chinatree] 全对。 09/29 15:23
[2011-10-12 16:28] 课程设计1
assume cs:codesg
data segment
db '1975', '1976', '1977', '1978', '1979', '1980', '1981', '1982', '1983'
db '1984', '1985', '1986', '1987', '1988', '1989', '1990', '1991', '1992'
db '1993', '1993', '1995'
dd 16, 22, 382, 1356, 2390, 8000, 16000, 24486, 50065, 97479, 140417, 197514
dd 345980, 590827, 803530, 1183000, 1843000, 2759000, 3753000, 4649000, 5937000
dw 3, 7, 9, 13, 28, 38, 130, 220, 476, 778, 1001, 1442, 2268, 2793, 4037, 5635, 8226
dw 11542, 14430, 15257, 17800
;start at ds:[210]
db 10 dup (0)
data ends
stack segment
dw 32 dup (0)
stack ends
codesg segment
start: mov ax, data
mov ds, ax
mov ax, stack
mov ss, ax
mov sp, 64
mov ax, 0B800h
mov es, ax
mov cx, 21
mov bx, 0
mov bp, 210
mov di, 3
mov si, 210
s: push cx
mov ax, ds:[bx]
mov ds:[bp], ax
mov ax, [bx+2]
mov ds:[bp+2], ax
mov al, 0
mov ds:[bp+4], al
mov dx, di
mov dh, dl
mov dl, 0
mov si, 210
mov cx, 00000101B
call show_str
sar bx, 1
mov ax, ds:[bx+168]
mov dx, 0
sal bx, 1
add si, 10
call dtoc
mov dx, di
mov dh, dl
mov dl, 7
mov cx, 00000101B
call show_str
mov ax, ds:[bx+84]
mov dx, ds:[bx+86]
mov si, 220
call dtoc
mov dx, di
mov dh, dl
mov dl, 20
mov cx, 00000101B
call show_str
jmp xx
xxx: loop s
jmp xxxx
xx:
mov ax, ds:[bx+84]
mov dx, ds:[bx+86]
sar bx,1
mov cx, ds:[bx+168]
sal bx,1
call divdw
mov si, 220
call dtoc
mov dx, di
mov dh, dl
mov dl, 30
mov cx, 00000101B
call show_str
add bx, 4
inc di
pop cx
jmp xxx
xxxx: mov ax, 4c00h
int 21h
;;function : change word data into decimal string, ended with '0'
;;input : ax -- lower 16 bit of word data dx---higher 16 bit of word data ds:si--尾地址
;;return: none
dtoc: ;push dx
push bx
;push si
push cx
next: mov cx, 10
call divdw
add cx, 030H
dec si
mov ds:[si], cl
mov cx, ax
jcxz ok2
jmp next
ok2: mov cx, dx
jcxz ok1
jmp next
ok1:
pop cx
;pop si
pop bx
;pop dx
ret
;;function : cannot overflow div
;; dx -- higher 16bit of dividend ax- lower 16bit of dividend cx -- divisor
;;return dx -- higher 16 bit of result ax -- lower 16bit of result cx --remainder
divdw:
push bx
push bp
sub sp, 8
mov bp, sp
mov ss:[bp], ax
;mov ds:[28], dx
;mov ds:[30], cx
;; H/N
mov ax, dx
mov dx, 0
div cx
;mov ds:[32], ax ;int(H/N)
mov ss:[bp+4], dx ;rem(H/N)
;storage (int)H/N * 65536
mov bx, 0
mov ss:[bp+6], bx
mov ss:[bp+2], ax
;calc (rem)H/N *65536
mov dx, ss:[bp+4]
mov ax, 0
;(rem)H/N * 65536 + L
add ax, ss:[bp]
;((rem)H/N * 65536 + L)/N
div cx
mov cx, dx ;存余数
;两项相加
mov dx, ss:[bp+2]
add ax, ss:[bp+6] ; +0 可以不做
add sp, 8
pop bp
pop bx
ret
;;function : show a string with 0 ended at certain position and color
;;dh--line no. dl--column no.
;;cl--color ds:si--the beginning of the string
;;return none
show_str:
push bx
push di
push ax
push si
push cx
;;calculate the first address of the string in video memory
mov al, dh
mov bl, 160
mul bl
mov bx, ax
mov ah, 0
mov al, dl
add bx, ax
add bx, ax
change:
mov cl, ds:[si]
mov ch, 0
jcxz ok
mov es:[bx], cl
pop cx
mov es:[bx+1], cl
push cx
inc si
inc bx
inc bx
jmp short change
ok: pop cx
pop si
pop ax
pop di
pop bx
ret
codesg ends
end start
data segment
db '1975', '1976', '1977', '1978', '1979', '1980', '1981', '1982', '1983'
db '1984', '1985', '1986', '1987', '1988', '1989', '1990', '1991', '1992'
db '1993', '1993', '1995'
dd 16, 22, 382, 1356, 2390, 8000, 16000, 24486, 50065, 97479, 140417, 197514
dd 345980, 590827, 803530, 1183000, 1843000, 2759000, 3753000, 4649000, 5937000
dw 3, 7, 9, 13, 28, 38, 130, 220, 476, 778, 1001, 1442, 2268, 2793, 4037, 5635, 8226
dw 11542, 14430, 15257, 17800
;start at ds:[210]
db 10 dup (0)
data ends
stack segment
dw 32 dup (0)
stack ends
codesg segment
start: mov ax, data
mov ds, ax
mov ax, stack
mov ss, ax
mov sp, 64
mov ax, 0B800h
mov es, ax
mov cx, 21
mov bx, 0
mov bp, 210
mov di, 3
mov si, 210
s: push cx
mov ax, ds:[bx]
mov ds:[bp], ax
mov ax, [bx+2]
mov ds:[bp+2], ax
mov al, 0
mov ds:[bp+4], al
mov dx, di
mov dh, dl
mov dl, 0
mov si, 210
mov cx, 00000101B
call show_str
sar bx, 1
mov ax, ds:[bx+168]
mov dx, 0
sal bx, 1
add si, 10
call dtoc
mov dx, di
mov dh, dl
mov dl, 7
mov cx, 00000101B
call show_str
mov ax, ds:[bx+84]
mov dx, ds:[bx+86]
mov si, 220
call dtoc
mov dx, di
mov dh, dl
mov dl, 20
mov cx, 00000101B
call show_str
jmp xx
xxx: loop s
jmp xxxx
xx:
mov ax, ds:[bx+84]
mov dx, ds:[bx+86]
sar bx,1
mov cx, ds:[bx+168]
sal bx,1
call divdw
mov si, 220
call dtoc
mov dx, di
mov dh, dl
mov dl, 30
mov cx, 00000101B
call show_str
add bx, 4
inc di
pop cx
jmp xxx
xxxx: mov ax, 4c00h
int 21h
;;function : change word data into decimal string, ended with '0'
;;input : ax -- lower 16 bit of word data dx---higher 16 bit of word data ds:si--尾地址
;;return: none
dtoc: ;push dx
push bx
;push si
push cx
next: mov cx, 10
call divdw
add cx, 030H
dec si
mov ds:[si], cl
mov cx, ax
jcxz ok2
jmp next
ok2: mov cx, dx
jcxz ok1
jmp next
ok1:
pop cx
;pop si
pop bx
;pop dx
ret
;;function : cannot overflow div
;; dx -- higher 16bit of dividend ax- lower 16bit of dividend cx -- divisor
;;return dx -- higher 16 bit of result ax -- lower 16bit of result cx --remainder
divdw:
push bx
push bp
sub sp, 8
mov bp, sp
mov ss:[bp], ax
;mov ds:[28], dx
;mov ds:[30], cx
;; H/N
mov ax, dx
mov dx, 0
div cx
;mov ds:[32], ax ;int(H/N)
mov ss:[bp+4], dx ;rem(H/N)
;storage (int)H/N * 65536
mov bx, 0
mov ss:[bp+6], bx
mov ss:[bp+2], ax
;calc (rem)H/N *65536
mov dx, ss:[bp+4]
mov ax, 0
;(rem)H/N * 65536 + L
add ax, ss:[bp]
;((rem)H/N * 65536 + L)/N
div cx
mov cx, dx ;存余数
;两项相加
mov dx, ss:[bp+2]
add ax, ss:[bp+6] ; +0 可以不做
add sp, 8
pop bp
pop bx
ret
;;function : show a string with 0 ended at certain position and color
;;dh--line no. dl--column no.
;;cl--color ds:si--the beginning of the string
;;return none
show_str:
push bx
push di
push ax
push si
push cx
;;calculate the first address of the string in video memory
mov al, dh
mov bl, 160
mul bl
mov bx, ax
mov ah, 0
mov al, dl
add bx, ax
add bx, ax
change:
mov cl, ds:[si]
mov ch, 0
jcxz ok
mov es:[bx], cl
pop cx
mov es:[bx+1], cl
push cx
inc si
inc bx
inc bx
jmp short change
ok: pop cx
pop si
pop ax
pop di
pop bx
ret
codesg ends
end start
评论次数(1) |
浏览次数(408) |
类型(汇编作业) |
收藏此文 |