这个都是过去DOS时代的汇编源码,虽然已经过去了,但是对于学习汇编还是有帮助的,汇编语言只是程序员一门基础语言,大多人掌握即可,不一定要深入研究.......
;************************************************************************
;*
;* SHOWMEM (C) 1997 RonSoft. *
;* *
;* A little utility thats shows what's in a given mem position. *
;* Usage: *
;* Showmem <segment,offset/startaddress> *
;* Where segment and offset are 16 bit hexadecimal values or *
;* a single 32 bit value. *
;* Just like this: *
;* Showmem 00000000 or Showmem 0. *
;* *
;* Ronald Nordberg. *
;* Silverv刧en 3 *
;* 907 50 Ume? *
;* Sweden *
;* christine.martinson@swipnet.se *
;* http://home2.swipnet.se/~w-20064 *
;* *
;* THIS IS ALL PUBLIC DOMAIN FREEWARE. *
;* LET EM KNOW IF YOU USE MY CODE. *
;* *
;************************************************************************
;some euqates for readability
kbd equ 16h ;keyboard irq
msdos equ 21h ;MSDOS irq
reset equ 0dh ;disk reset
dfopen equ 0fh ;open disk file
dfclose equ 10h ;close disk file
searchf equ 11h ;search first
searchn equ 12h ;search next
seqread equ 14h ;sequential disk read
seqwrite equ 15h ; " " write
setdta equ 1ah ;set disk transfer area address
createf equ 3ch ;create file with handle
openf equ 3dh ;open file with handle
closef equ 3eh ;close file with handle
readf equ 3fh ;read from file with handle
writef equ 40h ;write to file with handle
setfp equ 42h ;set file pointer
allocmem equ 48h ;allocate memory
freemem equ 49h ;free memory
changebs equ 4ah ;change block size
findfirst equ 4eh ;find first file
exit equ 4c00h ;msdos exit
[BITS 16] ;NASM stuff
[ORG 0x100]
s1:
mov ax,cs ;get code segment
mov ds,ax ;use it now
mov [comseg],ds ;save it there
mov si,0080h ;DOS command line page 0
lodsb ;load size of command line
cmp al,0 ;anything on command line ?
jbe usage ;noo, show usage
cbw ;extend AL to AX
xchg bx,ax ;swap size to bx for indexing
mov byte [bx+si],0 ;null terminate command line
call parse ;parse command line
jmp main ;go on with main
usage: mov bx,utext ;pointer usage text
jmp errout ;skip this
main:
mov si,inbuff ;check for valid HEX input
mov bx,errt1 ;proper text
ishex: lodsb ;get the char
cmp al,'0'
jb errout
and al,0dfh ;force UPPERCASE
cmp al,'F' ;>F ?
ja errout ;yeahh, dump this
loop ishex
call hexbin ;make hex bin
;start address now in EDX
mov ax,dx ;get low word (segment)
mov es,ax ;start segment
shr edx,16 ;shift in offset
mov di,dx ;start offset
dopage:
push es ;save registers
push di
push ds
push si
mov ax,es
mov ds,ax ;make ds=es
mov si,di ;and si=di
call showpage ;show it
pop si ;restore registers
pop ds
pop di
pop es
add di,512 ;adjust memory position
;xor ah,ah ;wait for ANY key
;int kbd
mov bx,text ;show message
call write
mov ah,0 ;wanna see next screen ?
int kbd ;chek out keyboard buffer
and al,0DFh ;force UPPER CASE
cmp al,"Q" ;wanna quit ?
je quit ;yeahh
jmp dopage
errout:
call write
quit:
mov ax,exit
int msdos
;***********************************************************
;* Convert ascii hex to 32 bit binary
;* Input = command line buffer, output EDX
;***********************************************************
hexbin:
mov si,inbuff ;pointer command line buffer
xor edx,edx ;clear binary output
aschexbin:
lodsb
cmp al,'0' ;< 0
jb notasc ;yes invalid character
cmp al,'9' ;<= 9
jbe astrip ;yes, strip high 4 bits
and al,05fh ;force upper case
cmp al,'A' ;< ascii A
jb notasc ;yes, invalid character
cmp al,'F' ;> ascii F
ja notasc ;yes, invalid character
add al,9 ;ok, add 9 for strip
astrip:
and al,0fh ;strip high 4 bits
mov cx,4 ;set shift count
shl edx,cl ;rotate EDX 4 bits
xor ah,ah ;zero out AH
cbw
add edx,eax ;add digit to value
jmp aschexbin ;continue
notasc: ret
;*********************************************************************
;* Format and show the stuff in a "sector"
;* Input SI
;**************