From
Eugene Palenock
→
To
Valerij Kozhevnikoff
24 March 2001
Hello Valerij!
23 Mar 01 01:30, Valerij Kozhevnikoff -> All:
VK> Someone throw a bun that makes a subject.
VK> Like we have the text string "32768" - we need to get the number #8000.
VK> I tried it - it’s somehow cumbersome...
Well, I’ll write now... There may be glitches here, because
it was made up right here. But I hope the general idea is clear...
LD HL,string address
LD B, string length
LD DE,s_tmp ;5 byte buffer address
LD LX,B
M1 LD A,(HL)
SUB 30h
LD(DE),A
INC HL
INC DE
DJNZ M1
Preparation. There are no checks against fools here.
Be more careful with the number of numbers and the presence of non-digits among them
;1
DEC DE
LD A,(DE)
LD H,0
LD L,A
DEC LX
RET Z
Conversion of units.
;10
DEC DE
LD A,(DE)
AND A
JR Z,C2Z
PUSH DE
PUSH HL
LD HL,0
LD DE,10
C2 ADD HL,DE
DEC A
JR NZ,C2
POP DE
ADD HL,DE
POP DE
C2Z DEC LX
RET Z
In general, this is not optimally written, but if severaldifferent directions of optimization, so I will not...
;100
DEC OF
LD A,(DE)
AND A
JR Z,C3Z
PUSH THERE
PUSH HL
LD HL,0
LD DE,100
C3 ADD HL,DE
DEC A
JR NZ,C3
POP DE
ADD HL,DE
POP DE
C3Z DEC LX
RET Z
;1000
DEC OF
LD A,(DE)
AND A
JR Z,C4Z
PUSH THERE
PUSH HL
LD HL,0
LD DE,1000
C4 ADD HL,DE
DEC A
JR NZ,C4
POP DE
ADD HL,DE
POP DE
C4Z DEC LX
RET Z
;10000
DEC OF
LD A,(DE)
AND A
JR Z,C5Z
PUSH THERE
PUSH HL
LD HL,0
LD DE,10000
C5 ADD HL,DE
DEC A
JR NZ,C2
POP DE
ADD HL,DE
POP DE
C5Z RET
From
Wladimir Bulchukey
→
To
Valerij Kozhevnikoff
25 March 2001
Greetings, Valerij!
23 Mar 01 01:30, Valerij Kozhevnikoff -> All:
VK> Someone throw a bun that makes a subject.
VK> Like we have the text string "32768" - we need to get the number
VK> #8000. I tried it here - it’s somehow cumbersome...
LD DE,STRING ; line address
LD BC,STRIN1-STRING ; string length
XOR A
CALL #2ABB
LD B,#1D
RST #28
DEFB #3B,#38
CALL #2DA2
RET ; numeric 16-bit string value in BC
;-
STRING DEFM "32768" ; any string representation of a number
; 0...65535
STRIN1
END
With the best -
Wlodek. mailto: wlblack@chat.ru http://www.wlodeks.boom.ru
[ZX] [Golyanovo] [Radio "Retro" 72.92 MHz]
From
Valerij Kozhevnikoff
→
To
Wladimir Bulchukey
25 March 2001
Hello, Wladimir!
25 Mar 01 00:36, Wladimir Bulchukey -> Valerij Kozhevnikoff:
VK>> Someone throw a bun that makes a subject.
VK>> Like we have the text string "32768" - we need to get the number
VK>> #8000. I tried it here - it’s somehow cumbersome...
WB> LD DE,STRING ; line address
WB> LD BC,STRIN1-STRING ; string length
WB> XOR A
WB> CALL #2ABB
WB> LD B,#1D
WB> RST #28
WB> DEFB #3B,#38
WB> CALL #2DA2
WB> RET ; numeric 16-bit string value in BC
WB> ;-
WB> STRING DEFM "32768" ; any string representation of a number
WB> ; 0...65535
WB> STRIN1
WB> END
Here! Calculator rules! Not a byte to the enemy!
Do you have a similar bun that does the opposite effect?
WBR, Jason.
[Team Obituary][Team Friday 13th][Team Evil Maniacs][Team Huge Axes]
From
Oleg Grigoriev
→
To
Valerij Kozhevnikoff
25 March 2001
Let your enemies, Valerij, die without sons!
23 March 2001 at 01:30, Valerij Kozhevnikoff => All:
VK> Someone throw a bun that makes a subject.
VK> Like we have the text string "32768" - we need to get the number #8000.
VK> I tried it - it’s somehow cumbersome...
Everything works out just fine.
the first digit is entered into the adder, multiplied by ten, added
the second one is multiplied by ten, the third one is added... and so on until the full
satisfaction. :)
[WBR, Oleg. ]
[ 19:57 25 March XXXVI A.S. ]
From
Oleg Grigoriev
→
To
EP & WB
25 March 2001
Let your enemies, EP, die without sons!
25 March 2001 at 00:36, Wladimir Bulchukey => Valerij Kozhevnikoff:
I suck... :(
at the input - de indicates a string ending in zero, at the output at hl -
number.
ld hl, #0000
loop ld a, (de)
or a
ret z
add hl, hl
ld b, h
ld c, l
add hl, hl
add hl, hl
add hl, bc
sub #30
ld c, a
ld b, #00
add hl, bc
jp loop
[WBR, Oleg. ]
[ 20:23 25 March XXXVI A.S. ]
From
Kirill Frolov
→
To
Valerij Kozhevnikoff
26 March 2001
Press RESET immediately, Valerij!
24 Mar 01 02:06, Eugene Palenock wrote to Valerij Kozhevnikoff:
VK>> Someone throw a bun that makes a subject.
VK>> Like we have the text string "32768" - we need to get the number #8000.
VK>> I tried it - it’s somehow cumbersome...
; de=string of digits with trailing zero -> hl=binary number
; checks for the correctness of input data and
; no overflow!
atoi: ld hl, 0
nextc: ld a, (de)
or a
ret z
inc de
add hl, hl
ld c, l
ld b, h
add hl, hl
add hl, bc
add hl, hl
ld b, 0
ld c, a
add hl, bc
jr nextc
From
Eugene Palenock
→
To
Valerij Kozhevnikoff
26 March 2001
Hello Valerij!
25 Mar 01 15:12, Valerij Kozhevnikoff -> Eugene Palenock:
VK>>> I tried it - it’s somehow cumbersome...
EP>> this was written right here. But I hope the general idea is clear...
VK> Uh-huh. I got about the same thing.
VK> And it needs to take up less memory.
You don’t have 65 bytes??? You can do this:
=== Home Windows Clipboard ===
LD HL,string address
LD B, string length
LD DE,M5
LD LX,B
M1 LD A,(HL)
SUB 30h
LD(DE),A
INC HL
INC DE
DJNZ M1
DEC DE
LD A,(DE)
LD H,0
LD L,A
DEC LX
RET Z
LD BC,10
CALL M2
LD C,100
CALL M2
LD BC,1000
CALL M2
LD BC,10000
CALL M2
M2 DEC DE
LD A,(DE)
AND A
JR Z,M3
M4 ADD HL,BC
DEC A
JR NZ,M4
M3 DEC LX
RET NZ
POP AF
RET
M5 DEFS 5.0
===End of Windows Clipboard ===
Best regards, Evgeniy.
From
Wladimir Bulchukey
→
To
Valerij Kozhevnikoff
26 March 2001
Greetings, Valerij!
25 Mar 01 15:21, Valerij Kozhevnikoff -> Wladimir Bulchukey:
VK> You don’t have a similar bun that does the opposite effect
VK> is there?
; input: BC = number
CALL #2D2B
CALL #361F
CALL #2BF1
; output: at this point DE = address of the beginning of the character string
; BC = string length.
With the best -
Wlodek. mailto: wlblack@chat.ru http://www.wlodeks.boom.ru
[ZX] [Golyanovo] [Radio "Retro" 72.92 MHz]
From
Wladimir Bulchukey
→
To
Oleg Grigoriev
28 March 2001
Приветствую, Oleg!
25 Мар 01 20:56, Oleg Grigoriev -> EP & WB:
OG> я хренею... :(
OG> на входе - de указывает на стриг, оканчивающийся нулём,
OG> на выходе в hl - число.
OG> ld hl, #0000
OG> loop ld a, (de)
OG> or a
OG> ret z
OG> add hl, hl
OG> ld b, h
OG> ld c, l
OG> add hl, hl
OG> add hl, hl
OG> add hl, bc
OG> sub #30
OG> ld c, a
OG> ld b, #00
OG> add hl, bc
OG> jp loop
Что ж, помножили сложением на 8 да прибавили удвоенное исходное -
умножили на 10. :)
А калькулятор - штука полезная, вообще-то. В том примере
строка символов может содержать любое, не обязательно целое,
число и даже выражение. Если результат в конце не запихивать в BC,
можно таких дел натворить! :)
А хренеть, кстати, следует от отсутствия в твоем примере INC DE ;-)))))) .
С наилучшими -Wlodek. mailto: wlblack@chat.ru http://www.wlodeks.boom.ru
[ZX] [Golyanovo] [Radio "Retro" 72.92 MHz]
From
Wladimir Bulchukey
→
To
Kirill Frolov
28 March 2001
Greetings, Kirill!
26 Mar 01 19:17, Kirill Frolov -> Wladimir Bulchukey:
WB>> RST #28
KF> Do you have a document for rst 28 functions?
=== Cut ===
#00 - jump true
#01 - exchange
#02 - delete
#03 - subtract (subtraction; X-Y)
#04 - mult (multiplication; X*Y)
#05 - div (division; Y/X)
#06 - to-power (exponentiation; X^Y)
#07 - or
#08 - no-&-no
#09 - no-l-eq
#0A - no-gr-eq
#0B - nos-eql
#0C - no-gtr
#0D - no-less
#0E - nos-eql
#0F - add (addition; X+Y)
#10 - str-&-no
#11 - str-l-eq
#12 - str-gr-eq
#13 - strs-negl
#14 - str-gtr
#15 - str-less
#16 - str-gtr
#17 - strs-add
#18 - val$ (recursion; only via fp-calc-2)
#19 - usr-s
#1A - read-in
#1B - neg
#1C - code
#1D - val (recursion; only via fp-calc-2)
#1E - len
#1F - sin
#20 - cos
#21 - tan
#22 - asn
#23 - acs
#24 - atn
#25 - ln
#26 - exp
#27 - int
#28 - sqr
#29 - sgn
#2A - abs
#2B - peek
#2C - int(Y+0.5)
#2D - user-no
#2E - str$
#2F - chr$
#30 - not
#31 - duplicate
#33 - jump
#34 - stk-data
#35 - djnz
#36 - less-0
#37 - greater-0
#38 - end-calc (end the calculator)
#39 - get-argt
#3A - trunc
#3B - fp-calc-2 (secondary calculator call - recursion)
#3C - e-to-fp
#3D - restack (Y integer -> Y in floating form)
#86 onwards - series-06
#A0 - 0 (constant; pushing a constant onto the stack)
#A1 - 1
#A2 - 1/2
#A3 - PI/2
#C0 onwards - st-mem-0#E0 onwards - get-mem-0
=== Cut ===
With the best -
Wlodek. mailto: wlblack@chat.ru http://www.wlodeks.boom.ru
[ZX] [Golyanovo] [Radio "Retro" 72.92 MHz]
From
Valerij Kozhevnikoff
→
To
Oleg Grigoriev
28 March 2001
Hello, Oleg!
25 Mar 01 20:56, Oleg Grigoriev -> EP & WB:
OG> on input - de indicates a zero-terminated strig, on output in hl -
OG> number.
Almost works =)
OG> ld hl, #0000
OG> loop ld a, (de)
OG> or a
OG> ret z
OG> add hl, hl
OG> ld b, h
OG> ld c, l
OG> add hl, hl
OG> add hl, hl
OG> add hl, bc
OG> sub #30 ;KF0 lost this sub.
OG> ld c, a
OG> ld b, #00
OG> add hl, bc
OG> jp loop ;will Pushkin do inc de here?
WBR, Jason.
[Team Obituary][Team Friday 13th][Team Evil Maniacs][Team Huge Axes]
From
Kirill Frolov
→
To
Valerij Kozhevnikoff
29 March 2001
Press RESET immediately, Valerij!
27 Mar 01 21:04, Valerij Kozhevnikoff wrote to Eugene Palenock:
VK> Hmm. I shouldn't have praised the calculator. Non-digital characters squash him, but
VK> with their catch it also weighs about that much.
Here, both Ruiner and I wrote the same normal algorithm - is it really not
did you see?
Filtering is easy!
; de=decimal in string --> hl=binary number; cf=1, de=illegal char. if
error
atoi: ld hl, 0
ld а, (de)
jr firstc
nextc: ld a, (de)
or a
ret z
firstc:sub '0'
ret c
cp 10
ccf
ret c
inc de
add hl, hl
ret c
ld c, l
ld b, h
add hl, hl
ret c
add hl, hl
ret c
add hl, bc
ret c
ld c, a
ld b, 0
add hl, bc
jr nc, nextc
ret
Is it that much?