1 / 94

The A1, in all its glory

The A1, in all its glory. Programming Fundamentals 6 Feliks Klu ź niak. Executive summary : We learn most of the remaining instruction of the A1. We look at some simple examples. We also find out how a program gets into the machine.

kyoko
Télécharger la présentation

The A1, in all its glory

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. The A1, in all its glory Programming Fundamentals 6 Feliks Kluźniak The A1

  2. Executive summary: • We learn most of the remaining instruction of the A1. • We look at some simple examples. • We also find out how a program gets into the machine. The A1

  3. 0 HLT a HALT the machine, after loading MA with a. 1 2 3 4 5 6 7 8 9 A B C D E F The A1

  4. 0 HLT a HALT the machine, after loading MA with a. 1 STO a STORE the accumulator: m[ a ] := A . 2 3 4 5 6 7 8 9 A B C D E F The A1

  5. 0 HLT a HALT the machine, after loading MA with a. 1 STO a STORE the accumulator: m[ a ] := A . 2 LOA a LOAD into the accumulator: A := m[ a ] . 3 4 5 6 7 8 9 A B C D E F The A1

  6. 0 HLT a HALT the machine, after loading MA with a. 1 STO a STORE the accumulator: m[ a ] := A . 2 LOA a LOAD into the accumulator: A := m[ a ] . 3 AND a Bitwise AND: A := A bit_and m[ a ] . 4 5 6 7 bit_and 0 1 8 0 0 0 9 1 0 1 A B C D E F The A1

  7. 0 HLT a HALT the machine, after loading MA with a. 1 STO a STORE the accumulator: m[ a ] := A . 2 LOA a LOAD into the accumulator: A := m[ a ] . 3 AND a Bitwise AND: A := A bit_and m[ a ] . 4 5 6 7 bit_and 0 1 8 0 0 0 9 1 0 1 A B Typical use: masking out certain bits. C For example, if INS is the address of an instruction, and D MASKis the address of of a word containing #0FFFF, E then the following will put the operand of that instruction F intoA:LOA INS AND MASK

  8. bit_and 0 1 0 0 0 1 0 1 For example, if INS is the address of an instruction, and MASKis the address of of a word containing #0FFFF, then the following will put the operand of that instruction intoA:LOA INS AND MASK NOTE: INS and MASK are just some names, we could have chosen ABC and ZYX as well. The A1

  9. bit_and 0 1 0 0 0 1 0 1 For example, if INS is the address of an instruction, and MASKis the address of of a word containing #0FFFF, then the following will put the operand of that instruction intoA:LOA INS AND MASK After the instruction assembled from LOA INS is executed, the accumulator will contain the bit pattern for the instruction at INS, e.g., 0 0 0 1 0 0 0 0 0 0 0 0 0 1 1 0 0 1 0 0 opcode operand The A1

  10. bit_and 0 1 0 0 0 1 0 1 For example, if INS is the address of an instruction, and MASKis the address of of a word containing #0FFFF, then the following will put the operand of that instruction intoA:LOA INS AND MASK After the instruction assembled from LOA INS is executed, the accumulator will contain the bit pattern for the instruction at INS, e.g., 0 0 0 1 0 0 0 0 0 0 0 0 0 1 1 0 0 1 0 0 opcode operand BTW, what instruction is this?

  11. bit_and 0 1 0 0 0 1 0 1 For example, if INS is the address of an instruction, and MASKis the address of of a word containing #0FFFF, then the following will put the operand of that instruction intoA:LOA INS AND MASK After the instruction assembled from LOA INS is executed, the accumulator will contain the bit pattern for the instruction at INS, e.g., 0 0 0 1 0 0 0 0 0 0 0 0 0 1 1 0 0 1 0 0 opcode operand BTW, what instruction is this? STO #64

  12. bit_and 0 1 0 0 0 1 0 1 For example, if INS is the address of an instruction, and MASKis the address of of a word containing #0FFFF, then the following will put the operand of that instruction intoA:LOA INS AND MASK After the instruction assembled from LOA INS is executed, the accumulator will contain the bit pattern for the instruction at INS, e.g., 0 0 0 1 0 0 0 0 0 0 0 0 0 1 1 0 0 1 0 0 opcode operand The A1

  13. bit_and 0 1 0 0 0 1 0 1 For example, if INS is the address of an instruction, and MASKis the address of of a word containing #0FFFF, then the following will put the operand of that instruction intoA:LOA INS AND MASK After the instruction assembled from LOA INS is executed, the accumulator will contain the bit pattern for the instruction at INS, e.g., 0 0 0 1 0 0 0 0 0 0 0 0 0 1 1 0 0 1 0 0 Now, 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 is the word at MASK. The A1

  14. bit_and 0 1 0 0 0 1 0 1 For example, if INS is the address of an instruction, and MASKis the address of of a word containing #0FFFF, then the following will put the operand of that instruction intoA:LOA INS AND MASK After the instruction assembled from LOA INS is executed, the accumulator will contain the bit pattern for the instruction at INS, e.g., 0 0 0 1 0 0 0 0 0 0 0 0 0 1 1 0 0 1 0 0 Now, 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 is the word at MASK. So 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 1 0 0 will be in the accumulator after the instruction assembled from AND MASK is executed: we get a 1 at some position only if both operands contain a 1 at that position.

  15. bit_and 0 1 0 0 0 1 0 1 For example, if INS is the address of an instruction, and MASKis the address of of a word containing #0FFFF, then the following will put the operand of that instruction intoA:LOA INS AND MASK After the instruction assembled from LOA INS is executed, the accumulator will contain the bit pattern for the instruction at INS, e.g., 0 0 0 1 0 0 0 0 0 0 0 0 0 1 1 0 0 1 0 0 Now, 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 is the word at MASK. So 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 1 0 0 will be in the accumulator after the instruction assembled from AND MASK is executed: we get a 1 at some position only if both operands contain a 1 at that position. The accumulator will contain #64.

  16. 0 HLT a HALT the machine, after loading MA with a. 1 STO a STORE the accumulator: m[ a ] := A . 2 LOA a LOAD into the accumulator: A := m[ a ] . 3 AND a Bitwise AND: A := A bit_and m[ a ] . 4 OR a Bitwise OR: A := A bit_or m[ a ] . 5 6 7 bit_or 0 1 8 0 0 1 9 1 1 1 A B C D E F The A1

  17. 0 HLT a HALT the machine, after loading MA with a. 1 STO a STORE the accumulator: m[ a ] := A . 2 LOA a LOAD into the accumulator: A := m[ a ] . 3 AND a Bitwise AND: A := A bit_and m[ a ] . 4 OR a Bitwise OR: A := A bit_or m[ a ] . 5 6 7 bit_or 0 1 8 0 0 1 9 1 1 1 A B Typical use: constructing a word out of smaller pieces. C For example, if INSis the address of LOA 0, and ADRN is the D address of a word containing some integer N, then the E following will fill A with the bit pattern for LOA N: F LOA INS OR ADRN The A1

  18. bit_or 0 1 0 0 1 1 1 1 Typical use: constructing a word out of smaller pieces. For example, if INSis the address of LOA 0, and ADRN is the address of a word containing some integer N, then the following will fill A with the bit pattern for LOA N : LOA INS OR ADRN 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 The A1

  19. bit_or 0 1 0 0 1 1 1 1 Typical use: constructing a word out of smaller pieces. For example, if INSis the address of LOA 0, and ADRN is the address of a word containing some integer N, then the following will fill A with the bit pattern for LOA N : LOA INS OR ADRN 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 1 0 The A1

  20. bit_or 0 1 0 0 1 1 11 Typical use: constructing a word out of smaller pieces. For example, if INSis the address of LOA 0, and ADRN is the address of a word containing some integer N, then the following will fill A with the bit pattern for LOA N : LOA INS OR ADRN 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 11 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 1 0 The A1

  21. bit_or 0 1 0 0 1 1 1 1 Typical use: constructing a word out of smaller pieces. For example, if INSis the address of LOA 0, and ADRN is the address of a word containing some integer N, then the following will fill A with the bit pattern for LOA N : LOA INS OR ADRN 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 1 0 The A1

  22. 0 HLT a HALT the machine, after loading MA with a. 1 STO a STORE the accumulator: m[ a ] := A . 2 LOA a LOAD into the accumulator: A := m[ a ] . 3 AND a Bitwise AND: A := A bit_and m[ a ] . 4 OR a Bitwise OR: A := A bit_or m[ a ] . 5 XOR a Bitwise exclusive OR: A := A bit_xor m[ a ] . 6 7 bit_xor 0 1 8 0 0 1 9 1 1 0 A B For example: LOA #11 C XOR #11 D will ensure that A contains zero. E The address (#11) does not matter! F The A1

  23. 0 HLT a HALT the machine, after loading MA with a. 1 STO a STORE the accumulator: m[ a ] := A . 2 LOA a LOAD into the accumulator: A := m[ a ] . 3 AND a Bitwise AND: A := A bit_and m[ a ] . 4 OR a Bitwise OR: A := A bit_or m[ a ] . 5 XOR a Bitwise exclusive OR: A := A bit_xor m[ a ] . 6 7 bit_xor 0 1 8 0 0 1 9 1 1 0 A B For example: LOA #11 C XOR #11 D will ensure that A contains zero. E The address (#11) does not matter! F But of course it must refer to physical memory. Why? The A1

  24. 0 HLT a HALT the machine, after loading MA with a. 1 STO a STORE the accumulator: m[ a ] := A . 2 LOA a LOAD into the accumulator: A := m[ a ] . 3 AND a Bitwise AND: A := A bit_and m[ a ] . 4 OR a Bitwise OR: A := A bit_or m[ a ] . 5 XOR a Bitwise exclusive OR: A := A bit_xor m[ a ] . 6 LSH i Logical SHift(right if i positive, left otherwise) 7 8 For example, if A contains 9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 A then after execution of LSH 3 it will contain B 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 C (the rightmost 3 bits will be “shifted out”, and D 3 new 0 bits will appear on the left). E F The A1

  25. 0 HLT a HALT the machine, after loading MA with a. 1 STO a STORE the accumulator: m[ a ] := A . 2 LOA a LOAD into the accumulator: A := m[ a ] . 3 AND a Bitwise AND: A := A bit_and m[ a ] . 4 OR a Bitwise OR: A := A bit_or m[ a ] . 5 XOR a Bitwise exclusive OR: A := A bit_xor m[ a ] . 6 LSH i Logical SHift (right if i positive, left otherwise) 7 8 For example, LSH 19 will yield 1 if A is negative, 9 and 0 if A is positive. A Why? B C D E F The A1

  26. 0 HLT a HALT the machine, after loading MA with a. 1 STO a STORE the accumulator: m[ a ] := A . 2 LOA a LOAD into the accumulator: A := m[ a ] . 3 AND a Bitwise AND: A := A bit_and m[ a ] . 4 OR a Bitwise OR: A := A bit_or m[ a ] . 5 XOR a Bitwise exclusive OR: A := A bit_xor m[ a ] . 6 LSH i Logical SHift (right if i positive, left otherwise) 7 8 For example, LSH 19 will yield 1 if A is negative, 9 and 0 if A is positive. A B For example,LSH -1 C LSH 1 D will ensure the sign bit is zero E (the incoming bit is always zero). F The A1

  27. 0 HLT a HALT the machine, after loading MA with a. 1 STO a STORE the accumulator: m[ a ] := A . 2 LOA a LOAD into the accumulator: A := m[ a ] . 3 AND a Bitwise AND: A := A bit_and m[ a ] . 4 OR a Bitwise OR: A := A bit_or m[ a ] . 5 XOR a Bitwise exclusive OR: A := A bit_xor m[ a ] . 6 LSH i Logical SHift (right if i positive, left otherwise) 7 8 For example, LSH 19 will yield 1 if A is negative, 9 and 0 if A is positive. A B For example,LSH -1 C LSH 1 D will ensure the sign bit is zero E (the incoming bit is always zero). F RECALL that just changing the sign bit will not turn, say, - 17 into + 17. The A1

  28. 0 HLT a HALT the machine, after loading MA with a. 1 STO a STORE the accumulator: m[ a ] := A . 2 LOA a LOAD into the accumulator: A := m[ a ] . 3 AND a Bitwise AND: A := A bit_and m[ a ] . 4 OR a Bitwise OR: A := A bit_or m[ a ] . 5 XOR a Bitwise exclusive OR: A := A bit_xor m[ a ] . 6 LSH i Logical SHift (right if i positive, left otherwise) 7 8 For example, LSH 19 will yield 1 if A is negative, 9 and 0 if A is positive. A B For example,LSH -1 C LSH 1 D will ensure the sign bit is zero E (the incoming bit is always zero). F RECALL that just changing the sign bit will not turn, say, - 17 into + 17.How should we negate a number? The A1

  29. How should we negate a number? Recall that we must flip all the bits, and then add one. To flip all the bits in the accumulator, we can perform exclusive or with a word containing a 1 in every position. Can you see why? The A1

  30. How should we negate a number? Recall that we must flip all the bits, and then add one. To flip all the bits in the accumulator, we can perform exclusive or with a word containing a 1 in every position. If the corresponding bit in the accumulator is a 1, both bits will be the same, and the result will be a 0; if the bit in the accumulator is 0, both bits will differ, and the result will be 1. The A1

  31. How should we negate a number? Recall that we must flip all the bits, and then add one. To flip all the bits in the accumulator, we can perform exclusive or with a word containing a 1 in every position. If the corresponding bit in the accumulator is a 1, both bits will be the same, and the result will be a 0; if the bit in the accumulator is 0, both bits will differ, and the result will be 1. Having flipped the bits, we must add 1: the result will be the arithmetic negation of the original number. The A1

  32. To flip all the bits in the accumulator, we can perform exclusive or with a word containing a 1 in every position. Having flipped the bits, we must add 1: the result will be the arithmetic negation of the original number. … ; some instructions here LOA N ; load the number XOR ONES ; flip all the bits ADD ONE ; add 1 STO N ; replace the number with its negation …. ; some other instructions, and HLT N LIT -17 ; some number, could be positive ONE LIT 1 ; the number 1 ONES LIT #FFFFF ; twenty bits, each of them a 1 … ; other data END The A1

  33. 0 HLT a HALT the machine, after loading MA with a. 1 STO a STORE the accumulator: m[ a ] := A . 2 LOA a LOAD into the accumulator: A := m[ a ] . 3 AND a Bitwise AND: A := A bit_and m[ a ] . 4 OR a Bitwise OR: A := A bit_or m[ a ] . 5 XOR a Bitwise exclusive OR: A := A bit_xor m[ a ] . 6 LSH i Logical SHift (right if i positive, left otherwise) 7 ASH i Arithmetic Shift (with sign-extension) 8 9 “Sign-extension” means that, as we shift A right, the new bits coming in from the left B will be copies of the original sign bit. C (The operand should not be negative, D arithmetic shift is always to the right.) E F The A1

  34. 0 HLT a HALT the machine, after loading MA with a. 1 STO a STORE the accumulator: m[ a ] := A . 2 LOA a LOAD into the accumulator: A := m[ a ] . 3 AND a Bitwise AND: A := A bit_and m[ a ] . 4 OR a Bitwise OR: A := A bit_or m[ a ] . 5 XOR a Bitwise exclusive OR: A := A bit_xor m[ a ] . 6 LSH i Logical SHift (right if i positive, left otherwise) 7 ASH i Arithmetic Shift (with sign-extension) 8 For example, ASH 19 will yield ? if A is negative, 9 and ? if A is positive. A B C D E F The A1

  35. 0 HLT a HALT the machine, after loading MA with a. 1 STO a STORE the accumulator: m[ a ] := A . 2 LOA a LOAD into the accumulator: A := m[ a ] . 3 AND a Bitwise AND: A := A bit_and m[ a ] . 4 OR a Bitwise OR: A := A bit_or m[ a ] . 5 XOR a Bitwise exclusive OR: A := A bit_xor m[ a ] . 6 LSH i Logical SHift (right if i positive, left otherwise) 7 ASH i Arithmetic Shift (with sign-extension) 8 For example, ASH 19 will yield -1 if A is negative, 9 and 0 if A is positive. A B C D E F The A1

  36. 0 HLT a HALT the machine, after loading MA with a. 1 STO a STORE the accumulator: m[ a ] := A . 2 LOA a LOAD into the accumulator: A := m[ a ] . 3 AND a Bitwise AND: A := A bit_and m[ a ] . 4 OR a Bitwise OR: A := A bit_or m[ a ] . 5 XOR a Bitwise exclusive OR: A := A bit_xor m[ a ] . 6 LSH i Logical SHift (right if i positive, left otherwise) 7 ASH i Arithmetic Shift (with sign-extension) 8 ADD a ADD: A := A + m[ A ] 9 A B C D E F The A1

  37. 0 HLT a HALT the machine, after loading MA with a. 1 STO a STORE the accumulator: m[ a ] := A . 2 LOA a LOAD into the accumulator: A := m[ a ] . 3 AND a Bitwise AND: A := A bit_and m[ a ] . 4 OR a Bitwise OR: A := A bit_or m[ a ] . 5 XOR a Bitwise exclusive OR: A := A bit_xor m[ a ] . 6 LSH i Logical SHift (right if i positive, left otherwise) 7 ASH i Arithmetic Shift (with sign-extension) 8 ADD a ADD: A := A + m[ A ] 9 A Don’t forget: ADD 17 B will not add 17toA, C it will add … what ? D E F The A1

  38. 0 HLT a HALT the machine, after loading MA with a. 1 STO a STORE the accumulator: m[ a ] := A . 2 LOA a LOAD into the accumulator: A := m[ a ] . 3 AND a Bitwise AND: A := A bit_and m[ a ] . 4 OR a Bitwise OR: A := A bit_or m[ a ] . 5 XOR a Bitwise exclusive OR: A := A bit_xor m[ a ] . 6 LSH i Logical SHift (right if i positive, left otherwise) 7 ASH i Arithmetic Shift (with sign-extension) 8 ADD a ADD: A := A + m[ A ] 9 A Don’t forget: ADD 17 B will not add 17toA, C it will add the contents of the D word whose address is 17. E F The A1

  39. 0 HLT a HALT the machine, after loading MA with a. 1 STO a STORE the accumulator: m[ a ] := A . 2 LOA a LOAD into the accumulator: A := m[ a ] . 3 AND a Bitwise AND: A := A bit_and m[ a ] . 4 OR a Bitwise OR: A := A bit_or m[ a ] . 5 XOR a Bitwise exclusive OR: A := A bit_xor m[ a ] . 6 LSH i Logical SHift (right if i positive, left otherwise) 7 ASH i Arithmetic Shift (with sign-extension) 8 ADD a ADD: A := A + m[ A ] 9 SUB a SUBTRACT: A := A – m[ A ] A B C D E F The A1

  40. 0 HLT a HALT the machine, after loading MA with a. 1 STO a STORE the accumulator: m[ a ] := A . 2 LOA a LOAD into the accumulator: A := m[ a ] . 3 AND a Bitwise AND: A := A bit_and m[ a ] . 4 OR a Bitwise OR: A := A bit_or m[ a ] . 5 XOR a Bitwise exclusive OR: A := A bit_xor m[ a ] . 6 LSH i Logical SHift (right if i positive, left otherwise) 7 ASH i Arithmetic Shift (with sign-extension) 8 ADD a ADD: A := A + m[ A ] 9 SUB a SUBTRACT: A := A – m[ A ] A JMP a JUMP: IC := a B C D E F The A1

  41. The processor performs a very simple sequence of actions, over and over again: Load the word at address IC into IR: IR := m[ IC ]. Increment IC: IC := IC + 1. Perform the action prescribed by the instruction in IR. So if the action in pt. 3 sets ICto some value a, then the next instruction will be taken from address a. Found in the attic

  42. 0 HLT a HALT the machine, after loading MA with a. 1 STO a STORE the accumulator: m[ a ] := A . 2 LOA a LOAD into the accumulator: A := m[ a ] . 3 AND a Bitwise AND: A := A bit_and m[ a ] . 4 OR a Bitwise OR: A := A bit_or m[ a ] . 5 XOR a Bitwise exclusive OR: A := A bit_xor m[ a ] . 6 LSH i Logical SHift (right if i positive, left otherwise) 7 ASH i Arithmetic Shift (with sign-extension) 8 ADD a ADD: A := A + m[ A ] 9 SUB a SUBTRACT: A := A – m[ A ] A JMP a JUMP: IC := a B C D E F The A1

  43. 0 HLT a HALT the machine, after loading MA with a. 1 STO a STORE the accumulator: m[ a ] := A . 2 LOA a LOAD into the accumulator: A := m[ a ] . 3 AND a Bitwise AND: A := A bit_and m[ a ] . 4 OR a Bitwise OR: A := A bit_or m[ a ] . 5 XOR a Bitwise exclusive OR: A := A bit_xor m[ a ] . 6 LSH i Logical SHift (right if i positive, left otherwise) 7 ASH i Arithmetic Shift (with sign-extension) 8 ADD a ADD: A := A + m[ A ] 9 SUB a SUBTRACT: A := A – m[ A ] A JMP a JUMP: IC := a B JMZ a JUMP on Zero: if A = 0 then IC := a fi C D E F The A1

  44. 0 HLT a HALT the machine, after loading MA with a. 1 STO a STORE the accumulator: m[ a ] := A . 2 LOA a LOAD into the accumulator: A := m[ a ] . 3 AND a Bitwise AND: A := A bit_and m[ a ] . 4 OR a Bitwise OR: A := A bit_or m[ a ] . 5 XOR a Bitwise exclusive OR: A := A bit_xor m[ a ] . 6 LSH i Logical SHift (right if i positive, left otherwise) 7 ASH i Arithmetic Shift (with sign-extension) 8 ADD a ADD: A := A + m[ A ] 9 SUB a SUBTRACT: A := A – m[ A ] A JMP a JUMP: IC := a B JMZ a JUMP on Zero: if A = 0 then IC := a fi C JMN a JUMP on Negative: if A < 0 then IC := a fi D E F The A1

  45. 0 HLT a 1 STO a 2 LOA a 3 AND a 4 OR a 5 XOR a 6 LSH i 7 ASH i 8 ADD a 9 SUB a A JMP a B JMZ a C JMN a D E F Let us develop a program that will find the largest of two integers. The A1

  46. 0 HLT a 1 STO a 2 LOA a 3 AND a 4 OR a 5 XOR a 6 LSH i 7 ASH i 8 ADD a 9 SUB a A JMP a B JMZ a C JMN a D E F Let us develop a program that will find the largest of two integers. We have no comparison operation, so what do we do? The A1

  47. 0 HLT a 1 STO a 2 LOA a 3 AND a 4 OR a 5 XOR a 6 LSH i 7 ASH i 8 ADD a 9 SUB a A JMP a B JMZ a C JMN a D E F Let us develop a program that will find the largest of two integers. We have no comparison operation, so we use subtraction. The A1

  48. 0 HLT a 1 STO a 2 LOA a 3 AND a 4 OR a 5 XOR a 6 LSH i 7 ASH i 8 ADD a 9 SUB a A JMP a B JMZ a C JMN a D E F Let us develop a program that will find the largest of two integers. We have no comparison operation, so we use subtraction. In pseudocode: if X – Y < 0 then MAX := Y else MAX := X fi The A1

  49. 0 HLT a 1 STO a 2 LOA a 3 AND a 4 OR a 5 XOR a 6 LSH i 7 ASH i 8 ADD a 9 SUB a A JMP a B JMZ a C JMN a D E F Let us develop a program that will find the largest of two integers. We have no comparison operation, so we use subtraction. In pseudocode: if X – Y < 0 then MAX := Y else MAX := X fi In the old days people universally used flowcharts: subtract Y from X negative? yes no MAX is Y MAX is X The A1

  50. 0 HLT a 1 STO a 2 LOA a 3 AND a 4 OR a 5 XOR a 6 LSH i 7 ASH i 8 ADD a 9 SUB a A JMP a B JMZ a C JMN a D E F Let us develop a program that will find the largest of two integers. We have no comparison operation, so we use subtraction. In pseudocode: if X – Y < 0 then MAX := Y else MAX := X fi In the old day people universally used flowcharts. Flowcharts are now considered quite obsolete, and for good reasons. The A1

More Related