projekt pk_os_go
This commit is contained in:
parent
5577560640
commit
decc8f3324
16 changed files with 70 additions and 126 deletions
|
|
@ -1,8 +1,7 @@
|
|||
arith START 0
|
||||
LDA x
|
||||
ADD y
|
||||
arith START 0
|
||||
LDA x
|
||||
ADD y
|
||||
STA sum
|
||||
|
||||
LDA x
|
||||
SUB y
|
||||
STA diff
|
||||
|
|
|
|||
|
|
@ -1,7 +0,0 @@
|
|||
package code
|
||||
|
||||
type program struct {
|
||||
name string
|
||||
instruction_list
|
||||
lc uint32
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
package comment
|
||||
|
||||
type Comment struct {
|
||||
value string
|
||||
}
|
||||
|
||||
func newComment(val string) Comment {
|
||||
return Comment {
|
||||
value: val
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
package instruction
|
||||
|
||||
type Instruction interface {
|
||||
newInstruction() Instruction
|
||||
}
|
||||
|
||||
|
||||
func newInstruction() {}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
package instructionF1
|
||||
|
||||
type InstructionF1 struct {
|
||||
opcode uint8
|
||||
}
|
||||
|
||||
func newInstructionF1(opcode uint8) InstructionF1 {
|
||||
return InstructionF1 {
|
||||
opcode: opcode
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
package instructionF2
|
||||
|
||||
type InstructionF2 struct {
|
||||
opcode uint8
|
||||
r1 uint8
|
||||
r2 uint8
|
||||
}
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
package instructionF3
|
||||
|
||||
type InstructionF3 struct {
|
||||
opcode uint8
|
||||
n bool
|
||||
i bool
|
||||
x bool
|
||||
b bool
|
||||
p bool
|
||||
e bool
|
||||
offset uint16
|
||||
}
|
||||
|
||||
func newInstructionF3(opcode uint8, n bool, i bool, x bool, b bool, p bool, e bool, offset uint16) InstructionF3 {
|
||||
return InstructionF3{
|
||||
opcode: opcode,
|
||||
n: n,
|
||||
i: i,
|
||||
x: x,
|
||||
b: b,
|
||||
p: p,
|
||||
e: e,
|
||||
offset: offset
|
||||
}
|
||||
}
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
package instructionF4
|
||||
|
||||
type InstructionF4 struct {
|
||||
opcode uint8,
|
||||
n bool,
|
||||
i bool,
|
||||
x bool,
|
||||
b bool,
|
||||
p bool,
|
||||
e bool,
|
||||
offset uint32
|
||||
}
|
||||
|
||||
func newInstructionF4(opcode uint8, n bool, i bool, x bool, b bool, p bool, e bool, offset uint32) InstructionF4 {
|
||||
return InstructionF4{
|
||||
opcode: opcode,
|
||||
n: n,
|
||||
i: i,
|
||||
x: x,
|
||||
b: b,
|
||||
p: p,
|
||||
e: e,
|
||||
offset: offset
|
||||
}
|
||||
}
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
package instructionSIC
|
||||
|
||||
type InstructionSIC struct {
|
||||
opcode uint8
|
||||
n bool
|
||||
i bool
|
||||
x bool
|
||||
b bool
|
||||
p bool
|
||||
e bool
|
||||
offset uint16
|
||||
}
|
||||
|
||||
func newInstructionSIC(opcode uint8, n bool, i bool, x bool, b bool, p bool, e bool, offset uint16) InstructionSIC {
|
||||
return InstructionSIC{
|
||||
opcode: opcode,
|
||||
n: n,
|
||||
i: i,
|
||||
x: x,
|
||||
b: b,
|
||||
p: p,
|
||||
e: e,
|
||||
offset: offset
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
arithr START 0 .komentar1
|
||||
LDX #10
|
||||
SHIFTR A, 10, X
|
||||
LDS #11 .komentar2
|
||||
LDT #5
|
||||
|
|
|
|||
|
|
@ -125,6 +125,22 @@ type format_F2_rr struct {
|
|||
r2 string
|
||||
}
|
||||
|
||||
type format_F3 struct {
|
||||
oznaka string
|
||||
opcode int
|
||||
format int
|
||||
velikost int
|
||||
}
|
||||
|
||||
type format_F3_m struct {
|
||||
oznaka string
|
||||
opcode int
|
||||
format int
|
||||
velikost int
|
||||
naslov string
|
||||
x bool
|
||||
}
|
||||
|
||||
func remove_comments_and_empty_lines(el string) bool {
|
||||
match_pure_comment, err := regexp.MatchString(`(?m)^[\t ]*\..*$\n`, el)
|
||||
if err != nil {
|
||||
|
|
@ -187,7 +203,7 @@ func check_F2_n(el string, AST *[]ukaz) bool {
|
|||
nov_ukaz.x = false
|
||||
nov_ukaz.n = temp
|
||||
}
|
||||
fmt.Println("F2_n ", el[:len(el) - 1], nov_ukaz)
|
||||
//fmt.Println("F2_n ", el[:len(el) - 1], nov_ukaz)
|
||||
*AST = append(*AST, nov_ukaz)
|
||||
return true
|
||||
}
|
||||
|
|
@ -248,7 +264,7 @@ func check_F2_rn(el string, AST *[]ukaz) bool {
|
|||
nov_ukaz.x = false
|
||||
nov_ukaz.n = temp
|
||||
}
|
||||
fmt.Println("F2_rn: ", el[:len(el) - 1], nov_ukaz)
|
||||
//fmt.Println("F2_rn: ", el[:len(el) - 1], nov_ukaz)
|
||||
*AST = append(*AST, nov_ukaz)
|
||||
return true
|
||||
}
|
||||
|
|
@ -305,6 +321,7 @@ func main() {
|
|||
if check_F1(el, &AST) {
|
||||
continue
|
||||
}
|
||||
// TODO !!! odstrani # in @ in x naslalvljaje od F2 formata, saj nima bitov, da to podpre
|
||||
if check_F2_n(el, &AST) {
|
||||
continue
|
||||
}
|
||||
|
|
|
|||
47
pk_os_go/g4.go
Normal file
47
pk_os_go/g4.go
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"runtime"
|
||||
"runtime/trace"
|
||||
"time"
|
||||
debug "runtime/debug"
|
||||
)
|
||||
|
||||
func child(c chan string) {
|
||||
for msg := range c {
|
||||
c <- msg
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
f, err := os.Create("trace.out")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
if err := trace.Start(f); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer trace.Stop()
|
||||
|
||||
runtime.GOMAXPROCS(1)
|
||||
debug.SetGCPercent(-1)
|
||||
|
||||
c := make(chan string)
|
||||
go child(c)
|
||||
|
||||
const niters = 2000000
|
||||
for i := 0; i < niters; i++ {
|
||||
c <- "test"
|
||||
reply := <-c
|
||||
if len(reply) != 4 {
|
||||
panic("err")
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Println("done")
|
||||
time.Sleep(1 * time.Second)
|
||||
}
|
||||
BIN
pk_os_go/pk_os_go.pptx
Normal file
BIN
pk_os_go/pk_os_go.pptx
Normal file
Binary file not shown.
BIN
pk_os_go/porocilo.pdf
Normal file
BIN
pk_os_go/porocilo.pdf
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue