wok-next diff linld/stuff/src/MEMTOP.ASM @ rev 20462
Combine receipts
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Tue Mar 06 03:00:01 2018 +0200 (2018-03-06) |
parents | 9107c8697bd1 |
children |
line diff
1.1 --- a/linld/stuff/src/MEMTOP.ASM Fri Mar 17 15:18:10 2017 +0100 1.2 +++ b/linld/stuff/src/MEMTOP.ASM Tue Mar 06 03:00:01 2018 +0200 1.3 @@ -42,23 +42,21 @@ 1.4 ;*************************************************************** 1.5 ; proc _memtop_e801 near 1.6 1.7 - ;push cx bx 1.8 xor cx,cx ;fix to work around buggy 1.9 xor dx,dx ; BIOSes which dont clear/set 1.10 stc ; carry on pass/error of 1.11 mov ax,0E801h 1.12 int 15h 1.13 jc @@err 1.14 - test cx,cx ;kludge to handle BIOSes 1.15 - jnz @@use_cxdx ; which report their extended 1.16 - test dx,dx ; memory in AX/BX rather than 1.17 + xchg ax,cx 1.18 + push ax ;kludge to handle BIOSes 1.19 + or ax,dx ; which report their extended 1.20 + pop ax ; memory in AX/BX rather than 1.21 jnz @@use_cxdx ; CX/DX. The spec I have read 1.22 @@use_axbx: mov dx,bx ; seems to indicate AX/BX 1.23 - jmp @@end_kludge ; are more reasonable anyway... 1.24 -@@use_cxdx: xchg ax,cx 1.25 -@@end_kludge: ;now: dx=64k units above 16m 1.26 + xchg ax,cx ; are more reasonable anyway... 1.27 +@@use_cxdx: ;now: dx=64k units above 16m 1.28 ; ax=1k units above 1m below 16m (max 3c00h) 1.29 - ;pop bx cx 1.30 test dx,dx 1.31 jz tokb ;dx=0 here, ax=kbs above 1m 1.32 xor ax,ax ;ignore info on low 16M (assume full) 1.33 @@ -84,28 +82,56 @@ 1.34 @@ok: 1.35 ; xor dx,dx 1.36 test ax,ax ;happens on big mem systems 1.37 - jz @@fail 1.38 + jnz tokb 1.39 + 1.40 +;*************************************************************** 1.41 +;u32 memtop_cmos() 1.42 +;*************************************************************** 1.43 + 1.44 +;memtop_cmos: 1.45 + pushf 1.46 + cli 1.47 + call rdcmos17 1.48 + popf 1.49 tokb: 1.50 xor dx,dx 1.51 add ah,4h ;account for 1024 low kb 1.52 adc dx,dx ; (optimized to death) 1.53 + mov cl,10 ;multiply by 1024 1.54 + global N_LXLSH@:near 1.55 +N_LXLSH@: 1.56 ifndef NO386 1.57 - shld dx,ax,10 ;multiply by 1024 1.58 - shl ax,10 ; (kbytes -> bytes) 1.59 + shld dx,ax,cl 1.60 + shl ax,cl ; (kbytes -> bytes) 1.61 else 1.62 + mov ch,0 1.63 @@lp: 1.64 - mov cx,10 1.65 - shl ax,1 ;multiply by 1024 1.66 + shl ax,1 1.67 rcl dx,1 1.68 loop @@lp 1.69 endif 1.70 -; mov cx,ax 1.71 -; or cx,dx ;update ZF 1.72 -;@@fail: 1.73 - ret 1.74 + ret 1.75 + 1.76 ; endp _memtop_88 1.77 1.78 -@@fail: 1.79 + ifdef NO386 1.80 + global N_LXURSH@:near 1.81 + global N_LXURSH@4:near 1.82 +; proc N_LXURSH@4 near 1.83 +N_LXURSH@4: 1.84 + mov cl,4 1.85 +N_LXURSH@: 1.86 + mov ch,0 1.87 +@@loop: 1.88 + shr dx,1 1.89 + rcr ax,1 1.90 + loop @@loop 1.91 + ret 1.92 + 1.93 +; endp N_LXURSH@4 1.94 + 1.95 + endif 1.96 + 1.97 1.98 ; proc _memtopz near 1.99 1.100 @@ -113,16 +139,7 @@ 1.101 ; jnz @@ok 1.102 ; call _memtop_88 1.103 ; jnz @@ok 1.104 - 1.105 -;*************************************************************** 1.106 -;u32 memtop_cmos() 1.107 -;*************************************************************** 1.108 - 1.109 - pushf 1.110 - cli 1.111 - call rdcmos17 1.112 - popf 1.113 - jmp tokb 1.114 +; jmp memtop_cmos 1.115 1.116 rdcmos17: mov al,18h ; read bytes 17-18 from CMOS 1.117 call @@rdcmos 1.118 @@ -173,38 +190,36 @@ 1.119 1.120 ifndef xmm_hook 1.121 mov ax,4300h 1.122 - ifdef NO386 1.123 - cwd 1.124 - endif 1.125 int 2fh 1.126 cmp al,80h ; 80h = XMS driver installed 1.127 je @@skip 1.128 endif 1.129 + xor bx,bx 1.130 + mov es,bx 1.131 ifndef NO386 1.132 - push 0 1.133 - pop es 1.134 - mov bx,15*4 1.135 - mov eax,[bx] 1.136 + push cs 1.137 + push offset int15_88 1.138 + pop eax 1.139 + xchg eax,[es:bx+15*4] 1.140 mov [saved15],eax 1.141 else 1.142 - mov es,dx 1.143 - mov bx,15*4 1.144 - mov ax,[bx] 1.145 + mov ax,offset int15_88 1.146 + xchg ax,[es:bx+15*4] 1.147 mov [word saved15],ax 1.148 - mov ax,[bx+2] 1.149 + mov ax,cs 1.150 + xchg ax,[es:bx+15*4+2] 1.151 mov [word saved15+2],ax 1.152 endif 1.153 - mov [word bx],offset int15_88 1.154 - mov [bx+2],cs 1.155 @@skip: 1.156 ret 1.157 int15_88: 1.158 cmp ah,88h 1.159 je @@do88 1.160 +@@jmp_saved15: 1.161 jmp [saved15] 1.162 @@do88: 1.163 pushf 1.164 - call [saved15] 1.165 + call @@jmp_saved15 1.166 test ax,ax 1.167 jnz @@iret 1.168