@@ -6426,19 +6426,77 @@ loadpgm endp
64266426
64276427endif
64286428
6429- ;--- M command - move/copy memory.
6429+ ;--- 'm'achine command: set machine type.
6430+
6431+ mach proc
6432+ ; dec si
6433+ ; call skipwhite
6434+ ; cmp al,CR
6435+ ; je mach_query ;if just an 'm' (query machine type)
6436+ mov al ,[ si - 1 ]
6437+ call getbyte
6438+ mov al , dl
6439+ cmp al , 6
6440+ ja errorj3 ;dl must be 0-6
6441+ mov [ machine ], al ;set machine type
6442+ mov [ mach_87 ], al ;coprocessor type, too
6443+ cmp al , 3
6444+ jnc @F
6445+ and [ rmode ], not RM_386REGS ;reset 386 register display
6446+ @@:
6447+ ret
6448+ mach endp
6449+
6450+ errorj3:
6451+ jmp cmd_error
6452+
6453+ ;--- 'mc' command: set coprocessor.
6454+ ;--- optional arguments:
6455+ ;--- N: no coprocessor
6456+ ;--- 2: 80287 with 80386
6457+
6458+ mc_cmd proc
6459+ call skipwhite ;get next nonblank character
6460+ mov ah ,[ machine ]
6461+ cmp al , CR
6462+ jz set_mpc
6463+ or al , TOLOWER
6464+ push ax
6465+ lodsb
6466+ call chkeol
6467+ pop ax
6468+ cmp al , 'n'
6469+ jne @F ;if something else
6470+ mov [ has_87 ], 0 ;clear coprocessor flag
6471+ ret ;done
6472+ @@:
6473+ cmp al , '2'
6474+ jne errorj3 ;if not '2'
6475+ cmp [ machine ], 3
6476+ jnz errorj3 ;if not a 386
6477+ mov ah , 2
6478+ set_mpc:
6479+ mov [ has_87 ], 1 ;set coprocessor flag
6480+ mov [ mach_87 ], ah
6481+ ret
6482+ mc_cmd endp
64306483
6431- ;--- first check if there is more than 1 argument
6432- ;--- 0 or 1 arguments are handled by the 'M [cpu]' code
6433- ;--- also check if command is MC, MC2 or MNC
6484+ ;--- M command - move/copy memory.
6485+ ;--- 1. check if there's no argument at all: mach_query, display cpu
6486+ ;--- 2. check for MC cmd: mc_cmd, set/reset coprocessor
6487+ ;--- 3. check if there's just 1 argument: mach, set cpu
64346488
64356489m_cmd proc
64366490 cmp al , CR
6437- jz mach
6491+ jz mach_query
64386492 mov ah ,[ si - 2 ]
6439- or ah , TOLOWER
6440- cmp ah , 'm'
6441- jz mach
6493+ or ax , TOLOWER or (TOLOWER shl 8 )
6494+ cmp ax , 'mc' ; mc cmd?
6495+ jz mc_cmd
6496+ if ?PM
6497+ cmp al , '0' ; is there a '$' or '%' modifier?
6498+ jb ismove ; ( would throw an error in getdword )
6499+ endif
64426500 push si
64436501 call getdword
64446502 cmp al , CR
@@ -6448,23 +6506,27 @@ m_cmd proc
64486506 pop si
64496507 cmp al , CR
64506508 je mach ; jump if 1 argument only
6509+ ismove:
64516510 dec si
64526511 lodsb
6453- call parsecm ;parse arguments ( DS:(E)SI, ES:(E)DI, (E)CX)
6512+ call parsecm ;parse arguments: src= DS:(E)SI, dst= ES:(E)DI, length-1= (E)CX
64546513;--- note: DS unknown here
6514+
64556515 push cx
64566516if ?PM
64576517 if ?DPMI
64586518 call ispm_dbg
64596519 jz @F
64606520 endif
64616521;--- TODO: do overlapping check in protected-mode
6522+
6523+ @dprintf "m_cmd: ds:esi=%X:%lX, es:edi=%X:%lX, ecx=%lX" , ds , esi , es , edi , ecx
64626524 clc
64636525 jmp m3
64646526@@:
64656527endif
64666528 mov cl , 4
6467- shr dx , cl
6529+ shr dx , cl ; BX:DX=dst seg:ofs
64686530 add dx , bx ;upper 16 bits of destination
64696531 mov ax , si
64706532 shr ax , cl
@@ -6495,7 +6557,11 @@ if ?PM
64956557 push ds
64966558 push ss
64976559 pop ds
6498- call IsWriteableBX ; needs DS=dgroup
6560+ if ?DPMI
6561+ push ss
6562+ pop es
6563+ endif
6564+ call IsWriteableBX ; expects DS(,ES)=dgroup
64996565 cmp [ bAddr32 ], 0
65006566 pop ds
65016567 mov es , bx
@@ -6526,31 +6592,9 @@ endif
65266592 jmp ee0a ;restore ds and es and undo the int2324 pointer hack
65276593m_cmd endp
65286594
6529- ;--- 'm'achine command: set machine type.
6530-
6531- mach proc
6532- or al , TOLOWER
6533- cmp al , 'c'
6534- jz mc
6535- dec si
6536- call skipwhite
6537- cmp al , CR
6538- je ma1 ;if just an 'm' (query machine type)
6539- call getbyte
6540- mov al , dl
6541- cmp al , 6
6542- ja errorj3 ;dl must be 0-6
6543- mov [ machine ], al ;set machine type
6544- mov [ mach_87 ], al ;coprocessor type, too
6545- cmp al , 3
6546- jnc @F
6547- and [ rmode ], not RM_386REGS ;reset 386 register display
6548- @@:
6549- ret
6550-
6551- ;--- Display machine type.
6595+ ;--- M without argument - display machine type.
65526596
6553- ma1:
6597+ mach_query proc
65546598 mov si , offset msg8088
65556599 mov al ,[ machine ]
65566600 cmp al , 0
@@ -6571,41 +6615,7 @@ ma1:
65716615@@:
65726616 call copystring ;si->di
65736617 jmp putsline ;call puts and quit
6574- mach endp
6575-
6576- errorj3:
6577- jmp cmd_error
6578-
6579- ;--- 'mc' command: set coprocessor.
6580- ;--- optional arguments:
6581- ;--- N: no coprocessor
6582- ;--- 2: 80287 with 80386
6583-
6584- mc proc
6585- call skipwhite ;get next nonblank character
6586- mov ah ,[ machine ]
6587- cmp al , CR
6588- jz set_mpc
6589- or al , TOLOWER
6590- push ax
6591- lodsb
6592- call chkeol
6593- pop ax
6594- cmp al , 'n'
6595- jne @F ;if something else
6596- mov [ has_87 ], 0 ;clear coprocessor flag
6597- ret ;done
6598- @@:
6599- cmp al , '2'
6600- jne errorj3 ;if not '2'
6601- cmp [ machine ], 3
6602- jnz errorj3 ;if not a 386
6603- mov ah , 2
6604- set_mpc:
6605- mov [ has_87 ], 1 ;set coprocessor flag
6606- mov [ mach_87 ], ah
6607- ret
6608- mc endp
6618+ mach_query endp
66096619
66106620if LCMDFILE or WCMDFILE
66116621
@@ -6843,8 +6853,8 @@ if ?PM
68436853
68446854;--- ensure segment in BX is writeable.
68456855;--- if it isn't, BX may be set to an alias (scratchsel)
6856+ ;--- expects DS,SS=dgroup ( for ?DPMI, also ES=dgroup )
68466857;--- out: Carry=1 if segment not writeable
6847- ;--- clears HiWord(EDI) in DPMI protected-mode
68486858;--- called by:
68496859;--- setcseipbyte(); write at regs.cs:e/ip + cx
68506860;--- writemem(): write byte at bx:e/dx
@@ -6857,10 +6867,11 @@ IsWriteableBX proc
68576867 jz is_rm
68586868 . 286
68596869 push ax
6870+ sizeprf ; push edi
68606871 push di
68616872 sub sp , 8
68626873 mov di , sp
6863- sizeprf ;lea edi,[di] (synonym for movzx edi,di), 3 bytes long
6874+ sizeprf ; lea edi,[di] (synonym for movzx edi,di), 3 bytes long
68646875 lea di ,[ di ]
68656876 mov ax , 000Bh ;get descriptor
68666877 int 31h
@@ -6874,6 +6885,7 @@ IsWriteableBX proc
68746885 int 31h
68756886@@:
68766887 lea sp , [ di + 8 ]
6888+ sizeprf ; pop edi
68776889 pop di
68786890 pop ax
68796891 . 8086
@@ -10194,6 +10206,7 @@ endif
1019410206; Exit DS:(E)SI Address from first parameter
1019510207; ES:(E)DI Address from second parameter
1019610208; (E)CX Length of address range minus one
10209+ ; m cmd in real-mode expects dst segm:ofs in BX:DX
1019710210
1019810211parsecm proc
1019910212 call prephack
@@ -10603,32 +10616,31 @@ getaddr proc
1060310616if ?PM
1060410617 mov [ bAddr32 ], 0
1060510618 if ?DPMI
10606- cmp byte ptr [ si - 1 ], '$' ; a real-mode segment?
10619+ cmp al , '$' ; a real-mode segment?
1060710620 jnz @F
1060810621 lodsb
1060910622 call ispm_dbg
1061010623 jz @F
1061110624 call getword
10625+ cmp al , ':'
10626+ jnz errorj2
1061210627 mov bx , dx
10613- push ax
1061410628 mov ax , 2
1061510629 int 31h
10616- jc errorj2
1061710630 mov bx , ax
1061810631 mov dx , ax
10619- pop ax
10620- jmp ga1_2
10632+ jc errorj2
10633+ jmp ga3
1062110634@@:
1062210635 elseif RING0
10623- cmp byte ptr [ si - 1 ], '%' ; a linear address?
10636+ cmp al , '%' ; a linear address?
1062410637 jnz @F
1062510638 mov bx , cs : [ wFl at ]
1062610639 jmp ga3
1062710640@@:
1062810641 endif
1062910642endif
1063010643 call getofsforbx
10631- ga1_2:
1063210644 push si
1063310645 call skipwh0
1063410646 cmp al , ':'
@@ -10769,20 +10781,20 @@ getdword proc
1076910781 cbw
1077010782 xchg ax , dx
1077110783 xor bx , bx ;clear high order word
10772- gd1 :
10784+ nextchar :
1077310785 lodsb
1077410786 call getnyb
10775- jc gd3
10787+ jc done
1077610788 test bh , 0f0h
1077710789 jnz errorj6 ;if too big
1077810790 mov cx , 4
10779- gd2 :
10791+ @@ :
1078010792 shl dx , 1 ;double shift left
1078110793 rcl bx , 1
10782- loop gd2
10794+ loop @B
1078310795 or dl , al
10784- jmp gd1
10785- gd3 :
10796+ jmp nextchar
10797+ done :
1078610798 ret
1078710799getdword endp
1078810800
0 commit comments