ch
This commit is contained in:
parent
3856635345
commit
1055ccd52f
6 changed files with 112 additions and 13 deletions
|
|
@ -1,8 +1,15 @@
|
||||||
arithr START 0 .komentar1
|
arithr START 0 .komentar1
|
||||||
+LDX #10
|
LDX #10
|
||||||
SHIFTR A, 10, X
|
SHIFTR A, 10, X
|
||||||
+LDS #11 .komentar2
|
LDS #11 .komentar2
|
||||||
LDT #5
|
LDT #5
|
||||||
|
NOBASE .koment
|
||||||
|
NOBASE
|
||||||
|
BASE ZERO .KOMENTAR
|
||||||
|
ORG tab-tab
|
||||||
|
LAB NOBASE
|
||||||
|
EQU
|
||||||
|
LAB NOBASE .koment
|
||||||
.komentar3
|
.komentar3
|
||||||
LDA ZERO
|
LDA ZERO
|
||||||
ADDR S, A
|
ADDR S, A
|
||||||
|
|
@ -11,9 +18,7 @@ arithr START 0 .komentar1
|
||||||
|
|
||||||
.komentar4
|
.komentar4
|
||||||
LDA ZERO
|
LDA ZERO
|
||||||
+LDA ZERO, X .test
|
|
||||||
ADDR S, A
|
ADDR S, A
|
||||||
LDA 123, X . kom
|
|
||||||
SUBR T, A
|
SUBR T, A
|
||||||
STA diff
|
STA diff
|
||||||
|
|
||||||
|
|
@ -22,7 +27,7 @@ arithr START 0 .komentar1
|
||||||
MULR T, A
|
MULR T, A
|
||||||
STA prod
|
STA prod
|
||||||
|
|
||||||
+LDA ZERO
|
LDA ZERO
|
||||||
ADDR S, A
|
ADDR S, A
|
||||||
DIVR T, A
|
DIVR T, A
|
||||||
STA quot
|
STA quot
|
||||||
|
|
|
||||||
|
|
@ -158,12 +158,14 @@ type format_F4_m struct {
|
||||||
|
|
||||||
type format_D struct {
|
type format_D struct {
|
||||||
oznaka string
|
oznaka string
|
||||||
|
ime string //NOBASE
|
||||||
format int // 6
|
format int // 6
|
||||||
velikost int
|
velikost int
|
||||||
}
|
}
|
||||||
|
|
||||||
type format_D_n struct {
|
type format_D_n struct {
|
||||||
oznaka string
|
oznaka string
|
||||||
|
ime string
|
||||||
format int // 7
|
format int // 7
|
||||||
velikost int
|
velikost int
|
||||||
operand string
|
operand string
|
||||||
|
|
@ -171,6 +173,7 @@ type format_D_n struct {
|
||||||
|
|
||||||
type format_M_r struct {
|
type format_M_r struct {
|
||||||
oznaka string
|
oznaka string
|
||||||
|
ime string
|
||||||
format int // 8
|
format int // 8
|
||||||
velikost int
|
velikost int
|
||||||
operand string
|
operand string
|
||||||
|
|
@ -178,6 +181,7 @@ type format_M_r struct {
|
||||||
|
|
||||||
type format_M_i struct {
|
type format_M_i struct {
|
||||||
oznaka string
|
oznaka string
|
||||||
|
ime string
|
||||||
format int // 9
|
format int // 9
|
||||||
velikost int
|
velikost int
|
||||||
operand string
|
operand string
|
||||||
|
|
@ -456,27 +460,73 @@ func check_F4_m(el string, AST *[]ukaz) bool {
|
||||||
nov_ukaz.x = false
|
nov_ukaz.x = false
|
||||||
}
|
}
|
||||||
nov_ukaz.e = true
|
nov_ukaz.e = true
|
||||||
fmt.Println(el, nov_ukaz)
|
//fmt.Println(el, nov_ukaz)
|
||||||
*AST = append(*AST, nov_ukaz)
|
*AST = append(*AST, nov_ukaz)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func check_D(el string, AST *[]ukaz) {
|
func check_D(el string, AST *[]ukaz) bool {
|
||||||
match_D, err := regexp.MatchString(`(?m)^[A-Za-z_]*[\t ]+NOBASE[\t ]*(\..*)?$\n`, el)
|
match_D, err := regexp.MatchString(`(?m)^[A-Za-z_]*[\t ]+NOBASE[\t ]*(\..*)?$\n`, el)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Error while matching string.")
|
fmt.Println("Error while matching string.")
|
||||||
}
|
}
|
||||||
if match_D {
|
if match_D {
|
||||||
var nova_direktiva format_D
|
var nova_direktiva format_D
|
||||||
|
nova_direktiva.ime = "NOBASE"
|
||||||
|
nova_direktiva.format = 6
|
||||||
|
nova_direktiva.velikost = 0
|
||||||
if !(strings.HasPrefix(el, " ") || strings.HasPrefix(el, "\t")) {
|
if !(strings.HasPrefix(el, " ") || strings.HasPrefix(el, "\t")) {
|
||||||
re := regexp.MustCompile(`(?m)^[A-Za-z]+`)
|
re := regexp.MustCompile(`(?m)^[A-Za-z]+`)
|
||||||
nov_direktiva.oznaka = re.FindString(el)
|
nova_direktiva.oznaka = re.FindString(el)
|
||||||
} else {
|
} else {
|
||||||
nov_direktiva.oznaka = ""
|
nova_direktiva.oznaka = ""
|
||||||
}
|
}
|
||||||
*AST = append(*AST, nova_direktiva)
|
*AST = append(*AST, nova_direktiva)
|
||||||
|
//fmt.Println(el, nova_direktiva)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func check_D_n(el string, AST *[]ukaz) bool {
|
||||||
|
match_D_n, err := regexp.MatchString(`(?m)^[A-Za-z]*[\t ]+(START|END|ORG|EQU|BASE) ([A-Za-z\+\-\*]+|[0-9\+\-\*]+)[\t ]*(\..*)?$\n`, el)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Error while matching string.")
|
||||||
|
}
|
||||||
|
if match_D_n {
|
||||||
|
var nova_direktiva format_D_n
|
||||||
|
re_ime := regexp.MustCompile(`START|END|ORG|EQU|BASE`)
|
||||||
|
nova_direktiva.ime = re_ime.FindString(el)
|
||||||
|
nova_direktiva.format = 7
|
||||||
|
nova_direktiva.velikost = 0
|
||||||
|
if !(strings.HasPrefix(el, " ") || strings.HasPrefix(el, "\t")) {
|
||||||
|
re := regexp.MustCompile(`(?m)^[A-Za-z]+`)
|
||||||
|
nova_direktiva.oznaka = re.FindString(el)
|
||||||
|
} else {
|
||||||
|
nova_direktiva.oznaka = ""
|
||||||
|
}
|
||||||
|
re_ope := regexp.MustCompile(`(START|END|ORG|EQU|BASE) ([A-Za-z\+\-\*]+|[0-9\+\-\*]+)`)
|
||||||
|
nova_direktiva.operand = strings.Split(re_ope.FindString(el), " ")[1]
|
||||||
|
*AST = append(*AST, nova_direktiva)
|
||||||
|
//fmt.Println(el, nova_direktiva)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func check_M_r(el string, AST *[]ukaz) bool {
|
||||||
|
match_M_r, err := regexp.MatchString(`(?m)^[A-Za-z]*[\t ]+(RESW|RESB) ([0-9]+)[\t ]*(\..*)?$\n`, el)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Error while matching string.")
|
||||||
|
}
|
||||||
|
if match_M_r {
|
||||||
|
var nova_direktiva format_D_n
|
||||||
|
re_ime := regexp.MustCompile(`RESW|RESB`)
|
||||||
|
nova_direktiva.ime = re_ime.FindString(el)
|
||||||
|
nova_direktiva.format = 8
|
||||||
|
//predpostavi celostevilski operand in doloci velikost
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
|
@ -504,6 +554,12 @@ func main() {
|
||||||
if check_D(el, &AST) {
|
if check_D(el, &AST) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if check_D_n(el, &AST) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if check_M_r(el, &AST) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
if check_F1(el, &AST) {
|
if check_F1(el, &AST) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
@ -519,7 +575,6 @@ func main() {
|
||||||
if check_F2_rr(el, &AST) {
|
if check_F2_rr(el, &AST) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// !!! direktivo START je treba preveriti pred F3, sicer jo bo dalo sem
|
|
||||||
if check_F3_m(el, &AST) {
|
if check_F3_m(el, &AST) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@ PRG START 300
|
||||||
LDA #bytes_len
|
LDA #bytes_len
|
||||||
DIV #3
|
DIV #3
|
||||||
LDA bytes_len
|
LDA bytes_len
|
||||||
LDB #tab
|
LDB tab
|
||||||
BASE #tab
|
BASE tab
|
||||||
NOBASE
|
NOBASE
|
||||||
HALT J HALT
|
HALT J HALT
|
||||||
END PRG
|
END PRG
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
***** Section <default> *****
|
||||||
|
Stats: size=29 blocks=29 symbols=7 literals=0 relocations=0
|
||||||
|
Blocks
|
||||||
|
name start size #ins #dir #sto
|
||||||
|
<default> 0012C 0001D 5 10 1
|
||||||
|
Symbols
|
||||||
|
name hex dec scope kind type description
|
||||||
|
HALT 000138 312 local relative code label
|
||||||
|
PRG 00012C 300 exported relative code label
|
||||||
|
bytes_len 000009 9 local absolute notlabel test-tab
|
||||||
|
tab 00013D 317 local relative data label
|
||||||
|
tab0 00013B 315 local relative data label
|
||||||
|
tab2 000146 326 local relative data label
|
||||||
|
test 000146 326 local absolute notlabel *
|
||||||
|
Literals
|
||||||
|
label definition
|
||||||
|
Relocations
|
||||||
|
address length flag symbol
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
0012C PRG START 300
|
||||||
|
0012C 010009 LDA #bytes_len
|
||||||
|
0012F 250003 DIV #3
|
||||||
|
00132 030009 LDA bytes_len
|
||||||
|
00135 6B2005 LDB tab
|
||||||
|
00135 BASE tab
|
||||||
|
00135 NOBASE
|
||||||
|
00138 3F2FFD HALT J HALT
|
||||||
|
0013B END PRG
|
||||||
|
|
||||||
|
0013B 0000 tab0 RESB 2
|
||||||
|
0013D 000001 tab WORD 1
|
||||||
|
00140 000002 WORD 2
|
||||||
|
00143 000003 WORD 3
|
||||||
|
00146 test EQU *
|
||||||
|
00146 bytes_len EQU test-tab
|
||||||
|
00146 000001 tab2 WORD 1
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
HPRG 00012C00001D
|
||||||
|
T00012C0F0100092500030300096B20053F2FFD
|
||||||
|
T00013D0C000001000002000003000001
|
||||||
|
E00012C
|
||||||
Loading…
Add table
Add a link
Reference in a new issue