Skip to content

Commit

Permalink
[Reduction] #125: hmem_lallocate
Browse files Browse the repository at this point in the history
  • Loading branch information
nmlgc committed Aug 21, 2014
1 parent 47781cd commit c3202f4
Show file tree
Hide file tree
Showing 11 changed files with 88 additions and 377 deletions.
58 changes: 58 additions & 0 deletions libs/master.lib/hmem_lallocate.asm
@@ -0,0 +1,58 @@
; master library
;
; Description:
; ヒープメモリ取得 long版
;
; Functions:
; unsigned hmem_lallocate( unsigned long bytesize ) ;
;
; Returns:
; unsigned (cy=0) 確保したセグメント
; 0(cy=1) 管理メモリ不足
;
; Notes:
; AX以外の全てのレジスタを保存します。
; hmem_lallocate(0)として呼び出すと、メモリ不足を返します。
;
; Running Target:
; MS-DOS
;
; Author:
; 恋塚昭彦
;
; Rebision History:
; 93/ 3/31 Initial
;

func HMEM_LALLOCATE ; hmem_lallocate() {
push BX
mov BX,SP
;
byteh = (RETSIZE+2)*2
bytel = (RETSIZE+1)*2
mov AX,SS:[BX+byteh]
mov BX,SS:[BX+bytel]
add BX,15
adc AX,0

shr AX,1
rcr BX,1
shr AX,1
rcr BX,1
shr AX,1
rcr BX,1
shr AX,1
jnz short @@NOMEM
rcr BX,1

push BX
call HMEM_ALLOC
pop BX
ret 4

@@NOMEM:
mov AX,0
stc
pop BX
ret 4
endfunc ; }
41 changes: 3 additions & 38 deletions th02_main.asm
Expand Up @@ -3448,8 +3448,7 @@ loc_17C7:
pop ds
mov mem_AllocID, 0Ah
nop
push cs
call near ptr sub_28DC
call hmem_lallocate
pop ds
stosw
jb short loc_1818
Expand Down Expand Up @@ -3496,8 +3495,7 @@ loc_1818:
pop ds
mov mem_AllocID, 0Ah
nop
push cs
call near ptr sub_28DC
call hmem_lallocate
pop ds
mov bx, ax
mov ax, 0FFF8h
Expand Down Expand Up @@ -5499,40 +5497,7 @@ loc_28C0:
retf 2
sub_289C endp


; =============== S U B R O U T I N E =======================================


sub_28DC proc far
; sub_1718+140p
push bx
mov bx, sp
mov ax, ss:[bx+8]
mov bx, ss:[bx+6]
add bx, 0Fh
adc ax, 0
shr ax, 1
rcr bx, 1
shr ax, 1
rcr bx, 1
shr ax, 1
rcr bx, 1
shr ax, 1
jnz short loc_2908
rcr bx, 1
push bx
call hmem_alloc
pop bx
retf 4
; ---------------------------------------------------------------------------

loc_2908:
mov ax, 0
stc
pop bx
retf 4
sub_28DC endp

include libs/master.lib/hmem_lallocate.asm
include libs/master.lib/mem_assign_dos.asm
include libs/master.lib/mem_assign.asm
include libs/master.lib/memheap.asm
Expand Down
41 changes: 3 additions & 38 deletions th02_maine.asm
Expand Up @@ -3113,8 +3113,7 @@ loc_1567:
pop ds
mov mem_AllocID, 0Ah
nop
push cs
call near ptr sub_24DA
call hmem_lallocate
pop ds
stosw
jb short loc_15B8
Expand Down Expand Up @@ -3161,8 +3160,7 @@ loc_15B8:
pop ds
mov mem_AllocID, 0Ah
nop
push cs
call near ptr sub_24DA
call hmem_lallocate
pop ds
mov bx, ax
mov ax, 0FFF8h
Expand Down Expand Up @@ -4867,40 +4865,7 @@ loc_24BE:
retf 2
sub_249A endp


; =============== S U B R O U T I N E =======================================


sub_24DA proc far
; sub_14B8+140p
push bx
mov bx, sp
mov ax, ss:[bx+8]
mov bx, ss:[bx+6]
add bx, 0Fh
adc ax, 0
shr ax, 1
rcr bx, 1
shr ax, 1
rcr bx, 1
shr ax, 1
rcr bx, 1
shr ax, 1
jnz short loc_2506
rcr bx, 1
push bx
call hmem_alloc
pop bx
retf 4
; ---------------------------------------------------------------------------

loc_2506:
mov ax, 0
stc
pop bx
retf 4
sub_24DA endp

