Skip to content

Instantly share code, notes, and snippets.

@vivekannan
Last active August 29, 2015 14:14
Show Gist options
  • Save vivekannan/6f87cfaa27a2d2a2dba0 to your computer and use it in GitHub Desktop.
Save vivekannan/6f87cfaa27a2d2a2dba0 to your computer and use it in GitHub Desktop.
A 8051 assembly program that can execute the 8085 instruction set from external memory.
;Little Endian --> Lower bytes in lower address and higher bytes in higher address.
EQU LOOKUP #0FEH
EQU ACC 0E0H
EQU EPCL 14H
EQU EPCH 15H
EQU ESPL 16H
EQU ESPH 17H
EQU EL 18H
EQU EH 19H
EQU EE 1AH
EQU ED 1BH
EQU EC 1CH
EQU EB 1DH
EQU EF 1EH
EQU EACC 1FH
EQU EPSW 20H
EQU EBCY 00H
EQU EBP 02H
EQU EBAC 04H
EQU EBZ 06H
EQU EBS 07H
;The DPTR register serves both as the Program Counter (PC) for the external memory
;as well as the internal lookup table register. Because of this, the contents of DPTR
;are frequently stored in the internal RAM locations 06 & 07 while the DPTR is used for
;internal lookup table referencing.
;
;The DPTR is initialised with the value FFFF and incremented to start the execution of the hexcodes
;in the external memory sequentially. The MOVX instruction is used to fetch the hexcodes
;from the external memory to the accumulator A and use it as a key for the lookup table address.
;The lookup table contains hexcodes which are the addresses where the subroutine relating
;to current opcode is written.
;
;Once the address is fetched from the lookup table, it is pushed into the stack and a rogue
;RET instruction is executed to perform an illegal jump to the address at the top of the stack.
;The contents of DPTR are relinquished from the internal RAM locations 06 & 07 before the jump
;so that the program can continue to read hexcodes from the external memory.
;
;Order of execution:
;
; > Read Hexcode from EXMEM.
; > Find subroutine address from lookup table using the hexcode as a key.
; > Jump to the address and execute the subroutine to perform the necessary actions.
; > Use DPTR to read data from the EXMEM if necessary for the current opcode.
; > Repeat the steps by illegally jumping out of the subroutine again.
;Start reading hexcodes from EXMEM.
MOV DPTR, #0FFFFH;
;Label where the looping starts. DPTR is incremented to point to the next hexcode.
PROGRESS:
INC DPTR;
;Move hexcode into the accumulator from EXMEM. This is done sequentially until the
;end of the EXMEM is reached. Once reached, the process os started again.
MOVX A, @DPTR;
;Preserve the contents of DPTR into the internal RAM before using it for lookup
;table referencing.
LCALL SAVEDPTR
;Move the constant lookup higher byte into DPH and thw lower byte to DPL and clear
;the accumulator as it will be added to DPTR during the MOVC instruction.
MOV DPH, LOOKUP;
MOV DPL, A;
CLR A;
;Perfrom MOVC once to get lower byte of the jump address and push it into stack
MOVC A, @A+DPTR
PUSH ACC
;Increment DPH to point to the next lookup table with the same lower byte.
INC DPH
CLR A;
;Fetch the higher address from the lookup table now and push it to stack.
MOVC A, @A+DPTR
PUSH ACC;
;Restore the contents of DPTR to point to the EXMEM.
LCALL RESTOREDPTR
;Rogue RET to jump to subroutine to perform instructions related to the current
;opcode. Since the DPTR points to the EXMEM, it can be used to read data from the
;EXMEM necessary for the current opcode in the subroutine.
RET
SAVEDPTR: MOV EPCH, DPH
MOV EPCL, DPL
RET
RESTOREDPTR: MOV DPH, EPCH
MOV DPL, EPCL
RET
;Instruction: NOP
;Opcode: 00
;Description: Do nothing.
LJMP PROGRESS
;Instruction: LXI B, data16
;Opcode: 01
;Description: Move 16 bit data in B register pair (BC).
;Increment DPTR to point to MSB of data16 and move it into the internal
;accumulator with MOVX.
INC DPTR;
MOVX A, @DPTR;
;Move MSB of data16 in accumulator into EB;
MOV EB, A;
;Get LSB of data16 from EXMEM and move it into A.
INC DPTR;
MOVX A, @DPTR;
;Move LSB of data16 in accumulator into EC;
MOV EC, A;
LJMP PROGRESS;
;Instruction: STAX B
;Opcode: 02
;Description: Contents of accumulator are moved into the memory location pointed
;by the B register pair (BC).
;Save value of DPTR in internal memory.
LCALL SAVEDPTR
;Move content in B register pair (BC) in DPTR to point to EXMEM.
MOV DPH, EB;
MOV DPL, EC;
;Move contents of EACC into A to move to EXMEM
MOV A, EACC;
MOVX @DPTR, A
;Restore DPTR to point to end of instruction.
LCALL RESTOREDPTR
LJMP PROGRESS
;Instruction: INX B
;Opcode: 03
;Description: Increment the content of the register pair B.
;Clear carry flag to prevent confusion.
CLR C
;Move EC to A and increment value by adding one. This is to ensure that the carry
;flag is set in case of overflow. Move A to EC.
MOV A, EC
ADD A, #01;
MOV EC, A
;Jump out of instruction if carry is not set, else increment B.
JNC DONE03
INC EB
DONE03: LJMP PROGRESS
;Instruction: INR B
;Opcode: 04
;Description: Increments the content of B register. Affects flags.
;Clear carry bit to avoid confusion.
CLR C
;Move EB to A and add one to increment with carry notification.
MOV A, EB
ADD A, #01;
MOV EB, A
;Check for carry flag and set bits as needed.
JNC DONE04
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
DONE04: LJMP PROGRESS
;Instruction: DCR B
;Opcode: 05
;Description: Decrements the content of B register. Affects flags.
;Move EB to A and check if zero.
MOV A, EB
JNZ DONE05
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
DONE05: DEC EB
LJMP PROGRESS
;Instruction: MVI B, data8
;Opcode: 06
;Description: Given data8 is stored in the register B.
;Increment DPTR to point to data8.
INC DPTR
;Move data8 into A and then into EB.
MOVX A, @DPTR
MOV EB, A
LJMP PROGRESS
;Instruction: RLC
;Opcode: 07
;Description: Left rotate EACC once and make EBCY == D7 of EACC
;Clear carry to avoid confusion.
CLR C
;Move EACC into A and rotate left using RLC. Carry bit now contains D7.
MOV A, EACC
RLC A
;If carry is not set, D7 is zero. Hence jump.
JNC DONE07
;Else, set D0 to match with D7 as per the instruction.
SETB A.0
;;;;; Write code to set flags as per the instruction. ;;;;;
;Move A into EACC.
DONE07: MOV EACC, A
LJMP PROGRESS
;Instruction: DSUB
;Opcode: 08
;Description: Undocumented.
LJMP PROGRESS
;Instruction: DAD B
;Opcode: 09
;Description: Contents of register pair B are added with register pair
;H and the EBCY is set if result is larger than 16-bits.
;Clear carry to avoid confusion.
CLR C;
;Move the LSB of register H to A and LSB of B pair with it and move it back to
;EL.
MOV A, EL
ADD A, EC
MOV EL, A
;Move the H pairs's MSB into A and add MSB of B pair to it with the previous carry.
MOV A, EH
ADDC A, EB
MOV EH, A
JNC DONE09
;Set EBCY if CY is set.
SETB EBCY
DONE09: LJMP PROGRESS
;Instruction: LDAX B
;Opcode: 0A
;Description: Contents of the memory location pointed by the B register pair (BC)
;is moved into EACC.
;Save value of DPTR in internal memory.
LCALL SAVEDPTR
;Move content in B register pair (BC) in DPTR to point to EXMEM.
MOV DPH, EB;
MOV DPL, EC;
;Move contents EXMEM pointed by DPTR to A and then to EACC.
MOVX A, @DPTR
MOV EACC, A;
;Restore DPTR to point to end of instruction.
LCALL RESTOREDPTR
LJMP PROGRESS
;Instruction: DCX B
;Opcode: 0B
;Description: Decrements the content of the register pair B.
;Move EC to A check if zero. Decrement EB if true.
MOV A, EC
JNZ DONE0B;
DEC EB;
DONE0B: DEC EC;
LJMP PROGRESS
;Instruction: INR C
;Opcode: 0C
;Description: Increments the content of register C.
;Clear carry bit to avoid confusion.
CLR C
;Move EC to A and add one to increment with carry notification.
MOV A, EC
ADD A, #01;
MOV EC, A
;Check for carry flag and set bits as needed.
JNC DONE0C
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
DONE0C: LJMP PROGRESS
;Instruction: DCR C
;Opcode: 0D
;Description: Decrements the content of register C.
;Clear carry bit to avoid confusion.
CLR C
;Move EC to A and add FF to decrement with carry notification.
MOV A, EC
ADD A, #0FFH;
MOV EC, A
;Check for carry flag and set bits as needed.
JNC DONE0D
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
DONE0D: LJMP PROGRESS
;Instruction: MVI C, data8
;Opcode: 0E
;Description: Given data8 is stored in the register C.
;Increment DPTR to point to data8.
INC DPTR
;Move data8 into A and then into EC.
MOVX A, @DPTR
MOV EC, A
LJMP PROGRESS
;Instruction: RRC
;Opcode: 0F
;Description: Right rotate EACC once and make EBCY == D7 of EACC
;Clear carry to avoid confusion.
CLR C
;Move EACC into A and rotate left using RLC. Carry bit now contains D7.
MOV A, EACC
RRC A
;If carry is not set, D7 is zero. Hence jump.
JNC DONE0F
;Else, set D0 to match with D7 as per the instruction.
SETB A.7
;;;;; Write code to set flags as per the instruction. ;;;;;
;Move A into EACC.
DONE0F: MOV EACC, A
LJMP PROGRESS
;Instruction: ARHL
;Opcode: 10
;Description: Undocumented.
LJMP PROGRESS
;Instruction: LXI D, data16
;Opcode: 11
;Description: Move 16 bit data in D register pair (DE).
;Increment DPTR to point to MSB of data16 and move it into the internal
;accumulator with MOVX.
INC DPTR;
MOVX A, @DPTR;
;Move MSB of data16 in accumulator into ED;
MOV ED, A;
;Get LSB of data16 from EXMEM and move it into A.
INC DPTR;
MOVX A, @DPTR;
;Move LSB of data16 in accumulator into EE;
MOV EE, A;
LJMP PROGRESS;
;Instruction: STAX D
;Opcode: 12
;Description: Contents of accumulator are moved into the memory location pointed
;by the D register pair (DE).
;Save value of DPTR in internal memory.
LCALL SAVEDPTR
;Move content in B register pair (BC) in DPTR to point to EXMEM.
MOV DPH, ED;
MOV DPL, EE;
;Move contents of EACC into A to move to EXMEM
MOV A, EACC;
MOVX @DPTR, A
;Restore DPTR to point to end of instruction.
LCALL RESTOREDPTR
LJMP PROGRESS
;Instruction: INX D
;Opcode: 13
;Description: Increment the content of the register pair D.
;Clear carry flag to prevent confusion.
CLR C
;Move EE to A and increment value by adding one. This is to ensure that the carry
;flag is set in case of overflow. Move A to EE.
MOV A, EE
ADD A, #01;
MOV EE, A
;Jump out of instruction if carry is not set, else increment ED.
JNC DONE13
INC ED
DONE13: LJMP PROGRESS
;Instruction: INR D
;Opcode: 14
;Description: Increments the content of D register. Affects flags.
;Clear carry bit to avoid confusion.
CLR C
;Move ED to A and add one to increment with carry notification.
MOV A, ED
ADD A, #01;
MOV ED, A
;Check for carry flag and set bits as needed.
JNC DONE14
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
DONE14: LJMP PROGRESS
;Instruction: DCR D
;Opcode: 15
;Description: Decrements the content of D register. Affects flags.
;Move ED to A and check if zero.
MOV A, ED
JNZ DONE15
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
DONE15: DEC ED
LJMP PROGRESS
;Instruction: MVI D, data8
;Opcode: 16
;Description: Given data8 is stored in the register D.
;Increment DPTR to point to data8.
INC DPTR
;Move data8 into A and then into ED.
MOVX A, @DPTR
MOV ED, A
LJMP PROGRESS
;Instruction: RAL
;Opcode: 17
;Description: Left rotate EACC once through EBCY.
;Clear carry to avoid confusion.
CLR C
;Move EACC into A and rotate left using RLC. Carry bit now contains D7.
MOV A, EACC
RLC A
;Set A.0 if EBCY is set else move on with CY.
JNB EBCY, CHECKCY
SETB A.0
;Pre-emptively clear EBCY and see if CY is set. Set EBCY if so.
CHECKCY: CLR EBCY
JNC DONE17
SETB EBCY
DONE17: MOV EACC, A
LJMP PROGRESS
;Instruction: RDEL
;Opcode: 18
;Description: Undocumented.
LJMP PROGRESS
;Instruction: DAD D
;Opcode: 19
;Description: Contents of register pair D are added with register pair
;H and the EBCY is set if result is larger than 16-bits.
;Clear carry to avoid confusion.
CLR C;
;Move the LSB of register H to A and LSB of D pair with it and move it back to
;EL.
MOV A, EL
ADD A, EE
MOV EL, A
;Move the H pairs's MSB into A and add MSB of D pair to it with the previous carry.
MOV A, EH
ADDC A, ED
MOV EH, A
JNC DONE19
;Set EBCY if CY is set.
SETB EBCY
DONE19: LJMP PROGRESS
;Instruction: LDAX D
;Opcode: 1A
;Description: Contents of the memory location pointed by the D register pair (DE)
;is moved into EACC.
;Save value of DPTR in internal memory.
LCALL SAVEDPTR
;Move content in D register pair (DE) in DPTR to point to EXMEM.
MOV DPH, ED;
MOV DPL, EE;
;Move contents EXMEM pointed by DPTR to A and then to EACC.
MOVX A, @DPTR
MOV EACC, A;
;Restore DPTR to point to end of instruction.
LCALL RESTOREDPTR
LJMP PROGRESS
;Instruction: DCX D
;Opcode: 1B
;Description: Decrements the content of the register pair D.
;Move EE to A check if zero. Decrement ED if true.
MOV A, EE
JNZ DONE1B;
DEC ED;
DONE1B: DEC EE;
LJMP PROGRESS
;Instruction: INR E
;Opcode: 1C
;Description: Increments the content of register E.
;Clear carry bit to avoid confusion.
CLR C
;Move EE to A and add one to increment with carry notification.
MOV A, EE
ADD A, #01;
MOV EE, A
;Check for carry flag and set bits as needed.
JNC DONE1C
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
DONE1C: LJMP PROGRESS
;Instruction: DCR E
;Opcode: 1D
;Description: Decrements the content of register E.
;Clear carry bit to avoid confusion.
CLR C
;Move EE to A and add FF to decrement with carry notification.
MOV A, EE
ADD A, #0FFH;
MOV EE, A
;Check for carry flag and set bits as needed.
JNC DONE1D
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
DONE1D: LJMP PROGRESS
;Instruction: MVI E, data8
;Opcode: 1E
;Description: Given data8 is stored in the register E.
;Increment DPTR to point to data8.
INC DPTR
;Move data8 into A and then into EE.
MOVX A, @DPTR
MOV EE, A
LJMP PROGRESS
;Instruction: RAR
;Opcode: 1F
;Description: Right rotate EACC once through EBCY.
;Clear carry to avoid confusion.
CLR C
;Move EACC into A and rotate left using RLC. Carry bit now contains D7.
MOV A, EACC
RLC A
;Set A.0 if EBCY is set else move on with CY.
JNB EBCY, CHECKCY
SETB A.7
;Pre-emptively clear EBCY and see if CY is set. Set EBCY if so.
CHECKCY: CLR EBCY
JNC DONE17
SETB EBCY
DONE17: MOV EACC, A
LJMP PROGRESS
;Instruction: RIM
;Opcode: 20
;Description: ???
LJMP PROGRESS
;Instruction: LXI H, data16
;Opcode: 21
;Description: Move 16 bit data in H register pair (HL).
;Increment DPTR to point to MSB of data16 and move it into the internal
;accumulator with MOVX.
INC DPTR;
MOVX A, @DPTR;
;Move MSB of data16 in accumulator into EH;
MOV EH, A;
;Get LSB of data16 from EXMEM and move it into A.
INC DPTR;
MOVX A, @DPTR;
;Move LSB of data16 in accumulator into EL;
MOV EL, A;
LJMP PROGRESS;
;Instruction: SHLD address16
;Opcode: 22
;Description: Contents of the register L are stored in the given address and the
;contents of the register H are stored in the next address.
;Increment DPTR to point to MSB of address16. Move MSB of address16 to A
;and then PUSH it into the stack.
INC DPTR
MOVX A, @DPTR
PUSH ACC
;Increment DPTR and get LSB into A and PUSH again.
INC DPTR
MOVX A, @DPTR
PUSH ACC
;Save the value of DPTR
LCALL SAVEDPTR
;POP address16 into DPTR.
POP DPL
POP DPH
;Move register L to A and transfer it to EXMEM using DPTR.
MOV A, EL
MOVX @DPTR, A
;Increment DPTR to point to next EXMEM location and move the register H.
;using MOVX.
INC DPTR
MOV A, EH
MOVX @DPTR, A
;Restore content of DPTR.
LCALL RESTOREDPTR
LJMP PROGRESS
;Instruction: INX H
;Opcode: 23
;Description: Increment the content of the register pair H.
;Clear carry flag to prevent confusion.
CLR C
;Move EL to A and increment value by adding one. This is to ensure that the carry
;flag is set in case of overflow. Move A to EL.
MOV A, EL
ADD A, #01;
MOV EL, A
;Jump out of instruction if carry is not set, else increment EH.
JNC DONE23
INC EH
DONE23: LJMP PROGRESS
;Instruction: INR H
;Opcode: 24
;Description: Increments the content of H register. Affects flags.
;Clear carry bit to avoid confusion.
CLR C
;Move EH to A and add one to increment with carry notification.
MOV A, EH
ADD A, #01;
MOV EH, A
;Check for carry flag and set bits as needed.
JNC DONE24
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
DONE24: LJMP PROGRESS
;Instruction: DCR H
;Opcode: 25
;Description: Decrements the content of H register. Affects flags.
;Move EH to A and check if zero.
MOV A, EH
JNZ DONE25
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
DONE25: DEC EH
LJMP PROGRESS
;Instruction: MVI H, data8
;Opcode: 26
;Description: Given data8 is stored in the register H.
;Increment DPTR to point to data8.
INC DPTR
;Move data8 into A and then into EH.
MOVX A, @DPTR
MOV EH, A
LJMP PROGRESS
;Instruction: DAA
;Opcode: 27
;Description: The content of EACC are converted to two 4-bit BCD.
;Move EACC to A and perform DA instruction and move it back in.
MOV A, EACC
DA A
MOV EACC, A
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
LJMP PROGRESS
;Instruction: LDHI data8
;Opcode: 28
;Description: Undocumented.
LJMP PROGRESS
;Instruction: DAD H
;Opcode: 29
;Description: Contents of register pair H are added with register pair
;H and the EBCY is set if result is larger than 16-bits.
;Clear carry to avoid confusion.
CLR C;
;Move the LSB of register H to A and LSB of H pair with it and move it back to
;EL.
MOV A, EL
ADD A, EL
MOV EL, A
;Move the H pairs's MSB into A and add MSB of H pair to it with the previous carry.
MOV A, EH
ADDC A, EH
MOV EH, A
JNC DONE29
;Set EBCY if CY is set.
SETB EBCY
DONE29: LJMP PROGRESS
;Instruction: LHLD address16
;Opcode: 2A
;Description: The contents of the given memory location is stored in register L
;and the contents of the next memory location is stored in register H.
;Increment DPTR to point to MSB of address16 and get it into A.
INC DPTR
MOVX A, @DPTR
;Push A into the stack and repeat to get LSB of address16.
PUSH ACC
INC DPTR
MOVX A, @DPTR
PUSH ACC
;Save contents of DPTR.
LCALL SAVEDPTR
;Use address16 from stack and transfer contents of location in register EL.
POP DPL
POP DPH
MOVX A, @DPTR
MOV EL, A
;Increment DPTR to get next data and move it into EH.
INC DPTR
MOVX A, @DPTR
MOV EH, A
;Restore the contents of DPTR>
LCALL RESTOREDPTR
LJMP PROGRESS
;Instruction: DCX H
;Opcode: 2B
;Description: Decrements the content of the register pair H.
;Move EL to A check if zero. Decrement ED if true.
MOV A, EL
JNZ DONE2B;
DEC EH;
DONE2B: DEC EL;
LJMP PROGRESS
;Instruction: INR L
;Opcode: 2C
;Description: Increments the content of register L.
;Clear carry bit to avoid confusion.
CLR C
;Move EL to A and add one to increment with carry notification.
MOV A, EL
ADD A, #01;
MOV EL, A
;Check for carry flag and set bits as needed.
JNC DONE2C
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
DONE2C: LJMP PROGRESS
;Instruction: DCR L
;Opcode: 2D
;Description: Decrements the content of register L.
;Clear carry bit to avoid confusion.
CLR C
;Move EL to A and add FF to decrement with carry notification.
MOV A, EL
ADD A, #0FFH;
MOV EL, A
;Check for carry flag and set bits as needed.
JNC DONE2D
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
DONE2D: LJMP PROGRESS
;Instruction: MVI L, data8
;Opcode: 2E
;Description: Given data8 is stored in the register L.
;Increment DPTR to point to data8.
INC DPTR
;Move data8 into A and then into EL.
MOVX A, @DPTR
MOV EL, A
LJMP PROGRESS
;Instruction: CMA
;Opcode: 2F
;Description: Contents of EACC are complemented.
;Move EACC to A and then complement A and move it back to EACC.
MOV A, EACC
CPL A
MOV EACC, A
LJMP PROGRESS
;Instruction: SIM
;Opcode: 30
;Description: ???
LJMP PROGRESS
;Instruction: LXI SP, data16
;Opcode: 31
;Description: Move 16 bit data into the ESP.
;Increment DPTR to point to MSB of data16 and move it into the internal
;accumulator with MOVX.
INC DPTR;
MOVX A, @DPTR;
;Move MSB of data16 in accumulator into ESPH;
MOV ESPH, A;
;Get LSB of data16 from EXMEM and move it into A.
INC DPTR;
MOVX A, @DPTR;
;Move LSB of data16 in accumulator into ESPL;
MOV ESPL, A;
LJMP PROGRESS;
;Instruction: STA address16
;Opcode: 32
;Description: The contents of EACC are stored in the location specified by address16.
;Get the MSB and LSB of address16 and push them into the stack.
INC DPTR
MOVX A, @DPTR
PUSH ACC
INC DPTR
MOVX A, @DPTR
PUSH ACC
;Save contents of DPTR.
LCALL SAVEDPTR
;Pop address16 into DPTR and move EACC into address16 location.
POP DPL
POP DPH
MOV A, EACC
MOVX @DPTR, A
;Restore value of DPTR
LCALL RESTOREDPTR
LJMP PROGRESS
;Instruction: INX SP
;Opcode: 33
;Description: Increment the content of ESP.
;Clear carry flag to prevent confusion.
CLR C
;Move EL to A and increment value by adding one. This is to ensure that the carry
;flag is set in case of overflow. Move A to EL.
MOV A, ESPL
ADD A, #01;
MOV ESPL, A
;Jump out of instruction if carry is not set, else increment ESPH.
JNC DONE33
INC ESPH
DONE33: LJMP PROGRESS
;Instruction: INR M
;Opcode: 34
;Description: Increments the content of the memory location pointed by register
;pair H (HL). Flags are affected.
;Clear carry bit to avoid confusion.
CLR C
;Save contents of DPTR.
LCALL SAVEDPTR
;Move contents of register H into DPTR and use the value as and address16 to
;access content to be incremented.
MOV DPH, EH
MOV DPL, EL
MOVX A, @DPTR
ADD A, #01;
MOVX @DPTR, A
;Restore contents of DPTR
LCALL RESTOREDPTR
;Check for carry flag and set bits as needed.
JNC DONE34
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
DONE34: LJMP PROGRESS
;Instruction: DCR M
;Opcode: 35
;Description: Decrements the content of the memory location pointed by register
;pair H (HL). Flags are affected.
;Save contents of DPTR.
LCALL SAVEDPTR
;Move contents of register H into DPTR and use the value as and address16 to
;access content to be incremented.
MOV DPH, EH
MOV DPL, EL
MOVX A, @DPTR
;Check if A in zero and jump accordingly.
JNZ DONE35
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
DONE35: DEC A
MOVX @DPTR, A
;Restore contents of DPTR
LCALL RESTOREDPTR
LJMP PROGRESS
;Instruction: MVI M, data8
;Opcode: 36
;Description: Given data8 is stored in the memory location pointed by the
;register pair H (HL).
;Increment DPTR to point to data8.
INC DPTR
;Move data8 into A and then into EH.
MOVX A, @DPTR
;Save DPTR
LCALL SAVEDPTR
;Move content of register pair H into DPTR
MOV DPH, EH
MOV DPL, EL
;Move contents of A into memory pointed by DPTR
MOVX @DPTR, A
;Restore DPTR
LCALL RESTOREDPTR
LJMP PROGRESS
;Instruction: STC
;Opcode: 37
;Description: EBCY is set.
SETB EBCY
LJMP PROGRESS
;Instruction: LDSI data8
;Opcode: 38
;Description: Undocemented.
LJMP PROGRESS
;Instruction: DAD SP
;Opcode: 39
;Description: Contents of register pair H are added with ESP and the EBCY is set
;if result is larger than 16-bits.
;Clear carry to avoid confusion.
CLR C;
;Move the LSB of register H to A and LSB of H pair with it and move it back to
;EL.
MOV A, EL
ADD A, ESPL
MOV ESPL, A
;Move the H pairs's MSB into A and add MSB of H pair to it with the previous carry.
MOV A, EH
ADDC A, ESPH
MOV ESPH, A
JNC DONE39
;Set EBCY if CY is set.
SETB EBCY
DONE39: LJMP PROGRESS
;Instruction: LDA address16
;Opcode: 3A
;Description: Contents of address16 is transferred to EACC.
;Get address16 and push into stack.
INC DPTR
MOVX A, @DPTR
PUSH ACC
INC DPTR
MOVX A, @DPTR
PUSH ACC
;Save DPTR
LCALL SAVEDPTR
;Pop address16 into DPTR and move content of address16 into A
POP DPL
POP DPH
MOVX A, @DPTR
MOV EACC, A
;Restore DPTR
LCALL RESTOREDPTR
LJMP PROGRESS
;Instruction: DCX SP
;Opcode: 3B
;Description: Decrements the content of ESP.
;Move ESPL to A check if zero. Decrement ED if true.
MOV A, ESPL
JNZ DONE3B;
DEC ESPH;
DONE3B: DEC ESPL;
LJMP PROGRESS
;Instruction: INR A
;Opcode: 3C
;Description: Increments the content of EACC.
;Clear carry bit to avoid confusion.
CLR C
;Move EL to A and add one to increment with carry notification.
MOV A, EACC
ADD A, #01;
MOV EACC, A
;Check for carry flag and set bits as needed.
JNC DONE3C
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
DONE3C: LJMP PROGRESS
;Instruction: DCR A
;Opcode: 3D
;Description: Decrements the content of EACC.
;Clear carry bit to avoid confusion.
CLR C
;Move EACC to A and add FF to decrement with carry notification.
MOV A, EACC
ADD A, #0FFH;
MOV EACC, A
;Check for carry flag and set bits as needed.
JNC DONE3D
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
DONE3D: LJMP PROGRESS
;Instruction: MVI A, data8
;Opcode: 3E
;Description: Given data8 is stored in EACC.
;Increment DPTR to point to data8.
INC DPTR
;Move data8 into A and then into EL.
MOVX A, @DPTR
MOV EACC, A
LJMP PROGRESS
;Instruction: CMC
;Opcode: 3F
;Description: Carry flag is complemented.
CPL EBCY
LJMP PROGRESS
;Instruction: MOV B, B
;Opcode: 40
;Description: Move contents of register B into B.
LJMP PROGRESS
;Instruction: MOV B, C
;Opcode: 41
;Description: Move contents of register C into B.
MOV EB, EC
LJMP PROGRESS
;Instruction: MOV B, D
;Opcode: 42
;Description: Move contents of register D into B.
MOV EB, ED
LJMP PROGRESS
;Instruction: MOV B, E
;Opcode: 43
;Description: Move contents of register E into B.
MOV EB, EE
LJMP PROGRESS
;Instruction: MOV B, EH
;Opcode: 44
;Description: Move contents of register H into B.
MOV EB, EH
LJMP PROGRESS
;Instruction: MOV B, EL
;Opcode: 45
;Description: Move contents of register L into B.
MOV EB, EL
LJMP PROGRESS
;Instruction: MOV B, M
;Opcode: 46
;Description: Move contents of memory location given by HL into B.
;Save DPTR
LCALL SAVEDPTR
;Move HL into DPTR and get data from EXMEM
MOV DPH, EH
MOV DPL, EL
MOVX A, @DPTR
MOV EB, A
;Restore DPTR
LCALL RESTOREDPTR
LJMP PROGRESS
;Instruction: MOV B, A
;Opcode: 47
;Description: Move contents of EACC into B.
MOV EB, EACC
LJMP PROGRESS
;Instruction: MOV C, B
;Opcode: 48
;Description: Move contents of B into C.
MOV EC, EB
LJMP PROGRESS
;Instruction: MOV C, C
;Opcode: 49
;Description: Move contents of C into C.
LJMP PROGRESS
;Instruction: MOV C, D
;Opcode: 4A
;Description: Move contents of D into C.
MOV EC, ED
LJMP PROGRESS
;Instruction: MOV C, E
;Opcode: 4B
;Description: Move contents of E into C.
MOV EC, EE
LJMP PROGRESS
;Instruction: MOV C, EH
;Opcode: 4C
;Description: Move contents of H into C.
MOV EC, EH
LJMP PROGRESS
;Instruction: MOV C, EL
;Opcode: 4D
;Description: Move contents of L into C.
MOV EC, EL
LJMP PROGRESS
;Instruction: MOV C, M
;Opcode: 4E
;Description: Move contents of memory location given by H into C.
;Save DPTR
LCALL SAVEDPTR
;Move HL into DPTR and get data from EXMEM
MOV DPH, EH
MOV DPL, EL
MOVX A, @DPTR
MOV EC, A
;Restore DPTR
LCALL RESTOREDPTR
LJMP PROGRESS
;Instruction: MOV C, A
;Opcode: 4F
;Description: Move contents of EACC into C.
MOV EC, EACC
LJMP PROGRESS
;Instruction: MOV D, B
;Opcode: 50
;Description: Move contents of register B into D.
MOV ED, EB
LJMP PROGRESS
;Instruction: MOV D, C
;Opcode: 51
;Description: Move contents of register C into D.
MOV ED, EC
LJMP PROGRESS
;Instruction: MOV D, D
;Opcode: 52
;Description: Move contents of register D into D.
LJMP PROGRESS
;Instruction: MOV D, E
;Opcode: 53
;Description: Move contents of register E into D.
MOV ED, EE
LJMP PROGRESS
;Instruction: MOV D, EH
;Opcode: 54
;Description: Move contents of register H into D.
MOV ED, EH
LJMP PROGRESS
;Instruction: MOV D, EL
;Opcode: 55
;Description: Move contents of register L into D.
MOV ED, EL
LJMP PROGRESS
;Instruction: MOV D, M
;Opcode: 56
;Description: Move contents of memory location given by HL into D.
;Save DPTR
LCALL SAVEDPTR
;Move HL into DPTR and get data from EXMEM
MOV DPH, EH
MOV DPL, EL
MOVX A, @DPTR
MOV ED, A
;Restore DPTR
LCALL RESTOREDPTR
LJMP PROGRESS
;Instruction: MOV D, A
;Opcode: 57
;Description: Move contents of EACC into D.
MOV ED, EACC
LJMP PROGRESS
;Instruction: MOV E, B
;Opcode: 58
;Description: Move contents of B into E.
MOV EE, EB
LJMP PROGRESS
;Instruction: MOV E, C
;Opcode: 59
;Description: Move contents of C into E.
MOV EE, EC
LJMP PROGRESS
;Instruction: MOV E, D
;Opcode: 5A
;Description: Move contents of D into E.
MOV EE, ED
LJMP PROGRESS
;Instruction: MOV E, E
;Opcode: 5B
;Description: Move contents of E into E.
LJMP PROGRESS
;Instruction: MOV E, EH
;Opcode: 5C
;Description: Move contents of H into E.
MOV EE, EH
LJMP PROGRESS
;Instruction: MOV E, EL
;Opcode: 5D
;Description: Move contents of L into C.
MOV EE, EL
LJMP PROGRESS
;Instruction: MOV E, M
;Opcode: 5E
;Description: Move contents of memory location given by H into E.
;Save DPTR
LCALL SAVEDPTR
;Move HL into DPTR and get data from EXMEM
MOV DPH, EH
MOV DPL, EL
MOVX A, @DPTR
MOV EE, A
;Restore DPTR
LCALL RESTOREDPTR
LJMP PROGRESS
;Instruction: MOV E, A
;Opcode: 5F
;Description: Move contents of EACC into E.
MOV EE, EACC
LJMP PROGRESS
;Instruction: MOV H, B
;Opcode: 60
;Description: Move contents of register B into H.
MOV EH, EB
LJMP PROGRESS
;Instruction: MOV H, C
;Opcode: 61
;Description: Move contents of register C into H.
MOV EH, EC
LJMP PROGRESS
;Instruction: MOV H, D
;Opcode: 62
;Description: Move contents of register D into H.
MOV EH, ED
LJMP PROGRESS
;Instruction: MOV H, E
;Opcode: 63
;Description: Move contents of register E into H.
MOV EH, EE
LJMP PROGRESS
;Instruction: MOV H, EH
;Opcode: 64
;Description: Move contents of register H into H.
LJMP PROGRESS
;Instruction: MOV H, EL
;Opcode: 65
;Description: Move contents of register L into H.
MOV EH, EL
LJMP PROGRESS
;Instruction: MOV H, M
;Opcode: 66
;Description: Move contents of memory location given by HL into H.
;Save DPTR
LCALL SAVEDPTR
;Move HL into DPTR and get data from EXMEM
MOV DPH, EH
MOV DPL, EL
MOVX A, @DPTR
MOV EH, A
;Restore DPTR
LCALL RESTOREDPTR
LJMP PROGRESS
;Instruction: MOV H, A
;Opcode: 67
;Description: Move contents of EACC into H.
MOV EH, EACC
LJMP PROGRESS
;Instruction: MOV L, B
;Opcode: 68
;Description: Move contents of B into L.
MOV EL, EB
LJMP PROGRESS
;Instruction: MOV L, C
;Opcode: 69
;Description: Move contents of C into L.
MOV EL, EC
LJMP PROGRESS
;Instruction: MOV L, D
;Opcode: 6A
;Description: Move contents of D into L.
MOV EL, ED
LJMP PROGRESS
;Instruction: MOV L, E
;Opcode: 6B
;Description: Move contents of E into L.
MOV EL, EE
LJMP PROGRESS
;Instruction: MOV L, EH
;Opcode: 6C
;Description: Move contents of H into L.
MOV EL, EH
LJMP PROGRESS
;Instruction: MOV L, EL
;Opcode: 6D
;Description: Move contents of L into L.
LJMP PROGRESS
;Instruction: MOV L, M
;Opcode: 6E
;Description: Move contents of memory location given by H into L.
;Save DPTR
LCALL SAVEDPTR
;Move HL into DPTR and get data from EXMEM
MOV DPH, EH
MOV DPL, EL
MOVX A, @DPTR
MOV EL, A
;Restore DPTR
LCALL RESTOREDPTR
LJMP PROGRESS
;Instruction: MOV L, A
;Opcode: 6F
;Description: Move contents of EACC into L.
MOV EL, EACC
LJMP PROGRESS
;Instruction: MOV M, B
;Opcode: 70
;Description: Move contents of register B into the memory location given by
;register pair H.
;Save DPTR
LCALL SAVEDPTR
;Move contents of register pair H into DPTR and get content of EB into A.
MOV DPH, EH
MOV DPL, EL
MOV A, EB
;Transfer A to EXMEM using DPTR.
MOVX @DPTR, A
;Restore DPTR
LCALL RESTOREDPTR
LJMP PROGRESS
;Instruction: MOV M, C
;Opcode: 71
;Description: Move contents of register C into the memory location given by
;register pair H.
;Save DPTR
LCALL SAVEDPTR
;Move contents of register pair H into DPTR and get content of EC into A.
MOV DPH, EH
MOV DPL, EL
MOV A, EC
;Transfer A to EXMEM using DPTR.
MOVX @DPTR, A
;Restore DPTR
LCALL RESTOREDPTR
LJMP PROGRESS
;Instruction: MOV M, D
;Opcode: 72
;Description: Move contents of register D into the memory location given by
;register pair H.
;Save DPTR
LCALL SAVEDPTR
;Move contents of register pair H into DPTR and get content of ED into A.
MOV DPH, EH
MOV DPL, EL
MOV A, ED
;Transfer A to EXMEM using DPTR.
MOVX @DPTR, A
;Restore DPTR
LCALL RESTOREDPTR
LJMP PROGRESS
;Instruction: MOV M, E
;Opcode: 73
;Description: Move contents of register E into the memory location given by
;register pair H.
;Save DPTR
LCALL SAVEDPTR
;Move contents of register pair H into DPTR and get content of EB into A.
MOV DPH, EH
MOV DPL, EL
MOV A, EE
;Transfer A to EXMEM using DPTR.
MOVX @DPTR, A
;Restore DPTR
LCALL RESTOREDPTR
LJMP PROGRESS
;Instruction: MOV M, EH
;Opcode: 74
;Description: Move contents of register H into the memory location given by
;register pair H.
;Save DPTR
LCALL SAVEDPTR
;Move contents of register pair H into DPTR and get content of EB into A.
MOV DPH, EH
MOV DPL, EL
MOV A, EH
;Transfer A to EXMEM using DPTR.
MOVX @DPTR, A
;Restore DPTR
LCALL RESTOREDPTR
LJMP PROGRESS
;Instruction: MOV M, EL
;Opcode: 75
;Description: Move contents of register L into the memory location given by
;register pair H.
;Save DPTR
LCALL SAVEDPTR
;Move contents of register pair H into DPTR and get content of EB into A.
MOV DPH, EH
MOV DPL, EL
MOV A, EL
;Transfer A to EXMEM using DPTR.
MOVX @DPTR, A
;Restore DPTR
LCALL RESTOREDPTR
LJMP PROGRESS
;Instruction: HLT
;Opcode: 76
;Description: Halts the MPU.
HALT: SJMP HALT
;Instruction: MOV M, A
;Opcode: 77
;Description: Move contents of EACC into the memory location given by
;register pair H.
;Save DPTR
LCALL SAVEDPTR
;Move contents of register pair H into DPTR and get content of EACC into A.
MOV DPH, EH
MOV DPL, EL
MOV A, EACC
;Transfer A to EXMEM using DPTR.
MOVX @DPTR, A
;Restore DPTR
LCALL RESTOREDPTR
LJMP PROGRESS
;Instruction: MOV A, B
;Opcode: 78
;Description: Move contents of register B into EACC.
MOV EACC, EB
LJMP PROGRESS
;Instruction: MOV A, C
;Opcode: 79
;Description: Move contents of register C into EACC.
MOV EACC, EC
LJMP PROGRESS
;Instruction: MOV A, D
;Opcode: 7A
;Description: Move contents of register D into EACC.
MOV EACC, ED
LJMP PROGRESS
;Instruction: MOV A, E
;Opcode: 7B
;Description: Move contents of register E into EACC.
MOV EACC, EE
LJMP PROGRESS
;Instruction: MOV A, EH
;Opcode: 7C
;Description: Move contents of register H into EACC.
MOV EACC, EH
LJMP PROGRESS
;Instruction: MOV A, EL
;Opcode: 7D
;Description: Move contents of register L into EACC.
MOV EACC, EL
LJMP PROGRESS
;Instruction: MOV A, M
;Opcode: 7E
;Description: Move contents of memory location given by register pair H into EACC.
;Save DPTR
LCALL SAVEDPTR
;Move register H into DPTR and get content into A and move it into EACC.
MOV DPH, EH
MOV DPL, EL
MOVX A, @DPTR
MOV EACC, A
;Restore DPTR
LCALL RESTOREDPTR
LJMP PROGRESS
;Instruction: MOV A, A
;Opcode: 7F
;Description: Move contents of EACC into EACC.
LJMP PROGRESS
;Instruction: ADD B
;Opcode: 80
;Description: Add register EB to EACC
MOV A, EACC
ADD A, EB
MOV EACC, A
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
LJMP PROGRESS
;Instruction: ADD C
;Opcode: 81
;Description: Add register EC to EACC
MOV A, EACC
ADD A, EC
MOV EACC, A
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
LJMP PROGRESS
;Instruction: ADD D
;Opcode: 82
;Description: Add register ED to EACC
MOV A, EACC
ADD A, ED
MOV EACC, A
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
LJMP PROGRESS
;Instruction: ADD E
;Opcode: 83
;Description: Add register EE to EACC
MOV A, EACC
ADD A, EE
MOV EACC, A
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
LJMP PROGRESS
;Instruction: ADD H
;Opcode: 84
;Description: Add register EH to EACC
MOV A, EACC
ADD A, EH
MOV EACC, A
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
LJMP PROGRESS
;Instruction: ADD L
;Opcode: 85
;Description: Add register EL to EACC
MOV A, EACC
ADD A, EL
MOV EACC, A
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
LJMP PROGRESS
;Instruction: ADD M
;Opcode: 86
;Description: Add value pointed by register pair EH and EL to accumulator.
LCALL SAVEDPTR
MOV DPH, EH
MOV DPL, EL
MOVX A, @DPTR
MOV B, A
MOV A, EACC
ADD A, B
MOV EACC, A
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
LJMP PROGRESS
;Instruction: ADD L
;Opcode: 87
;Description: Add register EACC to EACC
MOV A, EACC
ADD A, EACC
MOV EACC, A
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
LJMP PROGRESS
;Instruction: ADC B
;Opcode: 88
;Description: Add register EB to EACC with CARRY
MOV A, EACC
ADD A, EB
JNB EBCY, DONE88
ADD A, #01H;
DONE88: MOV EACC, A
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
LJMP PROGRESS
;Instruction: ADC C
;Opcode: 89
;Description: Add register EC to EACC with CARRY
MOV A, EACC
ADD A, EC
JNB EBCY, DONE89
ADD A, #01H;
DONE89: MOV EACC, A
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
LJMP PROGRESS
;Instruction: ADC D
;Opcode: 8A
;Description: Add register EB to EACC with CARRY
MOV A, EACC
ADD A, ED
JNB EBCY, DONE8A
ADD A, #01H;
DONE8A: MOV EACC, A
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
LJMP PROGRESS
;Instruction: ADC E
;Opcode: 8B
;Description: Add register EE to EACC with CARRY
MOV A, EACC
ADD A, EE
JNB EBCY, DONE8B
ADD A, #01H;
DONE8B: MOV EACC, A
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
LJMP PROGRESS
;Instruction: ADC H
;Opcode: 8C
;Description: Add register EH to EACC with CARRY
MOV A, EACC
ADD A, EH
JNB EBCY, DONE8C
ADD A, #01H;
DONE8C: MOV EACC, A
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
LJMP PROGRESS
;Instruction: ADC L
;Opcode: 8D
;Description: Add register EL to EACC with CARRY
MOV A, EACC
ADD A, EL
JNB EBCY, DONE8D
ADD A, #01H;
DONE8D: MOV EACC, A
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
LJMP PROGRESS
;Instruction: ADC M
;Opcode: 8E
;Description: Add register H to EACC with carry.
LCALL SAVEDPTR
MOV DPH, EH
MOV DPL, EL
MOVX A, @DPTR
MOV B, A
MOV A, EACC
ADD A, B
JNB EBCY, DONE8E
ADD A, #01H;
DONE8E: MOV EACC, A
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
LJMP PROGRESS
;Instruction: ADC A
;Opcode: 8F
;Description: Add register EACC to EACC with CARRY
MOV A, EACC
ADD A, EACC
JNB EBCY, DONE8F
ADD A, #01H;
DONE8F: MOV EACC, A
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
LJMP PROGRESS
;Instruction: SUB B
;Opcode: 90
;Description: Subtract register EB from EACC
MOV A, EACC
CLR C
SUBB A, EB
MOV EACC, A
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
LJMP PROGRESS
;Instruction: SUB C
;Opcode: 91
;Description: Subtract register EC from EACC
MOV A, EACC
CLR C
SUBB A, EC
MOV EACC, A
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
LJMP PROGRESS
;Instruction: SUB D
;Opcode: 92
;Description: Subtract register ED from EACC
MOV A, EACC
CLR C
SUBB A, ED
MOV EACC, A
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
LJMP PROGRESS
;Instruction: SUB E
;Opcode: 93
;Description: Subtract register EE from EACC
MOV A, EACC
CLR C
SUBB A, EE
MOV EACC, A
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
LJMP PROGRESS
;Instruction: SUB H
;Opcode: 94
;Description: Subtract register EH from EACC
MOV A, EACC
CLR C
SUBB A, EH
MOV EACC, A
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
LJMP PROGRESS
;Instruction: SUB L
;Opcode: 95
;Description: Subtract register EL from EACC
MOV A, EACC
CLR C
SUBB A, EL
MOV EACC, A
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
LJMP PROGRESS
;Instruction: SUB M
;Opcode: 96
;Description: Subtract value at memory location pointed by EH and EL from accumulator.
LCALL SAVEDPTR
MOV DPH, EH
MOV DPL, EL
MOVX A, @DPTR
MOV B, A
MOV A, EACC
CLR C
SUBB A, B
MOV EACC, A
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
LJMP PROGRESS
;Instruction: SUB A
;Opcode: 97
;Description: Subtract register EACC from EACC
MOV EACC, #00H
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
LJMP PROGRESS
;Instruction: SBB B
;Opcode: 98
;Description: Subtract register EB and borrow from EACC.
MOV A, EACC
CLR C
SUBB A, EB
JNB EBCY, DONE98
ADD A, #0FFH
DONE98: MOV EACC, A
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
LJMP PROGRESS
;Instruction: SBB C
;Opcode: 99
;Description: Subtract register EC and borrow from EACC
MOV A, EACC
CLR C
SUBB A, EC
JNB EBCY, DONE99
ADD A, #0FFH
DONE99: MOV EACC, A
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
LJMP PROGRESS
;Instruction: SBB D
;Opcode: 9A
;Description: Subtract register ED and borrow from EACC
MOV A, EACC
CLR C
SUBB A, ED
JNB EBCY, DONE9A
ADD A, #0FFH
DONE9A: MOV EACC, A
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
LJMP PROGRESS
;Instruction: SUB E
;Opcode: 9B
;Description: Subtract register EE and borrow from EACC
MOV A, EACC
CLR C
SUBB A, EE
JNB EBCY, DONE9B
ADD A, #0FFH
DONE9B: MOV EACC, A
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
LJMP PROGRESS
;Instruction: SUB H
;Opcode: 9C
;Description: Subtract register EH and borrow from EACC
MOV A, EACC
CLR C
SUBB A, EH
JNB EBCY, DONE9C
ADD A, #0FFH
DONE9C: MOV EACC, A
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
LJMP PROGRESS
;Instruction: SUB L
;Opcode: 9D
;Description: Subtract register EL and borrow from EACC
MOV A, EACC
CLR C
SUBB A, EL
JNB EBCY, DONE9D
ADD A, #0FFH
DONE9D: MOV EACC, A
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
LJMP PROGRESS
;Instruction: SUB M
;Opcode: 9E
;Description: Subtract value at memory location pointed by EH and EL and borrow from accumulator.
LCALL SAVEDPTR
MOV DPH, EH
MOV DPL, EL
MOVX A, @DPTR
MOV B, A
MOV A, EACC
CLR C
SUBB A, B
JNB EBCY, DONE9E
ADD A, #0FFH
DONE9E: MOV EACC, A
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
LJMP PROGRESS
;Instruction: SBB A
;Opcode: 9F
;Description: Subtract register EACC and borrow from EACC
MOV A, #00H
JNB EBCY, DONE9F
MOV A, #0FFH
DONE9F: MOV EACC, A
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
LJMP PROGRESS
;Instruction: ANA B
;Opcode: A0
;Description: Contents of register B and accumulator are logically ANDed.
MOV A, EACC
ANL A, EB
MOV EACC, A
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
LJMP PROGRESS
;Instruction: ANA C
;Opcode: A1
;Description: Contents of register C and accumulator are logically ANDed.
MOV A, EACC
ANL A, EC
MOV EACC, A
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
LJMP PROGRESS
;Instruction: ANA D
;Opcode: A2
;Description: Contents of register D and accumulator are logically ANDed.
MOV A, EACC
ANL A, ED
MOV EACC, A
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
LJMP PROGRESS
;Instruction: ANA E
;Opcode: A3
;Description: Contents of register E and accumulator are logically ANDed.
MOV A, EACC
ANL A, EE
MOV EACC, A
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
LJMP PROGRESS
;Instruction: ANA H
;Opcode: A4
;Description: Contents of register H and accumulator are logically ANDed.
MOV A, EACC
ANL A, EH
MOV EACC, A
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
LJMP PROGRESS
;Instruction: ANA L
;Opcode: A5
;Description: Contents of register L and accumulator are logically ANDed.
MOV A, EACC
ANL A, EL
MOV EACC, A
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
LJMP PROGRESS
;Instruction: ANA M
;Opcode: A6
;Description: Value at memory location pointed by EH and EL and accumulator are logically ANDed.
LCALL SAVEDPTR
MOV DPH, EH
MOV DPL, EL
MOVX A, @DPTR
ANL A, EACC
MOV EACC, A
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
LJMP PROGRESS
;Instruction: ANA A
;Opcode: A7
;Description: Contents of accumulator and accumulator are logically ANDed.
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
LJMP PROGRESS
;Instruction: XRA B
;Opcode: A8
;Description: Contents of register B and accumulator are logically XORed.
MOV A, EACC
XRL A, EB
MOV EACC, A
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
LJMP PROGRESS
;Instruction: XRA C
;Opcode: A9
;Description: Contents of register C and accumulator are logically XORed.
MOV A, EACC
XRL A, EC
MOV EACC, A
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
LJMP PROGRESS
;Instruction: XRA D
;Opcode: AA
;Description: Contents of register D and accumulator are logically XORed.
MOV A, EACC
XRL A, ED
MOV EACC, A
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
LJMP PROGRESS
;Instruction: XRA E
;Opcode: AB
;Description: Contents of register E and accumulator are logically XORed.
MOV A, EACC
XRL A, EE
MOV EACC, A
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
LJMP PROGRESS
;Instruction: XRA H
;Opcode: AC
;Description: Contents of register H and accumulator are logically XORed.
MOV A, EACC
XRL A, EH
MOV EACC, A
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
LJMP PROGRESS
;Instruction: XRA L
;Opcode: AD
;Description: Contents of register L and accumulator are logically XORed.
MOV A, EACC
XRL A, EL
MOV EACC, A
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
LJMP PROGRESS
;Instruction: XRA M
;Opcode: AE
;Description: Value at memory location pointed by EH and EL and accumulator are logically XORed.
LCALL SAVEDPTR
MOV DPH, EH
MOV DPL, EL
MOVX A, @DPTR
XRL A, EACC
MOV EACC, A
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
LJMP PROGRESS
;Instruction: XRA A
;Opcode: AF
;Description: Contents of accumulator and accumulator are logically XORed.
MOV EACC, #00H
;;;;; WRITE CODE TO SET FLAGS AS PER THE DESCRIPTION. ;;;;;;
LJMP PROGRESS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment