Object subclass: #CometDecoder instanceVariableNames: 'opcodes oprands opHighs' classVariableNames: '' poolDictionaries: '' category: 'Comet-Base'! !CometDecoder methodsFor: 'initialization' stamp: 'e-itoh 10/26/2007 23:17'! addOpcode: aSymbol1 oprands: aSymbol2 as: aNumber1 | d | opcodes at: aNumber1 put: aSymbol1. oprands at: aNumber1 put: aSymbol2. d := opHighs at: aSymbol2 ifAbsentPut: [Dictionary new]. d at: aSymbol1 put: aNumber1! ! !CometDecoder methodsFor: 'initialization' stamp: 'e-itoh 10/26/2007 23:17'! initialize opcodes := Dictionary new. oprands := Dictionary new. opHighs := Dictionary new. self setupOpcodes! ! !CometDecoder methodsFor: 'initialization' stamp: 'e-itoh 10/24/2007 20:26'! setupOpcodes self addOpcode: #nop: oprands: #CometOprand as: 0. self addOpcode: #ld: oprands: #CometOprandRadrX as: 16. self addOpcode: #st: oprands: #CometOprandRadrX as: 17. self addOpcode: #lad: oprands: #CometOprandRadrX as: 18. self addOpcode: #ld: oprands: #CometOprandRR as: 20. self addOpcode: #adda: oprands: #CometOprandRadrX as: 32. self addOpcode: #suba: oprands: #CometOprandRadrX as: 33. self addOpcode: #addl: oprands: #CometOprandRadrX as: 34. self addOpcode: #subl: oprands: #CometOprandRadrX as: 35. self addOpcode: #adda: oprands: #CometOprandRR as: 36. self addOpcode: #suba: oprands: #CometOprandRR as: 37. self addOpcode: #addl: oprands: #CometOprandRR as: 38. self addOpcode: #subl: oprands: #CometOprandRR as: 39. self addOpcode: #and: oprands: #CometOprandRadrX as: 48. self addOpcode: #or: oprands: #CometOprandRadrX as: 49. self addOpcode: #xor: oprands: #CometOprandRadrX as: 50. self addOpcode: #and: oprands: #CometOprandRR as: 52. self addOpcode: #or: oprands: #CometOprandRR as: 53. self addOpcode: #xor: oprands: #CometOprandRR as: 54. self addOpcode: #cpa: oprands: #CometOprandRadrX as: 64. self addOpcode: #cpl: oprands: #CometOprandRadrX as: 65. self addOpcode: #cpa: oprands: #CometOprandRR as: 68. self addOpcode: #cpl: oprands: #CometOprandRR as: 69. self addOpcode: #sla: oprands: #CometOprandRadrX as: 80. self addOpcode: #sra: oprands: #CometOprandRadrX as: 81. self addOpcode: #sll: oprands: #CometOprandRadrX as: 82. self addOpcode: #srl: oprands: #CometOprandRadrX as: 83. self addOpcode: #jmi: oprands: #CometOprandAdrX as: 97. self addOpcode: #jnz: oprands: #CometOprandAdrX as: 98. self addOpcode: #jze: oprands: #CometOprandAdrX as: 99. self addOpcode: #jump: oprands: #CometOprandAdrX as: 100. self addOpcode: #jpl: oprands: #CometOprandAdrX as: 101. self addOpcode: #jov: oprands: #CometOprandAdrX as: 102. self addOpcode: #push: oprands: #CometOprandAdrX as: 112. self addOpcode: #pop: oprands: #CometOprandR as: 113. self addOpcode: #call: oprands: #CometOprandAdrX as: 128. self addOpcode: #ret: oprands: #CometOprand as: 129. self addOpcode: #svc: oprands: #CometOprandAdrX as: 240! ! !CometDecoder methodsFor: 'accessing' stamp: 'e-itoh 10/29/2007 22:23'! opcodeOf: aNumber | op | op := aNumber bitShift: -8. ^ opcodes at: op ifAbsent: #dc:! ! !CometDecoder methodsFor: 'accessing' stamp: 'e-itoh 10/31/2007 22:19'! opHighOfOpcode: aSymbol1 oprand: aSymbol2 ^ (opHighs at: aSymbol2) at: aSymbol1 ifAbsent: []! ! !CometDecoder methodsFor: 'accessing' stamp: 'e-itoh 10/24/2007 22:11'! oprandClassOf: aNumber | op | op := aNumber bitShift: -8. ^ Smalltalk at: (oprands at: op)! ! Object subclass: #CometFlag instanceVariableNames: 'of sf zf' classVariableNames: '' poolDictionaries: '' category: 'Comet-Base'! !CometFlag methodsFor: 'testing' stamp: 'e-itoh 10/20/2007 21:49'! isMinus ^ sf! ! !CometFlag methodsFor: 'testing' stamp: 'e-itoh 10/20/2007 21:50'! isNonZero ^ zf not! ! !CometFlag methodsFor: 'testing' stamp: 'e-itoh 10/20/2007 21:50'! isOverflow ^ of! ! !CometFlag methodsFor: 'testing' stamp: 'e-itoh 10/20/2007 21:49'! isPlus ^ sf not and: [zf not]! ! !CometFlag methodsFor: 'testing' stamp: 'e-itoh 10/20/2007 21:50'! isZero ^ zf! ! !CometFlag methodsFor: 'accessing' stamp: 'e-itoh 10/19/2007 23:31'! of ^ of! ! !CometFlag methodsFor: 'accessing' stamp: 'e-itoh 10/19/2007 23:31'! of: aBoolean of := aBoolean! ! !CometFlag methodsFor: 'accessing' stamp: 'e-itoh 10/19/2007 23:31'! sf ^ sf! ! !CometFlag methodsFor: 'accessing' stamp: 'e-itoh 10/19/2007 23:31'! sf: aBoolean sf := aBoolean! ! !CometFlag methodsFor: 'accessing' stamp: 'e-itoh 10/20/2007 00:16'! updateZfSf: aNumber zf := aNumber = 0. sf := (aNumber bitAnd: 32768) ~= 0! ! !CometFlag methodsFor: 'accessing' stamp: 'e-itoh 10/19/2007 23:31'! zf ^ zf! ! !CometFlag methodsFor: 'accessing' stamp: 'e-itoh 10/19/2007 23:31'! zf: aBoolean zf := aBoolean! ! !CometFlag methodsFor: 'printing' stamp: 'e-itoh 10/24/2007 21:15'! printOn: aStream aStream nextPutAll: ''! ! Object subclass: #CometMachine instanceVariableNames: 'decoder memory grs sp pr fr halted' classVariableNames: '' poolDictionaries: '' category: 'Comet-Base'! !CometMachine methodsFor: 'private' stamp: 'e-itoh 10/25/2007 21:29'! clock | data1 data2 opcode oprandClass oprand | halted ifTrue: [^ self]. data1 := self fetch. opcode := decoder opcodeOf: data1. oprandClass := decoder oprandClassOf: data1. oprand := oprandClass needsAdditionalWord ifTrue: [data2 := self fetch. oprandClass newFrom: data1 with: data2] ifFalse: [oprandClass newFrom: data1]. oprand perform: opcode with: self! ! !CometMachine methodsFor: 'private' stamp: 'e-itoh 10/30/2007 11:28'! fetch | data | data := self logicalValueAt: pr logicalValue. pr logicalValue: pr logicalValue + 1. ^ data! ! !CometMachine methodsFor: 'accessing' stamp: 'e-itoh 10/30/2007 11:27'! arithmeticalValueAt: aNumber | v | v := memory wordAt: aNumber. ^ v > 32767 ifTrue: [v - 65536] ifFalse: [v]! ! !CometMachine methodsFor: 'accessing' stamp: 'e-itoh 10/30/2007 11:27'! at: aNumber putLogicalValue: aNumber2 memory wordAt: aNumber put: aNumber2! ! !CometMachine methodsFor: 'accessing' stamp: 'e-itoh 10/25/2007 22:01'! codeAt: aNumber putL: aNumber2 memory codeAt: aNumber put: aNumber2! ! !CometMachine methodsFor: 'accessing' stamp: 'e-itoh 10/20/2007 00:17'! fr ^ fr! ! !CometMachine methodsFor: 'accessing' stamp: 'e-itoh 10/19/2007 23:40'! grn: aNumber ^ grs at: aNumber + 1! ! !CometMachine methodsFor: 'accessing' stamp: 'e-itoh 10/19/2007 22:38'! grn: aNumber1 put: aNumber2 (grs at: aNumber1 + 1) value: aNumber2! ! !CometMachine methodsFor: 'accessing' stamp: 'e-itoh 10/25/2007 21:29'! halted ^ halted! ! !CometMachine methodsFor: 'accessing' stamp: 'e-itoh 10/25/2007 21:30'! halted: aBoolean halted := aBoolean! ! !CometMachine methodsFor: 'accessing' stamp: 'e-itoh 10/30/2007 11:27'! logicalValueAt: aNumber ^ memory wordAt: aNumber! ! !CometMachine methodsFor: 'accessing' stamp: 'e-itoh 10/24/2007 22:15'! memory ^ memory! ! !CometMachine methodsFor: 'accessing' stamp: 'e-itoh 10/31/2007 23:09'! pop | ea v | ea := sp logicalValue. v := self logicalValueAt: ea. sp logicalValue: ea + 1. ^ v! ! !CometMachine methodsFor: 'accessing' stamp: 'e-itoh 10/20/2007 21:57'! pr ^ pr! ! !CometMachine methodsFor: 'accessing' stamp: 'e-itoh 10/30/2007 11:27'! push: aNumber sp logicalValue: sp logicalValue - 1. self at: sp logicalValue putLogicalValue: aNumber! ! !CometMachine methodsFor: 'accessing' stamp: 'e-itoh 10/30/2007 11:29'! reset pr logicalValue: 0. sp logicalValue: memory size. grs do: [:each | each logicalValue: 65535]. fr of: false; sf: false; zf: false. halted := false! ! !CometMachine methodsFor: 'accessing' stamp: 'e-itoh 10/25/2007 20:38'! setup self reset! ! !CometMachine methodsFor: 'accessing' stamp: 'e-itoh 10/19/2007 22:37'! sp ^ sp! ! !CometMachine methodsFor: 'initialization' stamp: 'e-itoh 10/27/2007 21:16'! initialize decoder := CometDecoder new. memory := CometMemory new. fr := CometFlag new. grs := Array new: 8. grs withIndexDo: [:each :i | grs at: i put: (CometRegister newWithFlag: fr)]. sp := CometRegister new. pr := CometRegister new. self reset! ! "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! CometMachine class instanceVariableNames: ''! !CometMachine class methodsFor: 'examples' stamp: 'e-itoh 10/25/2007 22:01'! putSample1To: aMachine aMachine codeAt: 0 putL: 16r8000. aMachine codeAt: 1 putL: 4. aMachine codeAt: 2 putL: 16rF000. aMachine codeAt: 3 putL: 16rFFFF. aMachine codeAt: 4 putL: 4608. aMachine codeAt: 5 putL: 1. aMachine codeAt: 6 putL: 4624. aMachine codeAt: 7 putL: 2. aMachine codeAt: 8 putL: 9217. aMachine codeAt: 9 putL: 33024! ! !CometMachine class methodsFor: 'examples' stamp: 'e-itoh 10/25/2007 21:08'! sample1 "CometMachine sample1" | comet | comet := CometMachine new. self putSample1To: comet. ^ comet! ! Object subclass: #CometMemory instanceVariableNames: 'collection modified' classVariableNames: '' poolDictionaries: '' category: 'Comet-Base'! !CometMemory methodsFor: 'initialization' stamp: 'e-itoh 10/30/2007 11:06'! initialize modified := false. self clear! ! !CometMemory methodsFor: 'accessing' stamp: 'e-itoh 10/30/2007 11:06'! clear collection := Array new: 256 withAll: 0! ! !CometMemory methodsFor: 'accessing' stamp: 'e-itoh 10/25/2007 22:27'! codeAt: anInteger put: aNumber | data | data := aNumber bitAnd: 65535. data := data bitOr: 65536. collection at: anInteger + 1 put: data. modified := true! ! !CometMemory methodsFor: 'accessing' stamp: 'e-itoh 10/27/2007 21:16'! disassemble | stream decoder result | decoder := CometDecoder new. stream := ReadStream on: collection. result := OrderedCollection new. [stream atEnd] whileFalse: [result add: (self disassembleDecoder: decoder on: stream)]. ^ result! ! !CometMemory methodsFor: 'accessing' stamp: 'e-itoh 10/31/2007 22:59'! disassembleDecoder: aDecoder on: aStream | w data1 opcode oprandClass oprand data2 | w := WriteStream on: String new. w nextPutAll: (aStream position printStringBase: 16 length: 4 padded: true). w nextPutAll: ' '. data1 := aStream next. (data1 bitAnd: 65536) ~= 0 ifTrue: [data1 := data1 bitAnd: 65535. opcode := aDecoder opcodeOf: data1. oprandClass := aDecoder oprandClassOf: data1. oprand := oprandClass needsAdditionalWord ifTrue: [data2 := aStream next. data2 := data2 bitAnd: 65535. oprandClass newFrom: data1 with: data2] ifFalse: [oprandClass newFrom: data1]. w nextPutAll: (opcode asString copyWithout: $:) asUppercase; nextPutAll: ' '; nextPutAll: oprand asString] ifFalse: [w nextPutAll: 'DC '; nextPutAll: (data1 printStringBase: 16 length: 4 padded: true)]. ^ w contents! ! !CometMemory methodsFor: 'accessing' stamp: 'e-itoh 10/25/2007 22:27'! modified ^ modified! ! !CometMemory methodsFor: 'accessing' stamp: 'e-itoh 10/25/2007 22:26'! modified: aBoolean modified := aBoolean! ! !CometMemory methodsFor: 'accessing' stamp: 'e-itoh 10/29/2007 22:23'! readFrom: aCollectionOrStream startAddress: aNumber | stream address | stream := aCollectionOrStream. stream isStream ifFalse: [stream := ReadStream on: aCollectionOrStream]. address := aNumber. [stream atEnd] whileFalse: [self codeAt: address put: stream next. address := address + 1]. stream close! ! !CometMemory methodsFor: 'accessing' stamp: 'e-itoh 10/24/2007 21:05'! reallocate: aNumber collection := Array new: aNumber withAll: 0! ! !CometMemory methodsFor: 'accessing' stamp: 'e-itoh 10/24/2007 21:06'! size ^ collection size! ! !CometMemory methodsFor: 'accessing' stamp: 'e-itoh 10/25/2007 21:59'! wordAt: anInteger ^ (collection at: anInteger + 1) bitAnd: 65535! ! !CometMemory methodsFor: 'accessing' stamp: 'e-itoh 10/25/2007 22:27'! wordAt: anInteger put: aNumber | data | data := aNumber bitAnd: 65535. collection at: anInteger + 1 put: data. modified := true! ! Object subclass: #CometOprand instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Comet-Base'! !CometOprand methodsFor: 'private' stamp: 'e-itoh 10/24/2007 19:27'! compare: v1 with: v2 on: aMachine aMachine fr updateZfSf: v1 - v2. self of: false on: aMachine! ! !CometOprand methodsFor: 'private' stamp: 'e-itoh 10/20/2007 21:52'! of: aBoolean on: aMachine aMachine fr of: aBoolean! ! !CometOprand methodsFor: 'private' stamp: 'e-itoh 10/30/2007 11:24'! sla: v count: count1 on: aMachine | sign num of count | count := count1 min: 15. sign := v bitAnd: 32768. of := v bitAnd: (1 bitShift: 15 - count). num := v bitAnd: 32767. num := num bitShift: count. num := num bitOr: sign. self storeLogicalValue: num on: aMachine. self of: of on: aMachine! ! !CometOprand methodsFor: 'private' stamp: 'e-itoh 10/30/2007 11:24'! sll: v count: count1 on: aMachine | num of count | count := count1 min: 16. of := v bitAnd: (1 bitShift: 16 - count). num := v bitShift: count. self storeLogicalValue: num on: aMachine. self of: of on: aMachine! ! !CometOprand methodsFor: 'private' stamp: 'e-itoh 10/30/2007 11:24'! sra: v count: count1 on: aMachine | sign num of count s2 | count := count1 min: 15. sign := v bitAnd: 32768. of := v bitAnd: (1 bitShift: count - 1). num := v bitAnd: 32767. num := num bitShift: count negated. num := num bitOr: sign. s2 := (1 bitShift: count) - 1. s2 := s2 bitShift: 15 - count. num := num bitOr: s2. self storeLogicalValue: num on: aMachine. self of: of on: aMachine! ! !CometOprand methodsFor: 'private' stamp: 'e-itoh 10/30/2007 11:24'! srl: v count: count1 on: aMachine | num of count | count := count1 min: 16. of := v bitAnd: (1 bitShift: count - 1). num := v bitShift: count negated. self storeLogicalValue: num on: aMachine. self of: of on: aMachine! ! !CometOprand methodsFor: 'opcodes' stamp: 'e-itoh 10/24/2007 19:27'! nop: aMachine ! ! !CometOprand methodsFor: 'opcodes' stamp: 'e-itoh 10/30/2007 11:23'! ret: aMachine | addr | addr := aMachine pop. aMachine pr logicalValue: addr! ! !CometOprand methodsFor: 'printing' stamp: 'e-itoh 10/24/2007 21:45'! printOn: aStream aStream nextPutAll: '-'! ! "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! CometOprand class instanceVariableNames: ''! !CometOprand class methodsFor: 'accessing' stamp: 'e-itoh 10/24/2007 20:29'! needsAdditionalWord ^ false! ! !CometOprand class methodsFor: 'accessing' stamp: 'e-itoh 10/27/2007 21:50'! opcodes ^ #(#nop: #ret: )! ! !CometOprand class methodsFor: 'instance creation' stamp: 'e-itoh 10/24/2007 20:40'! newFrom: aNumber ^ self basicNew initialize! ! CometOprand subclass: #CometOprandAdrX instanceVariableNames: 'adr x' classVariableNames: '' poolDictionaries: '' category: 'Comet-Base'! !CometOprandAdrX methodsFor: 'accessing' stamp: 'e-itoh 10/26/2007 22:07'! adr: aNumberOrString adr := aNumberOrString! ! !CometOprandAdrX methodsFor: 'accessing' stamp: 'e-itoh 10/26/2007 22:11'! x ^ x! ! !CometOprandAdrX methodsFor: 'accessing' stamp: 'e-itoh 10/26/2007 23:02'! x: aNumber x := aNumber bitAnd: 15! ! !CometOprandAdrX methodsFor: 'opcodes' stamp: 'e-itoh 10/30/2007 11:21'! call: aMachine | ea | ea := self effectiveAddress: aMachine. aMachine push: aMachine pr logicalValue. aMachine pr logicalValue: ea! ! !CometOprandAdrX methodsFor: 'opcodes' stamp: 'e-itoh 10/20/2007 22:03'! jmi: aMachine self branch: aMachine fr isMinus on: aMachine! ! !CometOprandAdrX methodsFor: 'opcodes' stamp: 'e-itoh 10/20/2007 22:03'! jnz: aMachine self branch: aMachine fr isNonZero on: aMachine! ! !CometOprandAdrX methodsFor: 'opcodes' stamp: 'e-itoh 10/20/2007 22:03'! jov: aMachine self branch: aMachine fr isOverflow on: aMachine! ! !CometOprandAdrX methodsFor: 'opcodes' stamp: 'e-itoh 10/20/2007 22:03'! jpl: aMachine self branch: aMachine fr isPlus on: aMachine! ! !CometOprandAdrX methodsFor: 'opcodes' stamp: 'e-itoh 10/20/2007 22:03'! jump: aMachine self branch: true on: aMachine! ! !CometOprandAdrX methodsFor: 'opcodes' stamp: 'e-itoh 10/20/2007 22:03'! jze: aMachine self branch: aMachine fr isZero on: aMachine! ! !CometOprandAdrX methodsFor: 'opcodes' stamp: 'e-itoh 10/24/2007 19:27'! push: aMachine aMachine push: (self effectiveAddress: aMachine)! ! !CometOprandAdrX methodsFor: 'opcodes' stamp: 'e-itoh 10/25/2007 21:30'! svc: aMachine adr = 65535 ifTrue: [aMachine halted: true]! ! !CometOprandAdrX methodsFor: 'private' stamp: 'e-itoh 10/30/2007 11:23'! branch: aBoolean on: aMachine | ea | aBoolean ifTrue: [ea := self effectiveAddress: aMachine. aMachine pr logicalValue: ea]! ! !CometOprandAdrX methodsFor: 'private' stamp: 'e-itoh 10/30/2007 11:21'! effectiveAddress: aMachine ^ adr + (x = 0 ifTrue: [0] ifFalse: [(aMachine grn: x) logicalValue])! ! !CometOprandAdrX methodsFor: 'private' stamp: 'e-itoh 10/19/2007 22:03'! setAdr: aNumber1 x: aNumber2 adr := aNumber1. x := aNumber2! ! !CometOprandAdrX methodsFor: 'printing' stamp: 'e-itoh 10/31/2007 23:00'! printOn: aStream aStream nextPutAll: (adr isNumber ifTrue: [adr printStringBase: 16] ifFalse: [adr]). x ~= 0 ifTrue: [aStream nextPutAll: ', GR'; nextPutAll: x asString]! ! "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! CometOprandAdrX class instanceVariableNames: ''! !CometOprandAdrX class methodsFor: 'instance creation' stamp: 'e-itoh 10/24/2007 20:43'! newFrom: aNumber1 with: aNumber2 ^ self basicNew setAdr: aNumber2 x: (aNumber1 bitAnd: 15)! ! !CometOprandAdrX class methodsFor: 'accessing' stamp: 'e-itoh 10/24/2007 20:29'! needsAdditionalWord ^ true! ! !CometOprandAdrX class methodsFor: 'accessing' stamp: 'e-itoh 10/27/2007 21:49'! opcodes ^ #(#call: #jmi: #jnz: #jov: #jpl: #jump: #jze: #push: #svc:)! ! CometOprand subclass: #CometOprandR instanceVariableNames: 'r' classVariableNames: '' poolDictionaries: '' category: 'Comet-Base'! !CometOprandR methodsFor: 'accessing' stamp: 'e-itoh 10/26/2007 22:41'! r ^ r! ! !CometOprandR methodsFor: 'accessing' stamp: 'e-itoh 10/26/2007 23:02'! r: aNumber r := aNumber bitAnd: 15! ! !CometOprandR methodsFor: 'private' stamp: 'e-itoh 10/19/2007 22:04'! setR: aNumber r := aNumber! ! !CometOprandR methodsFor: 'private' stamp: 'e-itoh 10/30/2007 11:24'! storeLogicalValue: aNumber on: aMachine (aMachine grn: r) logicalValue: aNumber! ! !CometOprandR methodsFor: 'printing' stamp: 'e-itoh 10/24/2007 21:46'! printOn: aStream aStream nextPutAll: 'GR'; nextPutAll: r asString! ! !CometOprandR methodsFor: 'opcodes' stamp: 'e-itoh 10/30/2007 11:24'! pop: aMachine | v | v := aMachine pop. self storeLogicalValue: v on: aMachine! ! "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! CometOprandR class instanceVariableNames: ''! !CometOprandR class methodsFor: 'accessing' stamp: 'e-itoh 10/27/2007 21:50'! opcodes ^ #(#pop:)! ! !CometOprandR class methodsFor: 'instance creation' stamp: 'e-itoh 10/31/2007 21:46'! newFrom: aNumber ^ self basicNew setR: ((aNumber bitAnd: 240) bitShift: -4)! ! CometOprandAdrX subclass: #CometOprandRadrX instanceVariableNames: 'r' classVariableNames: '' poolDictionaries: '' category: 'Comet-Base'! !CometOprandRadrX methodsFor: 'opcodes' stamp: 'e-itoh 10/20/2007 20:41'! adda: aMachine self arithmeticOp: #+ on: aMachine! ! !CometOprandRadrX methodsFor: 'opcodes' stamp: 'e-itoh 10/20/2007 20:42'! addl: aMachine self logicalOp: #+ on: aMachine! ! !CometOprandRadrX methodsFor: 'opcodes' stamp: 'e-itoh 10/20/2007 20:41'! and: aMachine self logicalNofOp: #bitAnd: on: aMachine! ! !CometOprandRadrX methodsFor: 'opcodes' stamp: 'e-itoh 10/30/2007 11:27'! cpa: aMachine | ea v1 v2 | v1 := (aMachine grn: r) arithmeticalValue. ea := self effectiveAddress: aMachine. v2 := aMachine arithmeticalValueAt: ea. self compare: v1 with: v2 on: aMachine! ! !CometOprandRadrX methodsFor: 'opcodes' stamp: 'e-itoh 10/30/2007 11:28'! cpl: aMachine | ea v1 v2 | v1 := (aMachine grn: r) logicalValue. ea := self effectiveAddress: aMachine. v2 := aMachine logicalValueAt: ea. self compare: v1 with: v2 on: aMachine! ! !CometOprandRadrX methodsFor: 'opcodes' stamp: 'e-itoh 10/30/2007 11:24'! lad: aMachine | v | v := self effectiveAddress: aMachine. self storeLogicalValue: v on: aMachine! ! !CometOprandRadrX methodsFor: 'opcodes' stamp: 'e-itoh 10/30/2007 11:28'! ld: aMachine | ea v | ea := self effectiveAddress: aMachine. v := aMachine logicalValueAt: ea. self storeLogicalValue: v on: aMachine! ! !CometOprandRadrX methodsFor: 'opcodes' stamp: 'e-itoh 10/20/2007 20:41'! or: aMachine self logicalNofOp: #bitOr: on: aMachine! ! !CometOprandRadrX methodsFor: 'opcodes' stamp: 'e-itoh 10/30/2007 11:22'! sla: aMachine | count v | count := self effectiveAddress: aMachine. v := (aMachine grn: r) logicalValue. self sla: v count: count on: aMachine! ! !CometOprandRadrX methodsFor: 'opcodes' stamp: 'e-itoh 10/30/2007 11:22'! sll: aMachine | count v | count := self effectiveAddress: aMachine. v := (aMachine grn: r) logicalValue. self sll: v count: count on: aMachine! ! !CometOprandRadrX methodsFor: 'opcodes' stamp: 'e-itoh 10/30/2007 11:22'! sra: aMachine | count v | count := self effectiveAddress: aMachine. v := (aMachine grn: r) logicalValue. self sra: v count: count on: aMachine! ! !CometOprandRadrX methodsFor: 'opcodes' stamp: 'e-itoh 10/30/2007 11:22'! srl: aMachine | count v | count := self effectiveAddress: aMachine. v := (aMachine grn: r) logicalValue. self srl: v count: count on: aMachine! ! !CometOprandRadrX methodsFor: 'opcodes' stamp: 'e-itoh 10/30/2007 11:27'! st: aMachine | ea v | ea := self effectiveAddress: aMachine. v := (aMachine grn: r) logicalValue. aMachine at: ea putLogicalValue: v! ! !CometOprandRadrX methodsFor: 'opcodes' stamp: 'e-itoh 10/20/2007 20:41'! suba: aMachine self arithmeticOp: #- on: aMachine! ! !CometOprandRadrX methodsFor: 'opcodes' stamp: 'e-itoh 10/20/2007 20:42'! subl: aMachine self logicalOp: #- on: aMachine! ! !CometOprandRadrX methodsFor: 'opcodes' stamp: 'e-itoh 10/20/2007 20:42'! xor: aMachine self logicalNofOp: #bitXor: on: aMachine! ! !CometOprandRadrX methodsFor: 'private' stamp: 'e-itoh 10/30/2007 11:27'! arithmeticOp: aSymbol on: aMachine | ea v1 v2 | v1 := (aMachine grn: r) arithmeticalValue. ea := self effectiveAddress: aMachine. v2 := aMachine arithmeticalValueAt: ea. (aMachine grn: r) arithmeticalValue: (v1 perform: aSymbol with: v2)! ! !CometOprandRadrX methodsFor: 'private' stamp: 'e-itoh 10/30/2007 11:28'! logicalNofOp: aSymbol on: aMachine | ea v1 v2 | v1 := (aMachine grn: r) logicalValue. ea := self effectiveAddress: aMachine. v2 := aMachine logicalValueAt: ea. self storeLogicalValue: (v1 perform: aSymbol with: v2) on: aMachine. self of: false on: aMachine! ! !CometOprandRadrX methodsFor: 'private' stamp: 'e-itoh 10/30/2007 11:28'! logicalOp: aSymbol on: aMachine | ea v1 v2 | v1 := (aMachine grn: r) logicalValue. ea := self effectiveAddress: aMachine. v2 := aMachine logicalValueAt: ea. self storeLogicalValue: (v1 perform: aSymbol with: v2) on: aMachine! ! !CometOprandRadrX methodsFor: 'private' stamp: 'e-itoh 10/19/2007 22:02'! setR: aNumber1 adr: aNumber2 x: aNumber3 r := aNumber1. adr := aNumber2. x := aNumber3! ! !CometOprandRadrX methodsFor: 'private' stamp: 'e-itoh 10/30/2007 11:25'! storeLogicalValue: aNumber on: aMachine (aMachine grn: r) logicalValue: aNumber! ! !CometOprandRadrX methodsFor: 'printing' stamp: 'e-itoh 10/31/2007 23:00'! printOn: aStream aStream nextPutAll: 'GR'; nextPutAll: r asString; nextPutAll: ', '; nextPutAll: (adr isNumber ifTrue: [adr printStringBase: 16] ifFalse: [adr]). x ~= 0 ifTrue: [aStream nextPutAll: ', GR'; nextPutAll: x asString]! ! !CometOprandRadrX methodsFor: 'accessing' stamp: 'e-itoh 10/26/2007 22:31'! r ^ r! ! !CometOprandRadrX methodsFor: 'accessing' stamp: 'e-itoh 10/26/2007 23:03'! r: aNumber r := aNumber bitAnd: 15! ! "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! CometOprandRadrX class instanceVariableNames: ''! !CometOprandRadrX class methodsFor: 'instance creation' stamp: 'e-itoh 10/24/2007 20:45'! newFrom: aNumber1 with: aNumber2 ^ self basicNew setR: ((aNumber1 bitAnd: 240) bitShift: -4) adr: aNumber2 x: (aNumber1 bitAnd: 15)! ! !CometOprandRadrX class methodsFor: 'accessing' stamp: 'e-itoh 10/31/2007 22:56'! opcodes ^ #(#adda: #addl: #and: #cpa: #cpl: #lad: #ld: #or: #sla: #srl: #st: #suba: #subl: #xor:)! ! CometOprand subclass: #CometOprandRR instanceVariableNames: 'r1 r2' classVariableNames: '' poolDictionaries: '' category: 'Comet-Base'! !CometOprandRR methodsFor: 'accessing' stamp: 'e-itoh 10/26/2007 22:48'! r1 ^ r1! ! !CometOprandRR methodsFor: 'accessing' stamp: 'e-itoh 10/26/2007 23:01'! r1: aNumber r1 := aNumber bitAnd: 15! ! !CometOprandRR methodsFor: 'accessing' stamp: 'e-itoh 10/26/2007 22:48'! r2 ^ r2! ! !CometOprandRR methodsFor: 'accessing' stamp: 'e-itoh 10/26/2007 23:01'! r2: aNumber r2 := aNumber bitAnd: 15! ! !CometOprandRR methodsFor: 'opcodes' stamp: 'e-itoh 10/20/2007 20:41'! adda: aMachine self arithmeticOp: #+ on: aMachine! ! !CometOprandRR methodsFor: 'opcodes' stamp: 'e-itoh 10/20/2007 20:42'! addl: aMachine self logicalOp: #+ on: aMachine! ! !CometOprandRR methodsFor: 'opcodes' stamp: 'e-itoh 10/20/2007 20:42'! and: aMachine self logicalNofOp: #bitAnd: on: aMachine! ! !CometOprandRR methodsFor: 'opcodes' stamp: 'e-itoh 10/30/2007 11:21'! cpa: aMachine | v1 v2 | v1 := (aMachine grn: r1) arithmeticalValue. v2 := (aMachine grn: r2) arithmeticalValue. self compare: v1 with: v2 on: aMachine! ! !CometOprandRR methodsFor: 'opcodes' stamp: 'e-itoh 10/30/2007 11:22'! cpl: aMachine | v1 v2 | v1 := (aMachine grn: r1) logicalValue. v2 := (aMachine grn: r2) logicalValue. self compare: v1 with: v2 on: aMachine! ! !CometOprandRR methodsFor: 'opcodes' stamp: 'e-itoh 10/30/2007 11:25'! ld: aMachine | v | v := (aMachine grn: r2) logicalValue. self storeLogicalValue: v on: aMachine! ! !CometOprandRR methodsFor: 'opcodes' stamp: 'e-itoh 10/20/2007 20:42'! or: aMachine self logicalNofOp: #bitOr: on: aMachine! ! !CometOprandRR methodsFor: 'opcodes' stamp: 'e-itoh 10/20/2007 20:41'! suba: aMachine self arithmeticOp: #- on: aMachine! ! !CometOprandRR methodsFor: 'opcodes' stamp: 'e-itoh 10/20/2007 20:42'! subl: aMachine self logicalOp: #- on: aMachine! ! !CometOprandRR methodsFor: 'opcodes' stamp: 'e-itoh 10/20/2007 20:42'! xor: aMachine self logicalNofOp: #bitXor: on: aMachine! ! !CometOprandRR methodsFor: 'private' stamp: 'e-itoh 10/30/2007 11:20'! arithmeticOp: aSymbol on: aMachine | v2 v1 | v1 := (aMachine grn: r1) arithmeticalValue. v2 := (aMachine grn: r2) arithmeticalValue. (aMachine grn: r1) arithmeticalValue: (v1 perform: aSymbol with: v2)! ! !CometOprandRR methodsFor: 'private' stamp: 'e-itoh 10/30/2007 11:25'! logicalNofOp: aSymbol on: aMachine | v1 v2 | v1 := (aMachine grn: r1) logicalValue. v2 := (aMachine grn: r2) logicalValue. self storeLogicalValue: (v1 perform: aSymbol with: v2) on: aMachine. self of: false on: aMachine! ! !CometOprandRR methodsFor: 'private' stamp: 'e-itoh 10/30/2007 11:25'! logicalOp: aSymbol on: aMachine | v1 v2 | v1 := (aMachine grn: r1) logicalValue. v2 := (aMachine grn: r2) logicalValue. self storeLogicalValue: (v1 perform: aSymbol with: v2) on: aMachine! ! !CometOprandRR methodsFor: 'private' stamp: 'e-itoh 10/19/2007 21:59'! setR1: aNumber1 r2: aNumber2 r1 := aNumber1. r2 := aNumber2! ! !CometOprandRR methodsFor: 'private' stamp: 'e-itoh 10/30/2007 11:25'! storeLogicalValue: aNumber on: aMachine (aMachine grn: r1) logicalValue: aNumber! ! !CometOprandRR methodsFor: 'printing' stamp: 'e-itoh 10/24/2007 22:06'! printOn: aStream aStream nextPutAll: 'GR'; nextPutAll: r1 asString; nextPutAll: ', GR'; nextPutAll: r2 asString! ! "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! CometOprandRR class instanceVariableNames: ''! !CometOprandRR class methodsFor: 'accessing' stamp: 'e-itoh 10/27/2007 21:51'! opcodes ^ #(#adda: #addl: #and: #cpa: #cpl: #ld: #or: #suba: #subl: #xor: )! ! !CometOprandRR class methodsFor: 'instance creation' stamp: 'e-itoh 10/24/2007 20:41'! newFrom: aNumber ^ self basicNew setR1: ((aNumber bitAnd: 240) bitShift: -4) r2: (aNumber bitAnd: 15)! ! Object subclass: #CometRegister instanceVariableNames: 'v flag' classVariableNames: '' poolDictionaries: '' category: 'Comet-Base'! !CometRegister methodsFor: 'accessing' stamp: 'e-itoh 10/30/2007 11:20'! arithmeticalValue ^ v > 32767 ifTrue: [v - 65536] ifFalse: [v]! ! !CometRegister methodsFor: 'accessing' stamp: 'e-itoh 10/30/2007 11:20'! arithmeticalValue: aNumber flag ifNotNil: [flag of: (aNumber < -32768 or: [aNumber > 32767])]. v := aNumber + 65536 rem: 65536. self updateZfSf: v! ! !CometRegister methodsFor: 'accessing' stamp: 'e-itoh 10/30/2007 11:20'! logicalValue ^ v! ! !CometRegister methodsFor: 'accessing' stamp: 'e-itoh 10/30/2007 11:20'! logicalValue: aNumber flag ifNotNil: [flag of: (aNumber < 0 or: [aNumber > 65535])]. v := aNumber + 65536 rem: 65536. self updateZfSf: v! ! !CometRegister methodsFor: 'accessing' stamp: 'e-itoh 10/20/2007 00:17'! updateZfSf: aNumber flag ifNil: [^ self]. flag updateZfSf: aNumber! ! !CometRegister methodsFor: 'private' stamp: 'e-itoh 10/19/2007 23:26'! setFlag: aCometFlag flag := aCometFlag! ! !CometRegister methodsFor: 'initialization' stamp: 'e-itoh 10/19/2007 23:26'! initialize v := 0! ! !CometRegister methodsFor: 'printing' stamp: 'e-itoh 10/30/2007 11:33'! asHexString ^ v printStringBase: 16 length: 4 padded: true! ! !CometRegister methodsFor: 'printing' stamp: 'e-itoh 10/24/2007 21:17'! printOn: aStream v printOn: aStream base: 16! ! "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! CometRegister class instanceVariableNames: ''! !CometRegister class methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/19/2007 23:26'! newWithFlag: aCometFlag ^ self basicNew initialize setFlag: aCometFlag! !