include libs/master.lib/hmem_lallocate.asm
include libs/master.lib/mem_assign_dos.asm
include libs/master.lib/mem_assign.asm
include libs/master.lib/memheap.asm
Expand Down
40 changes: 3 additions & 37 deletions th02_op.asm
Expand Up @@ -2856,8 +2856,7 @@ loc_1581:
pop ds
mov mem_AllocID, 0Ah
nop
push cs
call near ptr sub_26F2
call hmem_lallocate
pop ds
stosw
jb short loc_15D2
Expand Down Expand Up @@ -2904,8 +2903,7 @@ loc_15D2:
pop ds
mov mem_AllocID, 0Ah
nop
push cs
call near ptr sub_26F2
call hmem_lallocate
pop ds
mov bx, ax
mov ax, 0FFF8h
Expand Down Expand Up @@ -4809,39 +4807,7 @@ sub_26B2 endp
; ---------------------------------------------------------------------------
nop

; =============== S U B R O U T I N E =======================================


sub_26F2 proc far
; sub_14D2+140p
push bx
mov bx, sp
mov ax, ss:[bx+8]
mov bx, ss:[bx+6]
add bx, 0Fh
adc ax, 0
shr ax, 1
rcr bx, 1
shr ax, 1
rcr bx, 1
shr ax, 1
rcr bx, 1
shr ax, 1
jnz short loc_271E
rcr bx, 1
push bx
call hmem_alloc
pop bx
retf 4
; ---------------------------------------------------------------------------

loc_271E:
mov ax, 0
stc
pop bx
retf 4
sub_26F2 endp

include libs/master.lib/hmem_lallocate.asm
include libs/master.lib/mem_assign_dos.asm
include libs/master.lib/mem_assign.asm
include libs/master.lib/memheap.asm
Expand Down
41 changes: 3 additions & 38 deletions th03_main.asm
Expand Up @@ -3073,8 +3073,7 @@ loc_169D:
pop ds
mov mem_AllocID, 0Ah
nop
push cs
call near ptr sub_2218
call hmem_lallocate
pop ds
stosw
jb short loc_16EE
Expand Down Expand Up @@ -3121,8 +3120,7 @@ loc_16EE:
pop ds
mov mem_AllocID, 0Ah
nop
push cs
call near ptr sub_2218
call hmem_lallocate
pop ds
mov bx, ax
mov ax, 0FFF8h
Expand Down Expand Up @@ -4793,40 +4791,7 @@ loc_2211:
retf
sub_21F2 endp


; =============== S U B R O U T I N E =======================================


sub_2218 proc far
; sub_15EE+140p
push bx
mov bx, sp
mov ax, ss:[bx+8]
mov bx, ss:[bx+6]
add bx, 0Fh
adc ax, 0
shr ax, 1
rcr bx, 1
shr ax, 1
rcr bx, 1
shr ax, 1
rcr bx, 1
shr ax, 1
jnz short loc_2244
rcr bx, 1
push bx
call hmem_alloc
pop bx
retf 4
; ---------------------------------------------------------------------------

loc_2244:
mov ax, 0
stc
pop bx
retf 4
sub_2218 endp

include libs/master.lib/hmem_lallocate.asm
include libs/master.lib/mem_assign_dos.asm
include libs/master.lib/mem_assign.asm
include libs/master.lib/memheap.asm
Expand Down
41 changes: 3 additions & 38 deletions th03_mainl.asm
Expand Up @@ -2249,8 +2249,7 @@ loc_10F3:
pop ds
mov mem_AllocID, 0Ah
nop
push cs
call near ptr sub_210A
call hmem_lallocate
pop ds
stosw
jb short loc_1144
Expand Down Expand Up @@ -2297,8 +2296,7 @@ loc_1144:
pop ds
mov mem_AllocID, 0Ah
nop
push cs
call near ptr sub_210A
call hmem_lallocate
pop ds
mov bx, ax
mov ax, 0FFF8h
Expand Down Expand Up @@ -4109,40 +4107,7 @@ loc_20EE:
retf 2
sub_20CA endp


; =============== S U B R O U T I N E =======================================


sub_210A proc far
; sub_1044+140p
push bx
mov bx, sp
mov ax, ss:[bx+8]
mov bx, ss:[bx+6]
add bx, 0Fh
adc ax, 0
shr ax, 1
rcr bx, 1
shr ax, 1
rcr bx, 1
shr ax, 1
rcr bx, 1
shr ax, 1
jnz short loc_2136
rcr bx, 1
push bx
call hmem_alloc
pop bx
retf 4
; ---------------------------------------------------------------------------

loc_2136:
mov ax, 0
stc
pop bx
retf 4
sub_210A endp

include libs/master.lib/hmem_lallocate.asm
include libs/master.lib/mem_assign_dos.asm
include libs/master.lib/mem_assign.asm
include libs/master.lib/memheap.asm
Expand Down

0 comments on commit c3202f4

Please sign in to comment.