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 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287
|
_____________________________________________________________
;------------------------
; General purpose macros:
;------------------------
[mov | mov #1 #2 | #+2]
[push | push #1 | #+1] [pop | pop #1 | #+1]
[Call | push #L>2 | call #1]
_____________________________________________________________
; Proc Function:
; Arguments @ParamA, @ParamB
; Local @LocalA, @LocalB
; Structure @Point 8, @X 0, @Y 4
; Uses ebx esi edi
; ...
; Return 0
; ...
; EndP
; &1 = Size of arguments
; &2 = Size of local data (local+structures)
; &3 = preserved regs
[Proc | &1=0 | &2=0 | &3= ; clear the compile time strings
#1
push ebp ; init stackframe
mov ebp esp]
[Arguments
{#1 ebp+((#x*4)+4)} | #+1 ; declare equate e.g. [Function@ParamA ebp+8]
&1=(#N*4)] ; remember size of arguments
[Argument ; Permets la syntaxe au singulier
{#1 ebp+((#x*4)+4)} | #+1 ; declare equate e.g. [Function@ParamA ebp+8]
&1=(#N*4)] ; remember size of arguments
[Local
{#1 ebp-(#x*4)} | #+1 ; declare equate e.g. [Function@LocalA ebp-4]
&2=(#N*4) ; remember size of locals
sub esp &2] ; reserve space on stack
[getMember
{#3 ebp-(#F-#2)} | #+2] ; build equates for structure members
[Structure
{#1 ebp-(&2+#2+4)} ; declare equate for address of the structure
sub esp #2 ; reserve space on stack
push esp ; push address of structure
getMember &2+#2 #L>3 ; build member equates starting at [ebp-LocalsSize]
&2=&2+#2+4] ; increase locals size, allows multiple structures
[Uses
push #1>L ; preserve registers by pushing them on the stack
&3=pop #L>1] ; build command to recover regs before leaving
[Return
#If #N=1
mov eax #1
#EndIf
jmp P9>]
[EndP | P9:
&3 ; pop preserved regs (if any)
mov esp ebp ; restore stack pointer
pop ebp ; restore parents stack frame
ret &1] ; return to caller and wipe arguments off the stack
_____________________________________________________________
[On | cmp #1 #3 | jn#2 o1> | #4>L | o1:]
[If | cmp #1 #3 | jn#2 I0>]
[.If | cmp #1 #3 | jn#2 I1>>]
[..If | cmp #1 #3 | jn#2 I2>>]
[...If | cmp #1 #3 | jn#2 I3>>]
[Else_if | jmp I5> | I0: | cmp #1 #3 | jn#2 I0>]
[.Else_if | jmp I6>> | I1: | cmp #1 #3 | jn#2 I1>>]
[..Else_if | jmp I7>> | I2: | cmp #1 #3 | jn#2 I2>>]
[...Else_if | jmp I8>> | I3: | cmp #1 #3 | jn#2 I3>>]
[Else | Jmp I5> | I0:]
[.Else | Jmp I6>> | I1:]
[..Else | Jmp I7>> | I2:]
[...Else | Jmp I8>> | I3:]
[End_if | I0: | I5:]
[.End_if | I1: | I6:]
[..End_if | I2: | I7:]
[...End_if | I3: | I8:]
[While | W0: | cmp #1 #3 | jn#2 W9>]
[End_While | jmp W0< | W9:]
[.While | X0: | cmp #1 #3 | jn#2 X9>>]
[.End_While | jmp X0<< | X9:]
[Do | D0:]
[Loop_Until | cmp #1 #3 | jn#2 D0<]
[Do_Loop | Loop D0<]
[.Do | E0:]
[.Loop_Until | cmp #1 #3 | jn#2 E0<<] ; long
[.Do_Loop | Loop E0<]
_____________________________________________________________
; Added Equates for a more HLL like style in comparison to Macros:
[= e < b > a =< be <= be => ae >= ae <> ne]
_____________________________________________________________
[WORD 2
DWORD 4]
[IDC_EDIT 100
IDC_TEXT 101
IDC_OK 200]
[Dialog: D$ 090CE08C0 0 U$ 04 0 0 092 041 0 '' 0 'Roman' 0
08 'Fixedsys' 0]
[Control0000: D$ 050802002 0 U$ 07 0F 086 0C 064 0FFFF 081 '' 0 0]
[Control0001: D$ 050000000 0 U$ 036 030 028 0C 0C8 0FFFF 080
'OK' 0 0]
[Control0002: D$ 050800802 0 U$ 07 01E 086 0C 065 0FFFF 081 '' 0 0]
[Control0003: D$ 050800000 0 U$ 07 02 086 0A 012C 0FFFF 082
'Type a number from 1 to 3,999,999' 0 0]
_____________________________________________________________
Main:
;;
The 1983 Hammond Almanac gives this description. I used it when I
wrote the conversion routine from decimal to roman below, but
instead of a bar line over the numerals I use lower case letters.
Just "Open source only" in RosAsm, compile, and run -> www.rosasm.org
*Roman numerals:*
These are letter symbols used to represent numbers. The seven basic
letters and their number equivalents are: I = 1, V = 5, X = 10, L =
50, C = 100, D = 500, M = 1000. All other numbers (there is no zero)
are formed using combinations of these letters (reading left to
right, highest to lowest) which, when added together, produce the
desired total: MCLX = 1,160; LXXI = 71; XVIII = 18, etc.
In most cases a subtraction principle is used to show numbers
containing 4's and 9's. Thus instead of using four consecutive
similar letters (IIII, XXXX or CCCC), only one letter is shown,
followed by a larger value letter from which the smaller is to be
subtracted. Examples of these cases are: IV = 4, IX = 9, XL = 40, XC
= 90, CD = 400, CM = 900. 494 is written CDXCIV, 1979 becomes
MCMLXXIX.
The addition of a bar line over the Roman numerals increases its
_ ___ ___
value 1,000 times. V represents 5,000, XIX = 19,000, LVI = 56,000.
____
A large number such as 145,262 converts to CXLVCCLXII.
;;
Call 'USER32.DialogBoxIndirectParamA' &NULL,
Dialog,
&NULL,
DialogProc,
&NULL
Call 'KERNEL32.ExitProcess' &NULL
;;
Bugg -> [-] = Prout ;))
Calling sequence: Call Roman
Entry conditions: EAX = Number.
Exit conditions: EDI -> Converted number.
;;
_____________________________________________________________
Proc DialogProc:
Arguments @hwndDlg,
@uMsg,
@wParam,
@lParam
Local @Translated
pushad
If D@uMsg = &WM_COMMAND
On W@wParam+WORD <> &BN_CLICKED jmp Ignore
On W@wParam <> IDC_OK jmp Ignore
Call 'USER32.GetDlgItemInt' D@hwndDlg,
IDC_EDIT,
D@Translated,
&FALSE
On eax > 3999999 jmp Ignore
Call Roman
Call 'USER32.SetDlgItemTextA' d@hwndDlg,
IDC_TEXT,
edi
Else_If D@uMsg = &WM_CLOSE
Call 'USER32.EndDialog' D@hwndDlg,
&NULL
Else
Ignore: popad | Return &FALSE
End_If
popad | Return &TRUE
EndP
_____________________________________________________________
[Digits: D$ 0]
[@I: D$ "I"] [@II: D$ "II"] [@III: D$ "III"]
[@IV: D$ "VI"] [@V: D$ "V"] [@VI: D$ "IV"]
[@VII: D$ "IIV"] [@VIII: D$ "IIIV"] [@IX: D$ "XI" D$ 0]
[@X: D$ "X"] [@XX: D$ "XX"] [@XXX: D$ "XXX"]
[@XL: D$ "LX"] [@L: D$ "L"] [@LX: D$ "XL"]
[@LXX: D$ "XXL"] [@LXXX: D$ "XXXL"] [@XC: D$ "CX" D$ 0]
[@C: D$ "C"] [@CC: D$ "CC"] [@CCC: D$ "CCC"]
[@CD: D$ "DC"] [@D: D$ "D"] [@DC: D$ "CD"]
[@DCC: D$ "CCD"] [@DCCC: D$ "CCCD"] [@CM: D$ "MC" D$ 0]
[@M: D$ "M"] [@MM: D$ "MM"] [@MMM: D$ "MMM"]
[@Mv: D$ "vM"] [@v1: D$ "v"] [@vM: D$ "Mv"]
[@vMM: D$ "MMv"] [@vMMM: D$ "MMMv"] [@Mx: D$ "xM" D$ 0]
[@i1: D$ "i"] [@ii1: D$ "ii"] [@iii1: D$ "iii"]
[@iv1: D$ "vi"] [@v2: D$ "v"] [@vi1: D$ "iv"]
[@vii1: D$ "iiv"] [@viii1: D$ "iiiv"] [@ix1: D$ "xi" D$ 0]
[@x1: D$ "x"] [@xx1: D$ "xx"] [@xxx1: D$ "xxx"]
[@xl1: D$ "lx"] [@l1: D$ "l"] [@lx1: D$ "xl"]
[@lxx1: D$ "xxl"] [@lxxx1: D$ "xxxl"] [@xc1: D$ "cx" D$ 0]
[@c1: D$ "c"] [@cc1: D$ "cc"] [@ccc1: D$ "ccc"]
[@cd1: D$ "dc"] [@d1: D$ "d"] [@dc1: D$ "cd"]
[@dcc1: D$ "ccd"] [@dccc1: D$ "cccd"] [@cm1: D$ "mc" D$ 0]
[@m1: D$ "m"] [@mm1: D$ "mm"] [@mmm1: D$ "mmm" D$ 0]
Roman:
[@Flag: D$ ?
@String: B$ ? # 28]
cmp eax 4000 | setae B@Flag
mov ecx 10, ebx Digits, edi @String+28
xor edx edx
L1: div ecx | test edx edx | jz S1>
mov edx D$ebx+edx*DWORD
L2: dec edi | mov B$edi dl | shr edx 8 | jnz L2<
S1: add ebx 40
test B@Flag 1 | jz S2>
cmp ebx Digits+120 | jne S2>
add ebx 40
S2: test eax eax | jnz L1<
ret
_____________________________________________________________
_____________________________________________________________
; EOF |
Partager