-
Notifications
You must be signed in to change notification settings - Fork 5
/
CF48.ASM
129 lines (110 loc) · 1.76 KB
/
CF48.ASM
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
; *******************************************************
; * *
; * Turbo Pascal Run-time Library *
; * Real Str/Val Routines (PChar) *
; * *
; * Copyright (c) 1988,92 Borland International *
; * *
; *******************************************************
TITLE CF48
INCLUDE SE.ASM
CODE SEGMENT BYTE PUBLIC
ASSUME CS:CODE
; Externals
EXTRN Real2Str:NEAR,Str2Real:NEAR
; Publics
PUBLIC StrRealC,ValRealC
; Convert real to zero-terminated string
; In [SP+10] = Real value
; [SP+8] = Field width
; [SP+6] = Decimal count
; [SP+2] = String pointer
; [SP] = Maximum length
; Out SP = SP+16
StrRealC:
ARG Value,BYTE,6
ARG Width,WORD,1
ARG Decimals,WORD,1
ARG StrP,DWORD,1
ARG StrLen,WORD,1
LOC NumStr,BYTE,64
ENTRY FAR
MOV AX,Value.w0
MOV BX,Value.w2
MOV DX,Value.w4
MOV CX,Decimals
OR CX,CX
JNS @@0
MOV CX,6
SUB CX,Width
CMP CX,-2
JLE @@0
MOV CX,-2
@@0: LEA DI,NumStr
PUSH SS
POP ES
CALL Real2Str
PUSH DS
MOV SI,DI
PUSH SS
POP DS
LES DI,StrP
MOV DX,StrLen
MOV AX,Width
CMP AX,DX
JLE @@1
MOV AX,DX
@@1: CMP CX,DX
JLE @@2
MOV CX,DX
@@2: CMP AX,CX
JGE @@3
MOV AX,CX
@@3: CLD
SUB AX,CX
JE @@4
PUSH CX
MOV CX,AX
MOV AL,' '
REP STOSB
POP CX
@@4: REP MOVSB
XOR AL,AL
STOSB
POP DS
EXIT
; Convert zero-terminated string to real
; In [SP+4] = String pointer
; [SP] = Error variable pointer
; Out R1 = Value
; SP = SP+8
ValRealC:
ARG StrP,DWORD,1
ARG ErrPosP,DWORD,1
ENTRY FAR
LES DI,StrP
MOV CX,0FFFFH
MOV AL,' '
CLD
REPE SCASB
DEC DI
MOV CX,0FFFFH
XOR AL,AL
REPNE SCASB
NOT CX
SUB DI,CX
DEC CX
CALL Str2Real
JC @@1
JCXZ @@2
@@1: MOV CX,DI
SUB CX,StrP.ofs
INC CX
XOR AX,AX
MOV BX,AX
MOV DX,AX
@@2: LES DI,ErrPosP
MOV ES:[DI],CX
EXIT
CODE ENDS
END