; multi-segment executable file template.
data SEGMENT
; add your data here!
rlst DW 1,127 dup(0)
ENDS
stack SEGMENT
DB 128 dup(0)
ENDS
code SEGMENT
start:
; set segment registers:
MOV AX,data
MOV DS,AX
; add your code here
MOV CX,100
loop_main:
MOV DX,0
MOV AX,0
PUSH CX
MOV BX,127
max:
CMP [BX],0
JNE max_out
DEC BX
JMP max
max_out:
MOV CX,BX
INC CX
MOV BX,0
loop2:
MOV AL,[BX]
MOV DI,CX
POP CX
MUL CL
PUSH CX
MOV CX,DI
ADD AX,DX
MOV [BX],AL
MOV DL,AH
INC BX
LOOP loop2
MOV [BX],DL
POP CX
PUSHA
MOV CX,BX
INC CX
disp:
CMP [BX],0
JNE disp_1
DEC BX
DEC CX
JMP disp
disp_1:
MOV DL,[BX]
SHR DL,4
CMP DL,10
JNC asc1
JMP asc2
asc1:
ADD DL,7
asc2:
ADD DL,48
MOV AH,2
INT 21h
MOV DL,[BX]
SHL DL,4
SHR DL,4
CMP DL,10
JNC asc3
JMP asc4
asc3:
ADD DL,7
asc4:
ADD DL,48
INT 21h
DEC BX
LOOP disp_1
MOV DL,10
INT 21h
MOV DL,13
INT 21h
POPA
LOOP loop_main
; wait for any key....
MOV AH, 1
INT 21h
MOV AX, 4c00h ; exit to operating system.
INT 21h
ENDS
END start ; set entry point and stop the assembler.
最后一组数据就是100!,十六进制表示,即
1B30964EC395DC24069528D54BBDA40D16E966EF9A70EB21B5B2943A321CDF10391745570CCA9420C6ECB3B72ED2EE8B02EA2735C61A000000000000000000000000
3L的比1L 2L强一些,至少还知道考虑溢出的问题……但是100!其实是10^15这个数量级的东西……
100!= 9.332 * 10 ^157
结果有150多位10进制数,相当于2进制数字,是多少位?
处理这么大的数据量,可不是个小程序。
调试已通过,100个数据太长了吧,我这就给出30个成绩记录
data segment
credit dw 76,69,84,90,73,88,99,63,100,80,45,64,24,36,51,20,19,86,89,90,76,69,84,90,73,88,99,63,100,80
mes1 db '<60:$'
mes2 db '60-85:$'
mes3 db '>85:$'
v1 dw 0
v2 dw 0
v3 dw 0
data ends
code segment
assume cs:code,ds:data
main proc far
start:
mov ax,data
mov ds,ax
call count ;统计各分段人数的子程序
mov ah,4ch
int 21h
ret
main endp
;------------------------------
count proc near
lea si,credit
mov cx,30
m1:mov bx,[si]
add si,2
cmp bx,60
jg m2
inc v1
jmp m4
m2:cmp bx,85
jg m3
inc v2
jmp m4
m3:inc v3
m4:loop m1
mov dx,offset mes1
mov ah,09h
int 21h
mov bx,v1
call bini
call crlf
mov dx,offset mes2
mov ah,09h
int 21h
mov bx,v2
call bini
call crlf
mov dx,offset mes3
mov ah,09h
int 21h
mov bx,v3
call bini
ret
count endp
;-----------------------------
bini proc near
mov cx,10d
call bin
mov cx,1d
call bin
ret
bini endp
bin proc near
mov ax,bx
mov dx,0
div cx
mov bx,dx
mov dl,al
add dl,30h
mov ah,02h
int 21h
ret
bin endp
;-------------------------------
crlf proc near ;回车换行子程序
mov dl,0ah
mov ah,02h
int 21h
mov dl,0dh
mov ah,02h
int 21h
ret
crlf endp
;-------------------------------
code ends
end start
ORG 1000H
MOV R1#100
MOV A,R1
CLR C
MUL AB
LOOP: DEC R1
MUL AB
DJNZ R1,LOOP
MOVX DPTR,AB
1楼的有问题
100!>255 8位不够的;所以要16位!
ORG 1000HJ
MOV R1#100
MOV A,R1
MUL AB
LOOP: DEC R1
MUL AB
DJNZ R1,LOOP