mirror of
https://github.com/dschmenk/PLASMA.git
synced 2025-03-25 21:30:44 +00:00
BIG change so FOR/NEXT exits with proper terminal value in variable
This commit is contained in:
parent
1c63d4832e
commit
c1d849946f
@ -180,12 +180,12 @@ end
|
||||
//
|
||||
// Local network parameters
|
||||
//
|
||||
const MAX_WIZ_CHANNELS = 4
|
||||
const MAX_WIZ_CHANNELS = 4
|
||||
//
|
||||
// Channel protocols
|
||||
//
|
||||
const WIZ_PROTO_CLOSED = 0
|
||||
const WIZ_PROTO_TCP = 1
|
||||
const WIZ_PROTO_CLOSED = 0
|
||||
const WIZ_PROTO_TCP = 1
|
||||
const WIZ_PROTO_UDP = 2
|
||||
const WIZ_PROTO_IP = 3
|
||||
const WIZ_PROTO_RAW = 4
|
||||
@ -212,7 +212,7 @@ struc t_channel
|
||||
word channel_recv_func
|
||||
word channel_recv_parm
|
||||
end
|
||||
byte[t_channel * MAX_WIZ_CHANNELS] wizChannel
|
||||
byte[t_channel] wizChannel[MAX_WIZ_CHANNELS]
|
||||
//
|
||||
// Service ICMP hook
|
||||
//
|
||||
@ -227,11 +227,11 @@ end
|
||||
// Swap bytes in word
|
||||
//
|
||||
asm swab(val)
|
||||
LDA ESTKL,X
|
||||
LDY ESTKH,X
|
||||
STA ESTKH,X
|
||||
STY ESTKL,X
|
||||
RTS
|
||||
LDA ESTKL,X
|
||||
LDY ESTKH,X
|
||||
STA ESTKH,X
|
||||
STY ESTKL,X
|
||||
RTS
|
||||
end
|
||||
//
|
||||
// Wiznet I/O functions
|
||||
@ -239,118 +239,122 @@ end
|
||||
// POKE WORD TO I/O SPACE
|
||||
// Note: Big Endian format
|
||||
//
|
||||
asm _pokeiow(val)
|
||||
LDA ESTKH,X
|
||||
asm _pokeiow(val)#0
|
||||
LDA ESTKH,X
|
||||
end
|
||||
asm _pokeiowl
|
||||
STA $C000
|
||||
LDA ESTKL,X
|
||||
STA $C000
|
||||
LDA ESTKL,X
|
||||
end
|
||||
asm _pokeiowh
|
||||
STA $C000
|
||||
RTS
|
||||
STA $C000
|
||||
INX
|
||||
RTS
|
||||
end
|
||||
//
|
||||
// POKE BYTE TO I/O SPACE
|
||||
//
|
||||
asm _pokeio(val)
|
||||
LDA ESTKL,X
|
||||
asm _pokeio(val)#0
|
||||
LDA ESTKL,X
|
||||
end
|
||||
asm _pokeiol
|
||||
STA $C000
|
||||
RTS
|
||||
STA $C000
|
||||
INX
|
||||
RTS
|
||||
end
|
||||
//
|
||||
// PEEK BYTE FROM I/O SPACE
|
||||
//
|
||||
asm _peekio
|
||||
DEX
|
||||
DEX
|
||||
end
|
||||
asm _peekiol
|
||||
LDA $C000
|
||||
STA ESTKL,X
|
||||
LDA #$00
|
||||
STA ESTKH,X
|
||||
RTS
|
||||
LDA $C000
|
||||
STA ESTKL,X
|
||||
LDA #$00
|
||||
STA ESTKH,X
|
||||
RTS
|
||||
end
|
||||
//
|
||||
// PEEK WORD FROM I/O SPACE
|
||||
// Note: Big Endian format
|
||||
//
|
||||
asm _peekiow
|
||||
DEX
|
||||
DEX
|
||||
end
|
||||
asm _peekiowl
|
||||
LDA $C000
|
||||
STA ESTKH,X
|
||||
LDA $C000
|
||||
STA ESTKH,X
|
||||
end
|
||||
asm _peekiowh
|
||||
LDA $C000
|
||||
STA ESTKL,X
|
||||
RTS
|
||||
LDA $C000
|
||||
STA ESTKL,X
|
||||
RTS
|
||||
end
|
||||
//
|
||||
// WRITE DATA INTO I/O SPACE
|
||||
// pokedata(BUF, LEN)
|
||||
//
|
||||
asm pokedata(buf, len)
|
||||
LDA ESTKL+1,X
|
||||
STA SRCL
|
||||
LDA ESTKH+1,X
|
||||
STA SRCH
|
||||
LDY ESTKL,X
|
||||
BEQ POKELP
|
||||
LDY #$00
|
||||
INC ESTKH,X
|
||||
POKELP LDA (SRC),Y
|
||||
asm pokedata(buf, len)#0
|
||||
LDA ESTKL+1,X
|
||||
STA SRCL
|
||||
LDA ESTKH+1,X
|
||||
STA SRCH
|
||||
LDY ESTKL,X
|
||||
BEQ POKELP
|
||||
LDY #$00
|
||||
INC ESTKH,X
|
||||
POKELP LDA (SRC),Y
|
||||
end
|
||||
asm _pokedata
|
||||
STA $C000
|
||||
INY
|
||||
BNE +
|
||||
INC SRCH
|
||||
+ DEC ESTKL,X
|
||||
BNE POKELP
|
||||
DEC ESTKH,X
|
||||
BNE POKELP
|
||||
INX
|
||||
RTS
|
||||
STA $C000
|
||||
INY
|
||||
BNE +
|
||||
INC SRCH
|
||||
+ DEC ESTKL,X
|
||||
BNE POKELP
|
||||
DEC ESTKH,X
|
||||
BNE POKELP
|
||||
INX
|
||||
INX
|
||||
RTS
|
||||
end
|
||||
//
|
||||
// READ DATA FROM I/O SPACE
|
||||
// peekdata(BUF, LEN)
|
||||
//
|
||||
asm peekdata(buf, len)
|
||||
LDA ESTKL+1,X
|
||||
STA DSTL
|
||||
LDA ESTKH+1,X
|
||||
STA DSTH
|
||||
LDY ESTKL,X
|
||||
BEQ PEEKLP
|
||||
LDY #$00
|
||||
INC ESTKH,X
|
||||
asm peekdata(buf, len)#0
|
||||
LDA ESTKL+1,X
|
||||
STA DSTL
|
||||
LDA ESTKH+1,X
|
||||
STA DSTH
|
||||
LDY ESTKL,X
|
||||
BEQ PEEKLP
|
||||
LDY #$00
|
||||
INC ESTKH,X
|
||||
end
|
||||
asm _peekdata
|
||||
PEEKLP LDA $C000
|
||||
STA (DST),Y
|
||||
INY
|
||||
BNE +
|
||||
INC DSTH
|
||||
+ DEC ESTKL,X
|
||||
BNE PEEKLP
|
||||
DEC ESTKH,X
|
||||
BNE PEEKLP
|
||||
INX
|
||||
RTS
|
||||
PEEKLP LDA $C000
|
||||
STA (DST),Y
|
||||
INY
|
||||
BNE +
|
||||
INC DSTH
|
||||
+ DEC ESTKL,X
|
||||
BNE PEEKLP
|
||||
DEC ESTKH,X
|
||||
BNE PEEKLP
|
||||
INX
|
||||
INX
|
||||
RTS
|
||||
end
|
||||
def pokeiow(io, data)
|
||||
def pokeiow(io, data)#0
|
||||
_pokeiowl.1 = io
|
||||
_pokeiowh.1 = io+1
|
||||
return _pokeiow(data)
|
||||
_pokeiow(data)
|
||||
end
|
||||
def pokeio(io, data)
|
||||
def pokeio(io, data)#0
|
||||
_pokeiol.1 = io
|
||||
return _pokeio(data)
|
||||
_pokeio(data)
|
||||
end
|
||||
def peekio(io)
|
||||
_peekiol.1 = io
|
||||
@ -361,26 +365,26 @@ def peekiow(io)
|
||||
_peekiowh.1 = io+1
|
||||
return _peekiow()
|
||||
end
|
||||
def pokereg(reg, data)
|
||||
def pokereg(reg, data)#0
|
||||
_pokeiow(reg)
|
||||
return _pokeio(data)
|
||||
_pokeio(data)
|
||||
end
|
||||
def peekreg(reg)
|
||||
_pokeiow(reg)
|
||||
return _peekio()
|
||||
end
|
||||
def pokeregs(reg, buf, len)
|
||||
def pokeregs(reg, buf, len)#0
|
||||
_pokeiow(reg)
|
||||
return pokedata(buf, len)
|
||||
pokedata(buf, len)
|
||||
end
|
||||
def peekregs(reg, buf, len)
|
||||
def peekregs(reg, buf, len)#0
|
||||
_pokeiow(reg)
|
||||
return peekdata(buf, len)
|
||||
peekdata(buf, len)
|
||||
end
|
||||
def pokeregw(reg, dataw)
|
||||
def pokeregw(reg, dataw)#0
|
||||
_pokeiow(reg)
|
||||
_pokeio(dataw.1)
|
||||
return _pokeio(dataw.0)
|
||||
_pokeio(dataw.0)
|
||||
end
|
||||
def peekregw(reg)
|
||||
word dataw
|
||||
@ -415,7 +419,7 @@ def wizSendUDP(wiz, ipdst, portdst, data, len)
|
||||
splitlen = WIZ_TXSIZE - txrr
|
||||
pokeregs(wizdata + txrr, data, splitlen)
|
||||
pokeregs(wizdata, data + splitlen, len - splitlen)
|
||||
else
|
||||
else
|
||||
pokeregs(wizdata + txrr, data, len)
|
||||
fin
|
||||
//
|
||||
@ -480,14 +484,14 @@ end
|
||||
//
|
||||
def wizCloseUDP(wiz)
|
||||
if isuge(wiz, @wizChannel) and isult(wiz, @wizChannel + MAX_WIZ_CHANNELS * t_channel)
|
||||
//
|
||||
// Clear notiications on this port
|
||||
//
|
||||
//
|
||||
// Clear notiications on this port
|
||||
//
|
||||
if wiz->channel_proto == WIZ_PROTO_UDP
|
||||
wiz->channel_proto = WIZ_PROTO_CLOSED
|
||||
pokereg(wiz=>channel_regs + WIZ_SnCR, $10) // CLOSE
|
||||
return 0
|
||||
fin
|
||||
return 0
|
||||
fin
|
||||
fin
|
||||
//
|
||||
// Invalid port
|
||||
@ -508,8 +512,8 @@ def wizListenTCP(lclport, callback, param)
|
||||
for i = 1 to MAX_WIZ_CHANNELS
|
||||
if wiz->channel_proto == WIZ_PROTO_TCP and wiz->channel_state == TCP_STATE_LISTEN and wiz=>channel_lclport == lclport
|
||||
break
|
||||
fin
|
||||
wiz = wiz + t_channel
|
||||
fin
|
||||
wiz = wiz + t_channel
|
||||
next
|
||||
if i > MAX_WIZ_CHANNELS
|
||||
//
|
||||
@ -519,8 +523,8 @@ def wizListenTCP(lclport, callback, param)
|
||||
for i = 1 to MAX_WIZ_CHANNELS
|
||||
if !wiz->channel_proto
|
||||
break
|
||||
fin
|
||||
wiz = wiz + t_channel
|
||||
fin
|
||||
wiz = wiz + t_channel
|
||||
next
|
||||
if i > MAX_WIZ_CHANNELS
|
||||
return 0
|
||||
@ -670,10 +674,10 @@ end
|
||||
def wizSetParam(wiz, param)
|
||||
if wiz->channel_proto == WIZ_PROTO_UDP or wiz->channel_proto == WIZ_PROTO_TCP
|
||||
//
|
||||
// Update param on this port
|
||||
//
|
||||
wiz=>channel_recv_parm = param
|
||||
return 0
|
||||
// Update param on this port
|
||||
//
|
||||
wiz=>channel_recv_parm = param
|
||||
return 0
|
||||
fin
|
||||
//
|
||||
// Invalid port
|
||||
|
@ -137,7 +137,7 @@ end
|
||||
def recvDHCP(remip, remport, pkt, len, param)
|
||||
word servopts, maskopts, gwopts, dnsopts
|
||||
|
||||
//putip(remip);putc(':');puti(remport);putln
|
||||
//puts("recvDHCP: ");putip(remip);putc(':');puti(remport);putln
|
||||
//dumpdhcp(pkt)
|
||||
if pkt=>dhcp_xid:0 == $0201 and pkt=>dhcp_xid:2 == $0403
|
||||
when pkt->dhcp_opts.[parseopts(@pkt->dhcp_opts, 53) + 2]
|
||||
@ -155,10 +155,10 @@ def recvDHCP(remip, remport, pkt, len, param)
|
||||
iNet:sendUDP(portDHCP, 0, DHCP_SERVER_PORT, @DHCP, @endDHCP - @DHCP)
|
||||
break
|
||||
is DHCP_ACK
|
||||
optsOP.2 = DHCP_ACK
|
||||
//
|
||||
// Copy parameters to working copy
|
||||
//
|
||||
optsOP.2 = DHCP_ACK
|
||||
memcpy(@localip, @pkt->dhcp_yourip, IP4ADR_SIZE)
|
||||
maskopts = parseopts(@pkt->dhcp_opts, 1) + 2
|
||||
if maskopts >= 0
|
||||
@ -187,7 +187,7 @@ iNet:getInterfaceHA(@optsCID.3)
|
||||
//
|
||||
// Clear our local IP address
|
||||
//
|
||||
iNet:setInterfaceIP(@zeros,@ones, @zeros)
|
||||
iNet:setInterfaceIP(@zeros, @ones, @zeros)
|
||||
//
|
||||
// Prepare to receive DHCP packets from a server
|
||||
//
|
||||
|
@ -33,7 +33,7 @@ end
|
||||
//
|
||||
// External interface to net class. Must be first.
|
||||
//
|
||||
export byte[t_inet] iNet
|
||||
res[t_inet] iNet
|
||||
//
|
||||
// List of loadable network device drivers
|
||||
//
|
||||
@ -87,14 +87,14 @@ def parseIP(ipstr, ipaddr)
|
||||
|
||||
endstr = ipstr + ^ipstr
|
||||
for i = 0 to 3
|
||||
ipstr = ipstr + 1
|
||||
while ^ipstr >= '0' and ^ipstr <= '9' and ipstr <= endstr
|
||||
ipaddr->[i] = ipaddr->[i] * 10 + ^ipstr - '0'
|
||||
ipstr = ipstr + 1
|
||||
loop
|
||||
if ^ipstr <> '.' and ipstr < endstr
|
||||
return 0
|
||||
fin
|
||||
while ^ipstr >= '0' and ^ipstr <= '9' and ipstr <= endstr
|
||||
ipaddr->[i] = ipaddr->[i] * 10 + ^ipstr - '0'
|
||||
ipstr = ipstr + 1
|
||||
loop
|
||||
if ^ipstr <> '.' and ipstr < endstr
|
||||
return 0
|
||||
fin
|
||||
next
|
||||
return i == 3
|
||||
end
|
||||
@ -105,11 +105,11 @@ def parseDomain(domstr, msgptr)
|
||||
l = 0
|
||||
for i = 1 to ^domstr
|
||||
if domstr->[i] == '.'
|
||||
msgptr->[l] = i - l - 1
|
||||
l = i
|
||||
else
|
||||
msgptr->[i] = domstr->[i]
|
||||
fin
|
||||
msgptr->[l] = i - l - 1
|
||||
l = i
|
||||
else
|
||||
msgptr->[i] = domstr->[i]
|
||||
fin
|
||||
next
|
||||
msgptr->[l] = i - l - 1
|
||||
msgptr = msgptr + i
|
||||
@ -171,7 +171,7 @@ def iNetResolve(namestr, ipaddr)
|
||||
//
|
||||
// Query Domain Name Server for address
|
||||
//
|
||||
dnspkt = heapmark // Use heap as working DNS query packet
|
||||
dnspkt = heapalloc(^namestr + t_dnshdr + 8) // Use heap as working DNS query packet
|
||||
msgptr = dnspkt
|
||||
msgptr=>dnsID = $BEEF
|
||||
msgptr=>dnsCode = $0001 // RD (Recursion Desired)
|
||||
@ -181,9 +181,8 @@ def iNetResolve(namestr, ipaddr)
|
||||
msgptr=>dnsArCount = 0
|
||||
msgptr = parseDomain(namestr, msgptr + t_dnshdr)
|
||||
msgptr=>0 = $0100 // BE TYPE = Address
|
||||
msgptr=>2 = $0100 // BE CLASS = INternet
|
||||
msgptr=>2 = $0100 // BE CLASS = Internet
|
||||
msglen = msgptr - dnspkt + 4
|
||||
heapalloc(msglen)
|
||||
//
|
||||
// Prepare to receive DNS answer from server
|
||||
//
|
||||
@ -210,21 +209,17 @@ def iNetInit
|
||||
// Look for net hardware
|
||||
//
|
||||
while ^driver
|
||||
//puts(driver);putln
|
||||
if cmdsys:modexec(driver) >= 0
|
||||
break
|
||||
//
|
||||
// Get an IP address
|
||||
//
|
||||
cmdsys:modexec("DHCP")
|
||||
iNet:resolveIP = @iNetResolve
|
||||
return @iNet
|
||||
fin
|
||||
driver = driver + ^driver + 1
|
||||
loop
|
||||
if !^driver
|
||||
return 0
|
||||
fin
|
||||
//
|
||||
// Get an IP address
|
||||
//
|
||||
cmdsys:modexec("DHCP")
|
||||
iNet:resolveIP = @iNetResolve
|
||||
return @iNet
|
||||
return NULL
|
||||
end
|
||||
|
||||
//
|
||||
|
@ -982,14 +982,13 @@ def compiler(defptr)#0
|
||||
codeptr=>5 = $0350 // BVC +3
|
||||
codeptr->7 = $49 // EOR #$8000
|
||||
codeptr=>8 = $8000
|
||||
codeptr=>10 = $0510 // BPL +5
|
||||
codeptr=>12 = $6868 // PLA; PLA
|
||||
codeptr->14 = $4C // JMP abs
|
||||
codeptr=>15 = addrxlate=>[dest]
|
||||
if not (codeptr->16 & $80) // Unresolved address list
|
||||
addrxlate=>[dest] = codeptr + 15 - *jitcodeptr
|
||||
codeptr=>10 = $0310 // BPL +3
|
||||
codeptr->12 = $4C // JMP abs
|
||||
codeptr=>13 = addrxlate=>[dest]
|
||||
if not (codeptr->14 & $80) // Unresolved address list
|
||||
addrxlate=>[dest] = codeptr + 13 - *jitcodeptr
|
||||
fin
|
||||
codeptr = codeptr + 17
|
||||
codeptr = codeptr + 5
|
||||
A_IS_TOS = FALSE
|
||||
break
|
||||
is $A2 // BRLT - FOR/NEXT SPECIFIC TEST & BRANCH
|
||||
@ -1005,14 +1004,13 @@ def compiler(defptr)#0
|
||||
codeptr=>3 = $0350 // BVC +3
|
||||
codeptr->5 = $49 // EOR #$8000
|
||||
codeptr=>6 = $8000
|
||||
codeptr=>8 = $0510 // BPL +5
|
||||
codeptr=>10 = $6868 // PLA; PLA
|
||||
codeptr->12 = $4C // JMP abs
|
||||
codeptr=>13 = addrxlate=>[dest]
|
||||
if not (codeptr->14 & $80) // Unresolved address list
|
||||
addrxlate=>[dest] = codeptr + 13 - *jitcodeptr
|
||||
codeptr=>8 = $0310 // BPL +3
|
||||
codeptr->10 = $4C // JMP abs
|
||||
codeptr=>11 = addrxlate=>[dest]
|
||||
if not (codeptr->12 & $80) // Unresolved address list
|
||||
addrxlate=>[dest] = codeptr + 11 - *jitcodeptr
|
||||
fin
|
||||
codeptr = codeptr + 15
|
||||
codeptr = codeptr + 13
|
||||
A_IS_TOS = FALSE
|
||||
break
|
||||
is $A4 // INCBRLE - FOR/NEXT SPECIFIC INC & TEST & BRANCH
|
||||
@ -1055,8 +1053,7 @@ def compiler(defptr)#0
|
||||
if not (codeptr->14 & $80) // Unresolved address list
|
||||
addrxlate=>[dest] = codeptr + 13 - *jitcodeptr
|
||||
fin
|
||||
codeptr=>15 = $6868 // PLA; PLA
|
||||
codeptr = codeptr + 17
|
||||
codeptr = codeptr + 15
|
||||
A_IS_TOS = FALSE
|
||||
break
|
||||
is $A8 // DECBRGR - FOR/NEXT SPECIFIC DEC & TEST & BRANCH
|
||||
@ -1100,8 +1097,7 @@ def compiler(defptr)#0
|
||||
if not (codeptr->12 & $80) // Unresolved address list
|
||||
addrxlate=>[dest] = codeptr + 11 - *jitcodeptr
|
||||
fin
|
||||
codeptr=>13 = $6868 // PLA; PLA
|
||||
codeptr = codeptr + 15
|
||||
codeptr = codeptr + 13
|
||||
A_IS_TOS = FALSE
|
||||
break
|
||||
is $AC // BRAND - LOGICAL AND SPECIFIC BRANCH
|
||||
|
@ -1172,14 +1172,13 @@ def compiler(defptr)#0
|
||||
codeptr=>6 = $C0F5//+(VX<<8) // SBC ESTKH
|
||||
codeptr=>8 = $0250 // BVC +2
|
||||
codeptr=>10 = $8049 // EOR #$80
|
||||
codeptr=>12 = $0510 // BPL +5
|
||||
codeptr=>14 = $E8E8 // INX; INX
|
||||
codeptr->16 = $4C // JMP abs
|
||||
codeptr=>17 = addrxlate=>[dest]
|
||||
if not (codeptr->18 & $80) // Unresolved address list
|
||||
addrxlate=>[dest] = codeptr + 17 - *jitcodeptr
|
||||
codeptr=>12 = $0310 // BPL +3
|
||||
codeptr->14 = $4C // JMP abs
|
||||
codeptr=>15 = addrxlate=>[dest]
|
||||
if not (codeptr->16 & $80) // Unresolved address list
|
||||
addrxlate=>[dest] = codeptr + 15 - *jitcodeptr
|
||||
fin
|
||||
codeptr = codeptr + 19
|
||||
codeptr = codeptr + 17
|
||||
A_IS_TOSL = FALSE
|
||||
break
|
||||
is $A2 // BRLT - FOR/NEXT SPECIFIC TEST & BRANCH
|
||||
@ -1200,14 +1199,13 @@ def compiler(defptr)#0
|
||||
codeptr=>4 = $C0F5+$0100//+(VX<<8) // SBC ESTKH+1
|
||||
codeptr=>6 = $0250 // BVC +2
|
||||
codeptr=>8 = $8049 // EOR #$80
|
||||
codeptr=>10 = $0510 // BPL +5
|
||||
codeptr=>12 = $E8E8 // INX; INX
|
||||
codeptr->14 = $4C // JMP abs
|
||||
codeptr=>15 = addrxlate=>[dest]
|
||||
if not (codeptr->16 & $80) // Unresolved address list
|
||||
addrxlate=>[dest] = codeptr + 15 - *jitcodeptr
|
||||
codeptr=>10 = $0310 // BPL +3
|
||||
codeptr->12 = $4C // JMP abs
|
||||
codeptr=>13 = addrxlate=>[dest]
|
||||
if not (codeptr->14 & $80) // Unresolved address list
|
||||
addrxlate=>[dest] = codeptr + 13 - *jitcodeptr
|
||||
fin
|
||||
codeptr = codeptr + 17
|
||||
codeptr = codeptr + 15
|
||||
A_IS_TOSL = FALSE
|
||||
break
|
||||
is $A4 // INCBRLE - FOR/NEXT SPECIFIC INC & TEST & BRANCH
|
||||
@ -1259,7 +1257,6 @@ def compiler(defptr)#0
|
||||
addrxlate=>[dest] = codeptr + 15 - *jitcodeptr
|
||||
fin
|
||||
codeptr = codeptr + 17
|
||||
VX = VX + 2 // INX; INX
|
||||
A_IS_TOSL = FALSE
|
||||
break
|
||||
is $A8 // DECBRGR - FOR/NEXT SPECIFIC DEC & TEST & BRANCH
|
||||
@ -1321,7 +1318,6 @@ def compiler(defptr)#0
|
||||
addrxlate=>[dest] = codeptr + 13 - *jitcodeptr
|
||||
fin
|
||||
codeptr = codeptr + 15
|
||||
VX = VX + 2 // INX; INX
|
||||
A_IS_TOSL = FALSE
|
||||
break
|
||||
is $AC // BRAND - LOGICAL AND SPECIFIC BRANCH
|
||||
|
@ -153,6 +153,26 @@ def emit_code(bval)#0
|
||||
codeptr++
|
||||
if codeptr - codebuff > codebufsz; exit_err(ERR_OVER|ERR_CODE|ERR_TABLE); fin
|
||||
end
|
||||
def emit_slb(offset)#0
|
||||
emit_pending_seq
|
||||
emit_byte($74)
|
||||
emit_byte(offset)
|
||||
end
|
||||
def emit_slw(offset)#0
|
||||
emit_pending_seq
|
||||
emit_byte($76)
|
||||
emit_byte(offset)
|
||||
end
|
||||
def emit_sab(tag, offset)#0
|
||||
emit_pending_seq
|
||||
emit_byte($78)
|
||||
emit_addr(tag, offset)
|
||||
end
|
||||
def emit_saw(tag, offset)#0
|
||||
emit_pending_seq
|
||||
emit_byte($7A)
|
||||
emit_addr(tag, offset)
|
||||
end
|
||||
def emit_dlb(offset)#0
|
||||
emit_pending_seq
|
||||
emit_byte($6C)
|
||||
|
@ -36,7 +36,9 @@
|
||||
// loop
|
||||
// chrptr = tknptr - 1
|
||||
// while keywrds[keypos] == tknlen
|
||||
// i = 1; while i <= tknlen and ^(chrptr + i) == keywrds[keypos + i]; i++; loop
|
||||
// for i = 1 to tknlen
|
||||
// if ^(chrptr + i) <> keywrds[keypos + i]; break; fin
|
||||
// next
|
||||
// if i > tknlen
|
||||
// return keywrds[keypos + keywrds[keypos] + 1]
|
||||
// fin
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
int parse_mods(void);
|
||||
|
||||
int infunc = 0, break_tag = 0, cont_tag = 0, stack_loop = 0, infor = 0;
|
||||
int infunc = 0, break_tag = 0, cont_tag = 0, stack_loop = 0;
|
||||
long infuncvals = 0;
|
||||
t_token prevstmnt;
|
||||
static int lambda_num = 0;
|
||||
@ -831,7 +831,7 @@ t_opseq *parse_set(t_opseq *codeseq)
|
||||
int parse_stmnt(void)
|
||||
{
|
||||
int tag_prevbrk, tag_prevcnt, tag_else, tag_endif, tag_while, tag_wend, tag_repeat, tag_for, tag_choice, tag_of;
|
||||
int type, addr, step, cfnvals, prev_for, constsize, casecnt, i;
|
||||
int type, addr, step, cfnvals, constsize, casecnt, i;
|
||||
int *caseval, *casetag;
|
||||
long constval;
|
||||
char *idptr;
|
||||
@ -891,8 +891,6 @@ int parse_stmnt(void)
|
||||
parse_error("Missing IF/FIN");
|
||||
break;
|
||||
case WHILE_TOKEN:
|
||||
prev_for = infor;
|
||||
infor = 0;
|
||||
tag_while = tag_new(BRANCH_TYPE);
|
||||
tag_wend = tag_new(BRANCH_TYPE);
|
||||
tag_prevcnt = cont_tag;
|
||||
@ -917,11 +915,8 @@ int parse_stmnt(void)
|
||||
emit_codetag(tag_wend);
|
||||
break_tag = tag_prevbrk;
|
||||
cont_tag = tag_prevcnt;
|
||||
infor = prev_for;
|
||||
break;
|
||||
case REPEAT_TOKEN:
|
||||
prev_for = infor;
|
||||
infor = 0;
|
||||
tag_prevbrk = break_tag;
|
||||
break_tag = tag_new(BRANCH_TYPE);
|
||||
tag_repeat = tag_new(BRANCH_TYPE);
|
||||
@ -945,12 +940,9 @@ int parse_stmnt(void)
|
||||
emit_seq(seq);
|
||||
emit_codetag(break_tag);
|
||||
break_tag = tag_prevbrk;
|
||||
infor = prev_for;
|
||||
break;
|
||||
case FOR_TOKEN:
|
||||
stack_loop += 2;
|
||||
prev_for = infor;
|
||||
infor = 1;
|
||||
tag_prevbrk = break_tag;
|
||||
break_tag = tag_new(BRANCH_TYPE);
|
||||
tag_for = tag_new(BRANCH_TYPE);
|
||||
@ -1029,13 +1021,15 @@ int parse_stmnt(void)
|
||||
emit_decbrge(tag_for);
|
||||
}
|
||||
emit_codetag(break_tag);
|
||||
if (type & LOCAL_TYPE)
|
||||
type & BYTE_TYPE ? emit_slb(addr) : emit_slw(addr);
|
||||
else
|
||||
type & BYTE_TYPE ? emit_sab(addr, 0, type) : emit_saw(addr, 0, type);
|
||||
emit_drop();
|
||||
break_tag = tag_prevbrk;
|
||||
infor = prev_for;
|
||||
stack_loop -= 2;
|
||||
break;
|
||||
case CASE_TOKEN:
|
||||
prev_for = infor;
|
||||
infor = 0;
|
||||
tag_prevbrk = break_tag;
|
||||
break_tag = tag_new(BRANCH_TYPE);
|
||||
tag_choice = tag_new(BRANCH_TYPE);
|
||||
@ -1111,15 +1105,10 @@ int parse_stmnt(void)
|
||||
free(casetag);
|
||||
emit_codetag(break_tag);
|
||||
break_tag = tag_prevbrk;
|
||||
infor = prev_for;
|
||||
break;
|
||||
case BREAK_TOKEN:
|
||||
if (break_tag)
|
||||
{
|
||||
if (infor)
|
||||
emit_drop2();
|
||||
emit_brnch(break_tag);
|
||||
}
|
||||
else
|
||||
parse_error("BREAK without loop");
|
||||
break;
|
||||
|
@ -596,7 +596,7 @@ def parse_set(codeseq)
|
||||
return codeseq
|
||||
end
|
||||
def parse_stmnt
|
||||
byte type, elem_type, elem_size, cfnvals, prev_for
|
||||
byte type, elem_type, elem_size, cfnvals
|
||||
word seq, fromseq, toseq, tag_prevbrk, tag_prevcnt, tag_else, tag_endif, tag_while, tag_wend
|
||||
word tag_repeat, tag_for, tag_choice, tag_of, idptr, addr, stepdir
|
||||
word caseconst, casecnt, caseval, casetag, i
|
||||
@ -650,8 +650,6 @@ def parse_stmnt
|
||||
if token <> FIN_TKN; exit_err(ERR_MISS|ERR_CLOSE|ERR_STATE); fin
|
||||
break
|
||||
is WHILE_TKN
|
||||
prev_for = infor
|
||||
infor = FALSE
|
||||
tag_while = new_tag(RELATIVE_FIXUP)
|
||||
tag_wend = new_tag(RELATIVE_FIXUP)
|
||||
tag_prevcnt = cont_tag
|
||||
@ -676,11 +674,8 @@ def parse_stmnt
|
||||
emit_tag(tag_wend)
|
||||
break_tag = tag_prevbrk
|
||||
cont_tag = tag_prevcnt
|
||||
infor = prev_for
|
||||
break
|
||||
is REPEAT_TKN
|
||||
prev_for = infor
|
||||
infor = FALSE
|
||||
tag_repeat = new_tag(RELATIVE_FIXUP)
|
||||
tag_prevbrk = break_tag
|
||||
break_tag = new_tag(RELATIVE_FIXUP)
|
||||
@ -704,11 +699,8 @@ def parse_stmnt
|
||||
emit_seq(seq)
|
||||
emit_tag(break_tag)
|
||||
break_tag = tag_prevbrk
|
||||
infor = prev_for
|
||||
break
|
||||
is FOR_TKN
|
||||
prev_for = infor
|
||||
infor = TRUE
|
||||
stack_loop = stack_loop + 2
|
||||
tag_for = new_tag(RELATIVE_FIXUP)
|
||||
tag_prevcnt = cont_tag
|
||||
@ -782,13 +774,16 @@ def parse_stmnt
|
||||
fin
|
||||
fin
|
||||
emit_tag(break_tag)
|
||||
if type & LOCAL_TYPE
|
||||
if type & BYTE_TYPE; emit_slb(addr); else; emit_slw(addr); fin
|
||||
else
|
||||
if type & BYTE_TYPE; emit_sab(addr, 0); else; emit_saw(addr, 0); fin
|
||||
fin
|
||||
emit_code(DROP_CODE)
|
||||
break_tag = tag_prevbrk
|
||||
stack_loop = stack_loop - 2
|
||||
infor = prev_for
|
||||
break
|
||||
is CASE_TKN
|
||||
prev_for = infor
|
||||
infor = FALSE
|
||||
tag_prevbrk = break_tag
|
||||
break_tag = new_tag(RELATIVE_FIXUP)
|
||||
tag_choice = new_tag(RELATIVE_FIXUP)
|
||||
@ -861,11 +856,9 @@ def parse_stmnt
|
||||
heaprelease(caseval)
|
||||
emit_tag(break_tag)
|
||||
break_tag = tag_prevbrk
|
||||
infor = prev_for
|
||||
break
|
||||
is BREAK_TKN
|
||||
if break_tag
|
||||
if infor; emit_code(DROP2_CODE); fin
|
||||
emit_branch(break_tag)
|
||||
else
|
||||
exit_err(ERR_INVAL|ERR_STATE)
|
||||
|
@ -298,7 +298,7 @@ const RVALUE = 1
|
||||
const LAMBDANUM = 16
|
||||
word strconstbuff
|
||||
word strconstptr
|
||||
byte infunc, inlambda, infor
|
||||
byte infunc, inlambda
|
||||
byte stack_loop
|
||||
byte prevstmnt
|
||||
word infuncvals
|
||||
|
@ -933,20 +933,16 @@ BRGT LDA ESTKL+1,X
|
||||
SBC ESTKH,X
|
||||
BVS +
|
||||
BPL NOBRNCH
|
||||
- INX ; DROP FOR VALUES
|
||||
INX
|
||||
BNE BRNCH ; BMI BRNCH
|
||||
BMI BRNCH
|
||||
BRLT LDA ESTKL,X
|
||||
CMP ESTKL+1,X
|
||||
LDA ESTKH,X
|
||||
SBC ESTKH+1,X
|
||||
BVS +
|
||||
BPL NOBRNCH
|
||||
INX ; DROP FOR VALUES
|
||||
INX
|
||||
BNE BRNCH ; BMI BRNCH
|
||||
BMI BRNCH
|
||||
+ BMI NOBRNCH
|
||||
BPL -
|
||||
BPL BRNCH
|
||||
DECBRGE DEC ESTKL,X
|
||||
LDA ESTKL,X
|
||||
CMP #$FF
|
||||
@ -958,9 +954,7 @@ _BRGE LDA ESTKL,X
|
||||
SBC ESTKH+1,X
|
||||
BVS +
|
||||
BPL BRNCH
|
||||
- INX ; DROP FOR VALUES
|
||||
INX
|
||||
BNE NOBRNCH ; BMI NOBRNCH
|
||||
BMI NOBRNCH
|
||||
INCBRLE INC ESTKL,X
|
||||
BNE _BRLE
|
||||
INC ESTKH,X
|
||||
@ -970,11 +964,9 @@ _BRLE LDA ESTKL+1,X
|
||||
SBC ESTKH,X
|
||||
BVS +
|
||||
BPL BRNCH
|
||||
INX ; DROP FOR VALUES
|
||||
INX
|
||||
BNE NOBRNCH ; BMI NOBRNCH
|
||||
BMI NOBRNCH
|
||||
+ BMI BRNCH
|
||||
BPL -
|
||||
BPL NOBRNCH
|
||||
SUBBRGE LDA ESTKL+1,X
|
||||
SEC
|
||||
SBC ESTKL,X
|
||||
|
@ -1298,20 +1298,16 @@ BRGT LDA ESTKL+1,X
|
||||
SBC ESTKH,X
|
||||
BVS +
|
||||
BPL NOBRNCH
|
||||
- INX ; DROP FOR VALUES
|
||||
INX
|
||||
BNE BRNCH ; BMI BRNCH
|
||||
BMI BRNCH
|
||||
BRLT LDA ESTKL,X
|
||||
CMP ESTKL+1,X
|
||||
LDA ESTKH,X
|
||||
SBC ESTKH+1,X
|
||||
BVS +
|
||||
BPL NOBRNCH
|
||||
INX ; DROP FOR VALUES
|
||||
INX
|
||||
BNE BRNCH ; BMI BRNCH
|
||||
BMI BRNCH
|
||||
+ BMI NOBRNCH
|
||||
BPL -
|
||||
BPL BRNCH
|
||||
DECBRGE DEC ESTKL,X
|
||||
LDA ESTKL,X
|
||||
CMP #$FF
|
||||
@ -1323,9 +1319,7 @@ _BRGE LDA ESTKL,X
|
||||
SBC ESTKH+1,X
|
||||
BVS +
|
||||
BPL BRNCH
|
||||
- INX ; DROP FOR VALUES
|
||||
INX
|
||||
BNE NOBRNCH ; BMI NOBRNCH
|
||||
BMI NOBRNCH
|
||||
INCBRLE INC ESTKL,X
|
||||
BNE _BRLE
|
||||
INC ESTKH,X
|
||||
@ -1335,11 +1329,9 @@ _BRLE LDA ESTKL+1,X
|
||||
SBC ESTKH,X
|
||||
BVS +
|
||||
BPL BRNCH
|
||||
INX ; DROP FOR VALUES
|
||||
INX
|
||||
BNE NOBRNCH ; BMI NOBRNCH
|
||||
BMI NOBRNCH
|
||||
+ BMI BRNCH
|
||||
BPL -
|
||||
BPL NOBRNCH
|
||||
SUBBRGE LDA ESTKL+1,X
|
||||
SEC
|
||||
SBC ESTKL,X
|
||||
|
@ -1262,32 +1262,16 @@ BRGT LDA ESTKL+1,X
|
||||
CMP ESTKL,X
|
||||
LDA ESTKH+1,X
|
||||
SBC ESTKH,X
|
||||
BVS +
|
||||
BPL NOBRNCH
|
||||
- INX ; DROP FOR VALUES
|
||||
INX
|
||||
BNE BRNCH ; BMI BRNCH
|
||||
BVS ++
|
||||
- BPL NOBRNCH
|
||||
BMI BRNCH
|
||||
BRLT LDA ESTKL,X
|
||||
CMP ESTKL+1,X
|
||||
LDA ESTKH,X
|
||||
SBC ESTKH+1,X
|
||||
BVS +
|
||||
BVS ++
|
||||
BPL NOBRNCH
|
||||
BMI -
|
||||
+ BMI NOBRNCH
|
||||
BPL -
|
||||
INCBRLE INC ESTKL,X
|
||||
BNE _BRLE
|
||||
INC ESTKH,X
|
||||
_BRLE LDA ESTKL+1,X
|
||||
CMP ESTKL,X
|
||||
LDA ESTKH+1,X
|
||||
SBC ESTKH,X
|
||||
BVS +
|
||||
BPL BRNCH
|
||||
- INX ; DROP FOR VALUES
|
||||
INX
|
||||
BNE NOBRNCH ; BMI NOBRNCH
|
||||
BMI BRNCH
|
||||
DECBRGE DEC ESTKL,X
|
||||
LDA ESTKL,X
|
||||
CMP #$FF
|
||||
@ -1297,11 +1281,19 @@ _BRGE LDA ESTKL,X
|
||||
+ CMP ESTKL+1,X
|
||||
LDA ESTKH,X
|
||||
SBC ESTKH+1,X
|
||||
BVS +
|
||||
BVS -
|
||||
BPL BRNCH
|
||||
BMI -
|
||||
+ BMI BRNCH
|
||||
BPL -
|
||||
BMI NOBRNCH
|
||||
INCBRLE INC ESTKL,X
|
||||
BNE _BRLE
|
||||
INC ESTKH,X
|
||||
_BRLE LDA ESTKL+1,X
|
||||
CMP ESTKL,X
|
||||
LDA ESTKH+1,X
|
||||
SBC ESTKH,X
|
||||
BVS -
|
||||
++ BPL BRNCH
|
||||
BMI NOBRNCH
|
||||
SUBBRGE LDA ESTKL+1,X
|
||||
SEC
|
||||
SBC ESTKL,X
|
||||
|
@ -1543,21 +1543,15 @@ BRGT LDA NOS,S
|
||||
SBC TOS,S
|
||||
BVS +
|
||||
BPL NOBRNCH
|
||||
PLA ; DROP FOR VALUES
|
||||
PLA
|
||||
BRA BRNCH ; BMI BRNCH
|
||||
BMI BRNCH
|
||||
BRLT LDA TOS,S
|
||||
SEC
|
||||
SBC NOS,S
|
||||
BVS +
|
||||
BPL NOBRNCH
|
||||
PLA ; DROP FOR VALUES
|
||||
PLA
|
||||
BRA BRNCH ; BMI BRNCH
|
||||
BMI BRNCH
|
||||
+ BMI NOBRNCH
|
||||
PLA ; DROP FOR VALUES
|
||||
PLA
|
||||
BRA BRNCH ; BMI BRNCH
|
||||
BPL BRNCH
|
||||
DECBRGE PLA
|
||||
DEC
|
||||
PHA
|
||||
@ -1566,9 +1560,7 @@ _BRGE LDA TOS,S
|
||||
SBC NOS,S
|
||||
BVS +
|
||||
BPL BRNCH
|
||||
PLA ; DROP FOR VALUES
|
||||
PLA
|
||||
BRA NOBRNCH ; BMI NOBRNCH
|
||||
BMI NOBRNCH
|
||||
INCBRLE PLA
|
||||
INC
|
||||
PHA
|
||||
@ -1577,13 +1569,9 @@ _BRLE LDA NOS,S
|
||||
SBC TOS,S
|
||||
BVS +
|
||||
BPL BRNCH
|
||||
PLA ; DROP FOR VALUES
|
||||
PLA
|
||||
BRA NOBRNCH ; BMI NOBRNCH
|
||||
BMI NOBRNCH
|
||||
+ BMI BRNCH
|
||||
PLA ; DROP FOR VALUES
|
||||
PLA
|
||||
BRA NOBRNCH ; BMI NOBRNCH
|
||||
BPL NOBRNCH
|
||||
SUBBRGE LDA NOS,S
|
||||
SEC
|
||||
SBC TOS,S
|
||||
|
@ -1770,20 +1770,16 @@ BRGT LDA ESTKL+1,X
|
||||
SBC ESTKH,X
|
||||
BVS +
|
||||
BPL NOBRNCH
|
||||
- INX ; DROP FOR VALUES
|
||||
INX
|
||||
BNE BRNCH ; BMI BRNCH
|
||||
BMI BRNCH
|
||||
BRLT LDA ESTKL,X
|
||||
CMP ESTKL+1,X
|
||||
LDA ESTKH,X
|
||||
SBC ESTKH+1,X
|
||||
BVS +
|
||||
BPL NOBRNCH
|
||||
INX ; DROP FOR VALUES
|
||||
INX
|
||||
BNE BRNCH ; BMI BRNCH
|
||||
BMI BRNCH
|
||||
+ BMI NOBRNCH
|
||||
BPL -
|
||||
BPL BRNCH
|
||||
DECBRGE DEC ESTKL,X
|
||||
LDA ESTKL,X
|
||||
CMP #$FF
|
||||
@ -1795,9 +1791,7 @@ _BRGE LDA ESTKL,X
|
||||
SBC ESTKH+1,X
|
||||
BVS +
|
||||
BPL BRNCH
|
||||
- INX ; DROP FOR VALUES
|
||||
INX
|
||||
BNE NOBRNCH ; BMI NOBRNCH
|
||||
BMI NOBRNCH
|
||||
INCBRLE INC ESTKL,X
|
||||
BNE _BRLE
|
||||
INC ESTKH,X
|
||||
@ -1807,11 +1801,9 @@ _BRLE LDA ESTKL+1,X
|
||||
SBC ESTKH,X
|
||||
BVS +
|
||||
BPL BRNCH
|
||||
INX ; DROP FOR VALUES
|
||||
INX
|
||||
BNE NOBRNCH ; BMI NOBRNCH
|
||||
BMI NOBRNCH
|
||||
+ BMI BRNCH
|
||||
BPL -
|
||||
BPL NOBRNCH
|
||||
SUBBRGE LDA ESTKL+1,X
|
||||
SEC
|
||||
SBC ESTKL,X
|
||||
|
@ -1047,20 +1047,16 @@ BRGT LDA ESTKL+1,X
|
||||
SBC ESTKH,X
|
||||
BVS +
|
||||
BPL NOBRNCH
|
||||
- INX ; DROP FOR VALUES
|
||||
INX
|
||||
BNE BRNCH ; BMI BRNCH
|
||||
BMI BRNCH
|
||||
BRLT LDA ESTKL,X
|
||||
CMP ESTKL+1,X
|
||||
LDA ESTKH,X
|
||||
SBC ESTKH+1,X
|
||||
BVS +
|
||||
BPL NOBRNCH
|
||||
INX ; DROP FOR VALUES
|
||||
INX
|
||||
BNE BRNCH ; BMI BRNCH
|
||||
BMI BRNCH
|
||||
+ BMI NOBRNCH
|
||||
BPL -
|
||||
BPL BRNCH
|
||||
DECBRGE DEC ESTKL,X
|
||||
LDA ESTKL,X
|
||||
CMP #$FF
|
||||
@ -1072,9 +1068,7 @@ _BRGE LDA ESTKL,X
|
||||
SBC ESTKH+1,X
|
||||
BVS +
|
||||
BPL BRNCH
|
||||
- INX ; DROP FOR VALUES
|
||||
INX
|
||||
BNE NOBRNCH ; BMI NOBRNCH
|
||||
BMI NOBRNCH
|
||||
INCBRLE INC ESTKL,X
|
||||
BNE _BRLE
|
||||
INC ESTKH,X
|
||||
@ -1084,11 +1078,9 @@ _BRLE LDA ESTKL+1,X
|
||||
SBC ESTKH,X
|
||||
BVS +
|
||||
BPL BRNCH
|
||||
INX ; DROP FOR VALUES
|
||||
INX
|
||||
BNE NOBRNCH ; BMI NOBRNCH
|
||||
BMI NOBRNCH
|
||||
+ BMI BRNCH
|
||||
BPL -
|
||||
BPL NOBRNCH
|
||||
SUBBRGE LDA ESTKL+1,X
|
||||
SEC
|
||||
SBC ESTKL,X
|
||||
|
Loading…
x
Reference in New Issue
Block a user