Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .global asm_main
- .align 4
- memory: .space 2000000
- .align 4
- asm_main:
- LDR R2, =0x000103F0 ;@ should be Zmem
- LDR R3, =0b01000000 ;@ Opcode test
- STR R3, [R2]
- checkSize:
- ;@ Could check size to see if it even is an OPCODE
- ;@ If it is check the type
- ;@ Else crash
- checkType:
- LDR R0, [R2]
- LSR R1, R0, #6
- CMP R1, #0b11
- BEQ Ctype
- CMP R1, #0b10
- BEQ Atype
- B Btype
- Ctype:
- MOV R5, #100
- LSR R1, R0, #5
- ANDS R1, #0b00000001
- BEQ twoOperands
- BNE variableOperands
- Atype:
- MOV R5, #200
- LSR R1, R0, #4
- AND R1, #0b00000011
- CMP R1, #0b00000011
- BEQ zeroOperands
- BNE oneOperand
- Btype:
- MOV R5, #300
- LSR R1, R0, #6
- ANDS R1, #0b00000001
- BEQ 1Bconstant
- B 1Bindicator
- twoOperands:
- B twoOperands
- variableOperands:
- B variableOperands
- zeroOperands:
- B zeroOperands
- oneOperand:
- B oneOperand
- -----------------------------------------------------------------------------------------------------------------------
- .global asm_main
- .align 4
- memory: .space 2000000
- .align 4
- asm_main:
- LDR R2, =0x000103F0 ;@ should be Zmem
- LDR R3, =0b01100000 ;@ Opcode test
- STR R3, [R2]
- checkSize:
- ;@ Could check size to see if it even is an OPCODE
- ;@ If it is check the type
- ;@ Else crash
- checkType:
- LDRB R0, [R2]
- LSR R1, R0, #6
- CMP R1, #0b11
- BEQ Ctype
- CMP R1, #0b10
- BEQ Atype
- B Btype
- Ctype:
- AND R5, R0, #0b11000000
- LSR R1, R0, #5
- ANDS R1, #0b00000001
- BEQ twoOperands
- BNE variableOperands
- Atype:
- AND R5, R0, #0b11000000 ;@testing
- LSR R1, R0, #4 ;@ shift 4th and 5th bit
- AND R1, #0b00000011;@ Extract 4th and 5th bit
- MOV R2, R1 ;@Store for later use in instruction finding
- CMP R1, #0b00000011
- BEQ zeroOperands
- B oneOperand
- Btype:
- AND R5, R0, #0b11000000
- LSR R1, R0, #6
- ANDS R1, #0b00000001
- BEQ 1Bconstant
- B 1Bindicator
- twoOperands:
- ;@ Retrieve each operand and store them into R1 and R0
- B twoOperands
- variableOperands:
- B variableOperands
- zeroOperands:
- AND R4, R0, #0b00110000
- ADD R5, R4
- B 4bitInstructionIndicator
- oneOperand:
- AND R4, R0, #0b00110000
- ADD R5, R4
- CMP R1, #0b10
- BEQ 1Bindicator
- CMP R1, #0b01
- BEQ 1Bconstant
- B 2Bconstant
- 1Bconstant:
- ;@ Retrieve Operand and store into R0
- B instructionIndicator
- 2Bconstant:
- ;@ Retrieve Operand and store into R0
- B instructionIndicator
- 1Bindicator:
- ;@ Retrieve Operand and store into R0
- B instructionIndicator
- 4bitInstructionIndicator:
- AND R1, R0, #0b00001111
- ADD R5, R1
- CMP R2, #0b00000011 ;@R2 is
- BEQ zero
- B one
- 5bitInstructionIndicator:
- AND R1, R0, #0b00011111
- ADD R5, R1
- BL CfindInstruction
- B 5bitInstructionIndicator
- zero:
- CMP R1, #0b00000010
- BEQ PRINT
- CMP R1, #0b00001000
- BEQ RET_POPPED
- CMP R1, #0b00001101
- BEQ VERIFY
- B crash
- one:
- ------------------------------------------------------------------------------------------------
- .global asm_main
- .align 4
- memory: .space 2000000
- .align 4
- asm_main:
- LDR R2, =0x000103F0 ;@ should be Zmem
- LDR R3, =0b10101111 ;@ Opcode test
- STR R3, [R2]
- checkSize:
- ;@ Could check size to see if it even is an OPCODE
- ;@ If it is check the type
- ;@ Else crash
- checkType:
- LDRB R0, [R2]
- LSR R1, R0, #6 ;@ shift 7th and 6th bits
- CMP R1, #0b11
- BEQ Ctype
- CMP R1, #0b10
- BEQ Atype
- ;@B Btype
- Ctype:
- AND R5, R0, #0b11000000 ;@testing
- LSR R1, R0, #5 ;@ shift 5th bit
- AND R1, #0b00000001;@ Extract 5th bit
- MOV R2, R1 ;@Store for later use in instruction finding
- CMP R1, #0b00000001
- BNE twoOperands
- BEQ variableOperands
- Atype:
- AND R5, R0, #0b11000000 ;@testing
- LSR R1, R0, #4 ;@ shift 4th and 5th bits
- AND R1, #0b00000011;@ Extract 4th and 5th bit
- MOV R2, R1 ;@Store for later use in instruction finding
- CMP R1, #0b00000011
- BEQ zeroOperands
- B oneOperand
- /*Btype:
- AND R5, R0, #0b11000000
- LSR R1, R0, #6
- ANDS R1, #0b00000001
- BEQ 1Bconstant
- B 1Bindicator*/
- twoOperands:
- ;@ Retrieve each operand and store them into R1 and R0
- B CInstructionIndicator
- variableOperands:
- ;@ Not sure what happens here yet
- B CInstructionIndicator
- zeroOperands:
- AND R4, R0, #0b00100000;@testing
- ADD R5, R4;@testing
- B AInstructionIndicator
- oneOperand:
- AND R4, R0, #0b00110000
- ADD R5, R4
- CMP R1, #0b10
- BEQ indicator1B
- CMP R1, #0b01
- BEQ constant1B
- B constant2B
- constant1B:
- ;@ Retrieve Operand and store into R0
- B AInstructionIndicator
- constant2B:
- ;@ Retrieve Operand and store into R0
- B AInstructionIndicator
- indicator1B:
- ;@ Retrieve Operand and store into R0
- B AInstructionIndicator
- AInstructionIndicator:
- AND R1, R0, #0b00001111
- ADD R5, R1
- CMP R2, #0b00000011 ;@R2 determines the number of operands
- BEQ zero
- B one
- CInstructionIndicator:
- AND R1, R0, #0b00011111
- ADD R5, R1
- CMP R1, #0b1
- BEQ variable
- B two
- zero:
- CMP R1, #0b00000010
- BEQ PRINT
- CMP R1, #0b00001000
- BEQ RET_POPPED
- CMP R1, #0b00001101
- BEQ VERIFY
- B crash
- one:
- CMP R1, #0b00000101
- BEQ INC
- CMP R1, #0b00000110
- BEQ DEC
- CMP R1, #0b00001111
- BEQ CALL_1N
- CMP R1, #0b00001011
- BEQ RET
- B crash
- two:
- CMP R1, #0b00010100
- BEQ ADD
- CMP R1, #0b00010101
- BEQ SUB
- CMP R1, #0b00010110
- BEQ MUL
- CMP R1, #0b00010111
- BEQ DIV
- CMP R1, #0b00011000
- BEQ MOD
- CMP R1, #0b00000001
- BEQ JE
- CMP R1, #0b00000010
- BEQ JL
- CMP R1, #0b00000011
- BEQ JG
- CMP R1, #0b00011001
- BEQ CALL_2S
- CMP R1, #0b00011010
- BEQ CALL_2N
- CMP R1, #0b00001010
- BEQ TEST_ATTR
- CMP R1, #0b00001011
- BEQ SET_ATTR
- CMP R1, #0b00001100
- BEQ CLEAR_ATTR
- B crash
- variable:
- B crash
- crash:
- ;@ Print the invalid intruction and its location in HEX
- ;@ Should probably loop back to execute or something
- B crash
- ;@ 0 Operand instructions
- PRINT:
- B PRINT
- RET_POPPED:
- B RET_POPPED
- VERIFY:
- B VERIFY
- ;@ 1 Operand instructions
- INC:
- B INC
- DEC:
- B DEC
- CALL_1N:
- B CALL_1N
- RET:
- B RET
- ;@ 2 Operand instructions
- ADD:
- B ADD
- SUB:
- B SUB
- MUL:
- B MUL
- DIV:
- B DIV
- MOD:
- B MOD
- JE:
- B JE
- JL:
- B JL
- JG:
- B JG
- CALL_2S:
- B CALL_2S
- CALL_2N:
- B CALL_2N
- TEST_ATTR:
- B TEST_ATTR
- SET_ATTR:
- B SET_ATTR
- CLEAR_ATTR:
- B CLEAR_ATTR
- ----------------------------------------------------------------------------------------------
- .global asm_main
- .align 4
- memory: .space 2000000
- .align 4
- asm_main:
- LDR R2, =0x000103F0 ;@ should be Zmem
- LDR R3, =0b01001001 ;@ Opcode test
- STR R3, [R2]
- checkSize:
- ;@ Could check size to see if it even is an OPCODE
- ;@ If it is check the type
- ;@ Else crash
- checkType:
- LDRB R0, [R2]
- LSR R1, R0, #6 ;@ shift 7th and 6th bits
- MOV R4, R1
- CMP R1, #0b11
- BEQ Ctype
- CMP R1, #0b10
- BEQ Atype
- B Btype
- Ctype:
- AND R5, R0, #0b11000000 ;@testing
- LSR R1, R0, #5 ;@ shift 5th bit
- AND R1, #0b00000001;@ Extract 5th bit
- MOV R2, R1 ;@Store for later use in instruction finding
- CMP R1, #0b00000001
- BNE twoOperands
- BEQ variableOperands
- Atype:
- AND R5, R0, #0b11000000 ;@testing
- LSR R1, R0, #4 ;@ shift 4th and 5th bits
- AND R1, #0b00000011;@ Extract 4th and 5th bit
- MOV R2, R1 ;@Store for later use in instruction finding
- CMP R1, #0b00000011
- BEQ zeroOperands
- B oneOperand
- Btype:
- AND R5, R0, #0b11000000
- LSR R1, R0, #6 ;@ shift 6th bit
- AND R1, #0b00000001;@ Extract 6th bit
- MOV R2, R1 ;@Store for later use in instruction finding
- CMP R1, #0b00000001
- BEQ indicator1B;@ ------------------ NEEDS TO GO TO FIRST
- B constant1B
- twoOperands:
- ;@ Retrieve each operand and store them into R1 and R0
- B CInstructionIndicator
- variableOperands:
- ;@ Not sure what happens here yet
- B CInstructionIndicator
- zeroOperands:
- AND R4, R0, #0b00100000;@testing
- ADD R5, R4;@testing
- B AInstructionIndicator
- oneOperand:
- AND R4, R0, #0b00110000
- ADD R5, R4
- CMP R1, #0b10
- BEQ indicator1B
- CMP R1, #0b01
- BEQ constant1B
- B constant2B
- constant1B:
- ;@ Retrieve Operand and store into R0
- CMP R4, #0b00000010
- BEQ AInstructionIndicator
- AND R1, R0, #0b00011111
- B two
- constant2B:
- ;@ Retrieve Operand and store into R0
- B AInstructionIndicator
- indicator1B:
- ;@ Retrieve Operand and store into R0
- CMP R4, #0b00000010
- BEQ AInstructionIndicator
- AND R1, R0, #0b00011111
- B two
- AInstructionIndicator:
- AND R1, R0, #0b00001111
- ADD R5, R1
- CMP R2, #0b00000011 ;@R2 determines the number of operands
- BEQ zero
- B one
- CInstructionIndicator:
- AND R1, R0, #0b00011111
- ADD R5, R1
- CMP R2, #0b1
- BEQ variable
- B two
- zero:
- CMP R1, #0b00000010
- BEQ PRINT
- CMP R1, #0b00001000
- BEQ RET_POPPED
- CMP R1, #0b00001101
- BEQ VERIFY
- B crash
- one:
- CMP R1, #0b00000101
- BEQ INC
- CMP R1, #0b00000110
- BEQ DEC
- CMP R1, #0b00001111
- BEQ CALL_1N
- CMP R1, #0b00001011
- BEQ RET
- B crash
- two:
- CMP R1, #0b00010100
- BEQ ADD
- CMP R1, #0b00010101
- BEQ SUB
- CMP R1, #0b00010110
- BEQ MUL
- CMP R1, #0b00010111
- BEQ DIV
- CMP R1, #0b00011000
- BEQ MOD
- CMP R1, #0b00000001
- BEQ JE
- CMP R1, #0b00000010
- BEQ JL
- CMP R1, #0b00000011
- BEQ JG
- CMP R1, #0b00011001
- BEQ CALL_2S
- CMP R1, #0b00011010
- BEQ CALL_2N
- CMP R1, #0b00001010
- BEQ TEST_ATTR
- CMP R1, #0b00001011
- BEQ SET_ATTR
- CMP R1, #0b00001100
- BEQ CLEAR_ATTR
- B crash
- variable:
- CMP R1, #0b00011000
- BEQ NOT
- CMP R1, #0b00000101
- BEQ PRINT_CHAR
- CMP R1, #0b00000110
- BEQ PRINT_NUM
- CMP R1, #0b00001000
- BEQ PUSH
- CMP R1, #0b00001001
- BEQ PULL
- B crash
- crash:
- ;@ Print the invalid intruction and its location in HEX
- ;@ Should probably loop back to execute or something
- B crash
- ;@ 0 Operand Instructions
- PRINT:
- B PRINT
- RET_POPPED:
- B RET_POPPED
- VERIFY:
- B VERIFY
- ;@ 1 Operand Instructions
- INC:
- B INC
- DEC:
- B DEC
- CALL_1N:
- B CALL_1N
- RET:
- B RET
- ;@ 2 Operand Instructions
- ADD:
- B ADD
- SUB:
- B SUB
- MUL:
- B MUL
- DIV:
- B DIV
- MOD:
- B MOD
- JE:
- B JE
- JL:
- B JL
- JG:
- B JG
- CALL_2S:
- B CALL_2S
- CALL_2N:
- B CALL_2N
- TEST_ATTR:
- B TEST_ATTR
- SET_ATTR:
- B SET_ATTR
- CLEAR_ATTR:
- B CLEAR_ATTR
- ;@ Variable Operand Instructions
- NOT:
- B NOT
- PRINT_CHAR:
- B PRINT_CHAR
- PRINT_NUM:
- B PRINT_NUM
- PUSH:
- B PUSH
- PULL:
- B PULL
- ---------------------------------------------------------------------------------------------
- .global asm_main
- .align 4
- memory: .space 2000000
- .align 4
- asm_main:
- LDR R2, =0x000103F0 ;@ should be Zmem
- LDR R3, =0b01001001 ;@ Opcode test
- STR R3, [R2]
- checkSize:
- ;@ Could check size to see if it even is an OPCODE
- ;@ If it is check the type
- ;@ Else crash
- checkType:
- LDRB R0, [R2]
- LSR R1, R0, #6 ;@ shift 7th and 6th bits
- MOV R4, R1
- CMP R1, #0b11
- BEQ Ctype
- CMP R1, #0b10
- BEQ Atype
- B Btype
- Ctype:
- AND R5, R0, #0b11000000 ;@testing
- LSR R1, R0, #5 ;@ shift 5th bit
- AND R1, #0b00000001;@ Extract 5th bit
- MOV R2, R1 ;@Store for later use in instruction finding
- CMP R1, #0b00000001
- BNE twoOperands
- BEQ variableOperands
- Atype:
- AND R5, R0, #0b11000000 ;@testing
- LSR R1, R0, #4 ;@ shift 4th and 5th bits
- AND R1, #0b00000011;@ Extract 4th and 5th bit
- MOV R2, R1 ;@Store for later use in instruction finding
- CMP R1, #0b00000011
- BEQ zeroOperands
- B oneOperand
- Btype:
- AND R5, R0, #0b11000000
- LSR R1, R0, #6 ;@ shift 6th bit
- AND R1, #0b00000001;@ Extract 6th bit
- MOV R2, R1 ;@Store for later use in instruction finding
- CMP R1, #0b00000001
- BEQ Bindicator1B;@ ------------------ NEEDS TO GO TO FIRST
- B Bconstant1B
- Bindicator1B:
- ;@store into r0
- B Btype2
- Bconstant1B:
- ;@store into r0
- B Btype2
- Btype2:
- ;@AND R5, R0, #0b11000000
- LSR R1, R0, #5 ;@ shift 6th bit
- AND R1, #0b00000001;@ Extract 6th bit
- MOV R2, R1 ;@Store for later use in instruction finding
- CMP R1, #0b00000001
- BEQ B2indicator1B
- B B2constant1B
- B2indicator1B:
- ;@store into R1
- B two
- B2constant1B:
- ;@store into R1
- B two
- twoOperands:
- ;@ Retrieve each operand and store them into R1 and R0
- B CInstructionIndicator
- variableOperands:
- ;@ Not sure what happens here yet
- B CInstructionIndicator
- zeroOperands:
- AND R4, R0, #0b00100000;@testing
- ADD R5, R4;@testing
- B AInstructionIndicator
- oneOperand:
- AND R4, R0, #0b00110000
- ADD R5, R4
- CMP R1, #0b10
- BEQ indicator1B
- CMP R1, #0b01
- BEQ constant1B
- B constant2B
- constant1B:
- ;@ Retrieve Operand and store into R0
- ;@CMP R4, #0b00000010
- B AInstructionIndicator
- ;@AND R1, R0, #0b00011111
- ;@B two
- constant2B:
- ;@ Retrieve Operand and store into R0
- B AInstructionIndicator
- indicator1B:
- ;@ Retrieve Operand and store into R0
- ;@ CMP R4, #0b00000010
- B AInstructionIndicator
- ;@ AND R1, R0, #0b00011111
- ;@ B two
- AInstructionIndicator:
- AND R1, R0, #0b00001111
- ADD R5, R1
- CMP R2, #0b00000011 ;@R2 determines the number of operands
- BEQ zero
- B one
- CInstructionIndicator:
- AND R1, R0, #0b00011111
- ADD R5, R1
- CMP R2, #0b1
- BEQ variable
- B two
- zero:
- CMP R1, #0b00000010
- BEQ PRINT
- CMP R1, #0b00001000
- BEQ RET_POPPED
- CMP R1, #0b00001101
- BEQ VERIFY
- B crash
- one:
- CMP R1, #0b00000101
- BEQ INC
- CMP R1, #0b00000110
- BEQ DEC
- CMP R1, #0b00001111
- BEQ CALL_1N
- CMP R1, #0b00001011
- BEQ RET
- B crash
- two:
- CMP R1, #0b00010100
- BEQ ADD
- CMP R1, #0b00010101
- BEQ SUB
- CMP R1, #0b00010110
- BEQ MUL
- CMP R1, #0b00010111
- BEQ DIV
- CMP R1, #0b00011000
- BEQ MOD
- CMP R1, #0b00000001
- BEQ JE
- CMP R1, #0b00000010
- BEQ JL
- CMP R1, #0b00000011
- BEQ JG
- CMP R1, #0b00011001
- BEQ CALL_2S
- CMP R1, #0b00011010
- BEQ CALL_2N
- CMP R1, #0b00001010
- BEQ TEST_ATTR
- CMP R1, #0b00001011
- BEQ SET_ATTR
- CMP R1, #0b00001100
- BEQ CLEAR_ATTR
- B crash
- variable:
- CMP R1, #0b00011000
- BEQ NOT
- CMP R1, #0b00000101
- BEQ PRINT_CHAR
- CMP R1, #0b00000110
- BEQ PRINT_NUM
- CMP R1, #0b00001000
- BEQ PUSH
- CMP R1, #0b00001001
- BEQ PULL
- B crash
- crash:
- ;@ Print the invalid intruction and its location in HEX
- ;@ Should probably loop back to execute or something
- B crash
- ;@ 0 Operand Instructions
- PRINT:
- B PRINT
- RET_POPPED:
- B RET_POPPED
- VERIFY:
- B VERIFY
- ;@ 1 Operand Instructions
- INC:
- B INC
- DEC:
- B DEC
- CALL_1N:
- B CALL_1N
- RET:
- B RET
- ;@ 2 Operand Instructions
- ADD:
- B ADD
- SUB:
- B SUB
- MUL:
- B MUL
- DIV:
- B DIV
- MOD:
- B MOD
- JE:
- B JE
- JL:
- B JL
- JG:
- B JG
- CALL_2S:
- B CALL_2S
- CALL_2N:
- B CALL_2N
- TEST_ATTR:
- B TEST_ATTR
- SET_ATTR:
- B SET_ATTR
- CLEAR_ATTR:
- B CLEAR_ATTR
- ;@ Variable Operand Instructions
- NOT:
- B NOT
- PRINT_CHAR:
- B PRINT_CHAR
- PRINT_NUM:
- B PRINT_NUM
- PUSH:
- B PUSH
- PULL:
- B PULL
- --------------------------------------------------------------------------------------------------------------------------
- ;@ WORKING ATYPE, BTYPE, CTYPE INSTRUCTION CHECK
- .global asm_main
- .align 4
- memory: .space 2000000
- .align 4
- asm_main:
- LDR R2, =0x000103F0 ;@ should be Zmem
- LDR R3, =0b01010100 ;@ Opcode test
- STRB R3, [R2]
- checkSize:
- ;@ Could check size to see if it even is an OPCODE
- ;@ If it is check the type
- ;@ Else crash
- checkType:
- LDRB R0, [R2]
- LSR R1, R0, #6 ;@ shift 7th and 6th bits
- MOV R4, R1
- CMP R1, #0b11
- BEQ Ctype
- CMP R1, #0b10
- BEQ Atype
- B Btype
- Ctype:
- AND R5, R0, #0b11000000 ;@testing
- LSR R1, R0, #5 ;@ shift 5th bit
- AND R1, #0b00000001;@ Extract 5th bit
- MOV R2, R1 ;@Store for later use in instruction finding
- CMP R1, #0b00000001
- BNE twoOperands
- BEQ variableOperands
- Atype:
- AND R5, R0, #0b11000000 ;@testing
- LSR R1, R0, #4 ;@ shift 4th and 5th bits
- AND R1, #0b00000011;@ Extract 4th and 5th bit
- MOV R2, R1 ;@Store for later use in instruction finding
- CMP R1, #0b00000011
- BEQ zeroOperands
- B oneOperand
- Btype:
- AND R5, R0, #0b11000000
- LSR R1, R0, #6 ;@ shift 6th bit
- AND R1, #0b00000001;@ Extract 6th bit
- MOV R2, R1 ;@Store for later use in instruction finding
- CMP R1, #0b00000001
- BEQ Bindicator1B;@ ------------------ NEEDS TO GO TO FIRST
- B Bconstant1B
- Bindicator1B:
- ;@store into r0
- B Btype2
- Bconstant1B:
- ;@store into r0
- B Btype2
- Btype2:
- ;@AND R5, R0, #0b11000000
- LSR R1, R0, #5 ;@ shift 6th bit
- AND R1, #0b00000001;@ Extract 6th bit
- MOV R2, R1 ;@Store for later use in instruction finding
- CMP R1, #0b00000001
- BEQ B2indicator1B
- B B2constant1B
- B2indicator1B:
- ;@store into R1
- AND R1, R0, #0b00011111
- ADD R5, R1
- B two
- B2constant1B:
- ;@store into R1
- AND R1, R0, #0b00011111
- ADD R5, R1
- B two
- twoOperands:
- ;@ Retrieve each operand and store them into R1 and R0
- B CInstructionIndicator
- variableOperands:
- ;@ Not sure what happens here yet
- B CInstructionIndicator
- zeroOperands:
- AND R4, R0, #0b00100000;@testing
- ADD R5, R4;@testing
- B AInstructionIndicator
- oneOperand:
- AND R4, R0, #0b00110000
- ADD R5, R4
- CMP R1, #0b10
- BEQ Aindicator1B
- CMP R1, #0b01
- BEQ Aconstant1B
- B Aconstant2B
- Aconstant1B:
- ;@ Retrieve Operand and store into R0
- ;@CMP R4, #0b00000010
- B AInstructionIndicator
- ;@AND R1, R0, #0b00011111
- ;@B two
- Aconstant2B:
- ;@ Retrieve Operand and store into R0
- B AInstructionIndicator
- Aindicator1B:
- ;@ Retrieve Operand and store into R0
- ;@ CMP R4, #0b00000010
- B AInstructionIndicator
- ;@ AND R1, R0, #0b00011111
- ;@ B two
- AInstructionIndicator:
- AND R1, R0, #0b00001111
- ADD R5, R1
- CMP R2, #0b00000011 ;@R2 determines the number of operands
- BEQ zero
- B one
- CInstructionIndicator:
- AND R1, R0, #0b00011111
- ADD R5, R1
- CMP R2, #0b1
- BEQ variable
- B two
- zero:
- CMP R1, #0b00000010
- BEQ PRINT
- CMP R1, #0b00001000
- BEQ RET_POPPED
- CMP R1, #0b00001101
- BEQ VERIFY
- B crash
- one:
- CMP R1, #0b00000101
- BEQ INC
- CMP R1, #0b00000110
- BEQ DEC
- CMP R1, #0b00001111
- BEQ CALL_1N
- CMP R1, #0b00001011
- BEQ RET
- B crash
- two:
- CMP R1, #0b00010100
- BEQ ADD
- CMP R1, #0b00010101
- BEQ SUB
- CMP R1, #0b00010110
- BEQ MUL
- CMP R1, #0b00010111
- BEQ DIV
- CMP R1, #0b00011000
- BEQ MOD
- CMP R1, #0b00000001
- BEQ JE
- CMP R1, #0b00000010
- BEQ JL
- CMP R1, #0b00000011
- BEQ JG
- CMP R1, #0b00011001
- BEQ CALL_2S
- CMP R1, #0b00011010
- BEQ CALL_2N
- CMP R1, #0b00001010
- BEQ TEST_ATTR
- CMP R1, #0b00001011
- BEQ SET_ATTR
- CMP R1, #0b00001100
- BEQ CLEAR_ATTR
- B crash
- variable:
- CMP R1, #0b00011000
- BEQ NOT
- CMP R1, #0b00000101
- BEQ PRINT_CHAR
- CMP R1, #0b00000110
- BEQ PRINT_NUM
- CMP R1, #0b00001000
- BEQ PUSH
- CMP R1, #0b00001001
- BEQ PULL
- B crash
- crash:
- ;@ Print the invalid intruction and its location in HEX
- ;@ Should probably loop back to execute or something
- B crash
- ;@ 0 Operand Instructions
- PRINT:
- B PRINT
- RET_POPPED:
- B RET_POPPED
- VERIFY:
- B VERIFY
- ;@ 1 Operand Instructions
- INC:
- B INC
- DEC:
- B DEC
- CALL_1N:
- B CALL_1N
- RET:
- B RET
- ;@ 2 Operand Instructions
- ADD:
- B ADD
- SUB:
- B SUB
- MUL:
- B MUL
- DIV:
- B DIV
- MOD:
- B MOD
- JE:
- B JE
- JL:
- B JL
- JG:
- B JG
- CALL_2S:
- B CALL_2S
- CALL_2N:
- B CALL_2N
- TEST_ATTR:
- B TEST_ATTR
- SET_ATTR:
- B SET_ATTR
- CLEAR_ATTR:
- B CLEAR_ATTR
- ;@ Variable Operand Instructions
- NOT:
- B NOT
- PRINT_CHAR:
- B PRINT_CHAR
- PRINT_NUM:
- B PRINT_NUM
- PUSH:
- B PUSH
- PULL:
- B PULL
- -------------------------------------------------------------------------------------------------------------
- .global asm_main
- .align 4
- Zmemory: .space 2000000
- .align 4
- asm_main:
- LDR R7, =Zmemory ;@ should be Zmem
- LDR R3, =0b01010100 ;@ Opcode test
- STRB R3, [R7]
- checkSize:
- ;@ Could check size to see if it even is an OPCODE
- ;@ If it is check the type
- ;@ Else crash
- checkType:
- LDRB R8, [R2]
- LSR R9, R8, #6 ;@ shift 7th and 6th bits
- MOV R4, R1
- CMP R9, #0b11
- BEQ Ctype
- CMP R9, #0b10
- BEQ Atype
- B Btype
- Ctype:
- ;@AND R5, R0, #0b11000000 ;@testing
- LSR R9, R8, #5 ;@ shift 5th bit
- AND R9, #0b00000001;@ Extract 5th bit
- MOV R10, R9 ;@Store for later use in instruction finding
- CMP R9, #0b00000001
- BNE twoOperands
- BEQ variableOperands
- Atype:
- ;@AND R5, R0, #0b11000000 ;@testing
- LSR R9, R8, #4 ;@ shift 4th and 5th bits
- AND R9, #0b00000011;@ Extract 4th and 5th bit
- MOV R10, R9 ;@Store for later use in instruction finding
- CMP R9, #0b00000011
- BEQ zeroOperands
- B oneOperand
- Btype:
- ;@AND R5, R0, #0b11000000
- LSR R9, R8, #6 ;@ shift 6th bit
- AND R9, #0b00000001;@ Extract 6th bit
- MOV R10, R9 ;@Store for later use in instruction finding
- CMP R9, #0b00000001
- BEQ Bindicator1B;@ ------------------ NEEDS TO GO TO FIRST
- B Bconstant1B
- Bindicator1B:
- ;@store into r0
- B Btype2
- Bconstant1B:
- ;@store into r0
- B Btype2
- Btype2:
- ;@AND R5, R0, #0b11000000
- LSR R9, R8, #5 ;@ shift 6th bit
- AND R9, #0b00000001;@ Extract 6th bit
- MOV R10, R9 ;@Store for later use in instruction finding
- CMP R9, #0b00000001
- BEQ B2indicator1B
- B B2constant1B
- B2indicator1B:
- ;@store into R1
- AND R9, R8, #0b00011111
- ADD R5, R9
- B two
- B2constant1B:
- ;@store into R1
- AND R9, R8, #0b00011111
- ADD R5, R9
- B two
- twoOperands:
- ;@ Retrieve each operand and store them into R1 and R0
- LDRB R11, []
- B CInstructionIndicator
- variableOperands:
- ;@ Not sure what happens here yet
- B CInstructionIndicator
- zeroOperands:
- AND R4, R0, #0b00100000;@testing
- ADD R5, R4;@testing
- B AInstructionIndicator
- oneOperand:
- AND R4, R0, #0b00110000
- ADD R5, R4
- CMP R9, #0b10
- BEQ Aindicator1B
- CMP R9, #0b01
- BEQ Aconstant1B
- B Aconstant2B
- Aconstant1B:
- ;@ Retrieve Operand and store into R0
- ;@CMP R4, #0b00000010
- B AInstructionIndicator
- ;@AND R1, R0, #0b00011111
- ;@B two
- Aconstant2B:
- ;@ Retrieve Operand and store into R0
- B AInstructionIndicator
- Aindicator1B:
- ;@ Retrieve Operand and store into R0
- ;@ CMP R4, #0b00000010
- B AInstructionIndicator
- ;@ AND R1, R0, #0b00011111
- ;@ B two
- AInstructionIndicator:
- AND R9, R0, #0b00001111
- ADD R5, R9
- CMP R10, #0b00000011 ;@R2 determines the number of operands
- BEQ zero
- B one
- CInstructionIndicator:
- AND R9, R0, #0b00011111
- ADD R5, R9
- CMP R10, #0b1
- BEQ variable
- B two
- zero:
- CMP R9, #0b00000010
- BEQ PRINT
- CMP R9, #0b00001000
- BEQ RET_POPPED
- CMP R9, #0b00001101
- BEQ VERIFY
- B crash
- one:
- CMP R9, #0b00000101
- BEQ INC
- CMP R9, #0b00000110
- BEQ DEC
- CMP R9, #0b00001111
- BEQ CALL_1N
- CMP R9, #0b00001011
- BEQ RET
- B crash
- two:
- CMP R9, #0b00010100
- BEQ ADD
- CMP R9, #0b00010101
- BEQ SUB
- CMP R9, #0b00010110
- BEQ MUL
- CMP R9, #0b00010111
- BEQ DIV
- CMP R9, #0b00011000
- BEQ MOD
- CMP R9, #0b00000001
- BEQ JE
- CMP R9, #0b00000010
- BEQ JL
- CMP R9, #0b00000011
- BEQ JG
- CMP R9, #0b00011001
- BEQ CALL_2S
- CMP R9, #0b00011010
- BEQ CALL_2N
- CMP R9, #0b00001010
- BEQ TEST_ATTR
- CMP R9, #0b00001011
- BEQ SET_ATTR
- CMP R9, #0b00001100
- BEQ CLEAR_ATTR
- B crash
- variable:
- CMP R9, #0b00011000
- BEQ NOT
- CMP R9, #0b00000101
- BEQ PRINT_CHAR
- CMP R9, #0b00000110
- BEQ PRINT_NUM
- CMP R9, #0b00001000
- BEQ PUSH
- CMP R9, #0b00001001
- BEQ PULL
- B crash
- crash:
- ;@ Print the invalid intruction and its location in HEX
- ;@ Should probably loop back to execute or something
- B crash
- ;@ 0 Operand Instructions
- PRINT:
- B PRINT
- RET_POPPED:
- B RET_POPPED
- VERIFY:
- B VERIFY
- ;@ 1 Operand Instructions
- INC:
- B INC
- DEC:
- B DEC
- CALL_1N:
- B CALL_1N
- RET:
- B RET
- ;@ 2 Operand Instructions
- ADD:
- B ADD
- SUB:
- B SUB
- MUL:
- B MUL
- DIV:
- B DIV
- MOD:
- B MOD
- JE:
- B JE
- JL:
- B JL
- JG:
- B JG
- CALL_2S:
- B CALL_2S
- CALL_2N:
- B CALL_2N
- TEST_ATTR:
- B TEST_ATTR
- SET_ATTR:
- B SET_ATTR
- CLEAR_ATTR:
- B CLEAR_ATTR
- ;@ Variable Operand Instructions
- NOT:
- B NOT
- PRINT_CHAR:
- B PRINT_CHAR
- PRINT_NUM:
- B PRINT_NUM
- PUSH:
- B PUSH
- PULL:
- B PULL
- .global asm_main
- .align 4
- Zmemory: .space 2000000
- .align 4
- asm_main:
- MOV R12, #0 ;@ONLY USED in div and mod
- MOV R4, #0 ;@ Zpc
- LDR R7, =Zmemory ;@ should be Zmem
- LDRB R3, =0b00011000 ;@ Opcode test
- STRB R3, [R7]
- LDRB R3, =0b00001000 ;@ Operand1 test
- STRB R3, [R7,#1]
- LDRB R3, =0b00000011 ;@ Operand2 test
- STRB R3, [R7,#2]
- ;@ LDRB R3, =0b00001000 ;@ Destination test
- ;@ STRB R3, [R7,#3]
- checkSize:
- ;@ Could check size to see if it even is an OPCODE
- ;@ If it is check the type
- ;@ Else crash
- checkType:
- LDRB R8, [R7]
- ADD R4, #1
- LSR R9, R8, #6 ;@ shift 7th and 6th bits
- ;@MOV R4, R9
- CMP R9, #0b11
- BEQ Ctype
- CMP R9, #0b10
- BEQ Atype
- B Btype
- Ctype:
- ;@AND R5, R0, #0b11000000 ;@testing
- LSR R9, R8, #5 ;@ shift 5th bit
- AND R9, #0b00000001;@ Extract 5th bit
- MOV R10, R9 ;@Store for later use in instruction finding
- CMP R9, #0b00000001
- BNE twoOperands
- BEQ variableOperands
- Atype:
- ;@AND R5, R0, #0b11000000 ;@testing
- LSR R9, R8, #4 ;@ shift 4th and 5th bits
- AND R9, #0b00000011;@ Extract 4th and 5th bit
- MOV R10, R9 ;@Store for later use in instruction finding
- CMP R9, #0b00000011
- BEQ zeroOperands
- B oneOperand
- Btype:
- ;@AND R5, R0, #0b11000000
- LSR R9, R8, #6 ;@ shift 6th bit
- AND R9, #0b00000001;@ Extract 6th bit
- MOV R10, R9 ;@Store for later use in instruction finding
- CMP R9, #0b00000001
- BEQ Bindicator1B;@ ------------------ NEEDS TO GO TO FIRST
- B Bconstant1B
- Bindicator1B:
- ;@store into r0
- B Btype2
- Bconstant1B:
- ;@store into r0
- LDRB R0, [R7,R4]
- ADD R4, #1
- B Btype2
- Btype2:
- ;@AND R5, R0, #0b11000000
- LSR R9, R8, #5 ;@ shift 6th bit
- AND R9, #0b00000001;@ Extract 6th bit
- MOV R10, R9 ;@Store for later use in instruction finding
- CMP R9, #0b00000001
- BEQ B2indicator1B
- B B2constant1B
- B2indicator1B:
- ;@store into R1
- AND R9, R8, #0b00011111
- B two
- B2constant1B:
- ;@store into R1
- LDRB R1, [R7, R4]
- ADD R4, #1
- AND R9, R8, #0b00011111
- B two
- twoOperands:
- ;@ Retrieve each operand and store them into R1 and R0
- LDRB R0, [R7,R4]
- ADD R4, #1
- LDRB R1, [R7, R4]
- ADD R4, #1
- B CInstructionIndicator
- variableOperands:
- ;@ Not sure what happens here yet
- B CInstructionIndicator
- zeroOperands:
- AND R4, R0, #0b00100000;@testing
- ADD R5, R4;@testing
- B AInstructionIndicator
- oneOperand:
- AND R4, R0, #0b00110000
- ADD R5, R4
- CMP R9, #0b10
- BEQ Aindicator1B
- CMP R9, #0b01
- BEQ Aconstant1B
- B Aconstant2B
- Aconstant1B:
- ;@ Retrieve Operand and store into R0
- ;@CMP R4, #0b00000010
- B AInstructionIndicator
- ;@AND R1, R0, #0b00011111
- ;@B two
- Aconstant2B:
- ;@ Retrieve Operand and store into R0
- LDRH R0, [R7,R4]
- ADD R4, #1
- B AInstructionIndicator
- Aindicator1B:
- ;@ Retrieve Operand and store into R0
- ;@ CMP R4, #0b00000010
- B AInstructionIndicator
- ;@ AND R1, R0, #0b00011111
- ;@ B two
- AInstructionIndicator:
- AND R9, R0, #0b00001111
- ADD R5, R9
- CMP R10, #0b00000011 ;@R2 determines the number of operands
- BEQ zero
- B one
- CInstructionIndicator:
- AND R9, R0, #0b00011111
- ADD R5, R9
- CMP R10, #0b1
- BEQ variable
- B two
- zero:
- CMP R9, #0b00000010
- BEQ PRINT
- CMP R9, #0b00001000
- BEQ RET_POPPED
- CMP R9, #0b00001101
- BEQ VERIFY
- B crash
- one:
- CMP R9, #0b00000101
- BEQ INC
- CMP R9, #0b00000110
- BEQ DEC
- CMP R9, #0b00001111
- BEQ CALL_1N
- CMP R9, #0b00001011
- BEQ RET
- B crash
- two:
- CMP R9, #0b00010100
- BEQ ADD
- CMP R9, #0b00010101
- BEQ SUB
- CMP R9, #0b00010110
- BEQ MUL
- CMP R9, #0b00010111
- BEQ DIV
- CMP R9, #0b00011000
- BEQ MOD
- CMP R9, #0b00000001
- BEQ JE
- CMP R9, #0b00000010
- BEQ JL
- CMP R9, #0b00000011
- BEQ JG
- CMP R9, #0b00011001
- BEQ CALL_2S
- CMP R9, #0b00011010
- BEQ CALL_2N
- CMP R9, #0b00001010
- BEQ TEST_ATTR
- CMP R9, #0b00001011
- BEQ SET_ATTR
- CMP R9, #0b00001100
- BEQ CLEAR_ATTR
- B crash
- variable:
- CMP R9, #0b00011000
- BEQ NOT
- CMP R9, #0b00000101
- BEQ PRINT_CHAR
- CMP R9, #0b00000110
- BEQ PRINT_NUM
- CMP R9, #0b00001000
- BEQ PUSH
- CMP R9, #0b00001001
- BEQ PULL
- B crash
- crash:
- ;@ Print the invalid intruction and its location in HEX
- ;@ Should probably loop back to execute or something
- B crash
- ;@ 0 Operand Instructions
- PRINT:
- B PRINT
- RET_POPPED:
- B RET_POPPED
- VERIFY:
- B VERIFY
- ;@ 1 Operand Instructions
- INC:
- B INC
- DEC:
- B DEC
- CALL_1N:
- B CALL_1N
- RET:
- B RET
- ;@ 2 Operand Instructions
- ADD:
- ADD R11, R0, R1 ;@R11 is currently the destination but this most likely will have to be stored in some locaton in Zmemory
- B crash;@ should CHANGE, needs to reloop
- SUB:
- SUB R11, R0, R1 ;@R11 is currently the destination but this most likely will have to be stored in some locaton in Zmemory
- B crash ;@ should CHANGE, needs to reloop
- MUL:
- MUL R11, R0, R1 ;@R11 is currently the destination but this most likely will have to be stored in some locaton in Zmemory
- B crash ;@ should CHANGE, needs to reloop
- DIV:
- SUBS R0, R1
- ADDGE R12, #1
- BPL DIV
- MOV R11, R12
- B crash
- MOD:
- SUBS R0, R1
- BPL MOD
- ADD R11, R0, R1
- B crash
- JE:
- B JE
- JL:
- B JL
- JG:
- B JG
- CALL_2S:
- B CALL_2S
- CALL_2N:
- B CALL_2N
- TEST_ATTR:
- B TEST_ATTR
- SET_ATTR:
- B SET_ATTR
- CLEAR_ATTR:
- B CLEAR_ATTR
- ;@ Variable Operand Instructions
- NOT:
- B NOT
- PRINT_CHAR:
- B PRINT_CHAR
- PRINT_NUM:
- B PRINT_NUM
- PUSH:
- B PUSH
- PULL:
- B PULL
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement