



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A step-by-step guide on using the thrsim11 simulator to understand the basics of microcontrollers through a simple example written in assembly language. The example demonstrates loading numbers into accumulators, performing arithmetic operations, and interpreting the list (.lst) file. Users will learn about immediate and inherent addressing modes, opcodes, and microcontroller registers.
Typology: Study notes
1 / 7
This page cannot be seen from the preview
Don't miss anything!




This simple example has the following objectives: Familiarize the user with the THRSim11 simulator environment Introduce the user to the syntax and concepts of Assembly (.asm) language Familiarize the user the way arithmetic operations are handled by the microcontroller Instruct the user to interpret the List (.LST) file. Teach the user to perform the simulation and follow the step-by-step results. Introduce the LDAA, LDAB and ABA operations Introduce immediate addressing mode Introduce inherent addressing mode
Ex1.asm program is very simple. It performs the arithmetic operation 3 + 2 = 5 using the ABA operation in immediate mode. To achieve this, the program does the following operations: Load the number 3 into accA using the opcode mnemonic LDAA with operand #3. The symbol # signifies that the number 3 is used immediately. For this reason, this mode of operation is called immediate mode ). Load the number 2 into accB using the opcode mnemonic LDAB with operand #2, i.e., using immediate mode Add the number in accA (i.e., 3) with the number in accB (i.e., 2) using the opcode mnemonic ABA and no operand. This mode, which uses no operant, is called inherent mode. The symbolic representation of this process is: 3 A (immediate mode) 2 B (immediate mode) A + B A (inherent mode) This signifies that number 3 is loaded into accA, number 2 is loaded into accB, and the content of accA is added to the content of accB with the result being put back into accA.
The green highlight has moved to the next line, starting at address $c003. It has jumped by 2 counts because the line that has just been executed had to Opcodes (i.e., machine instructions) in it, 86 and 03. Each Opcode takes up one memory address, hence the program has move forward by 2 locations. The current value of the program counter is PC $c003, as can be readily verified in the CPU registers window. The result of executing the previous instruction is now apparent. The number 3 has been loaded into accA. You can verify this by noting that, in the CPU registers window, you see A 3.
The execution of the previous instruction has performed the addition between the contents of accA (i.e., 3) and the contents of accB (i.e., 2). The result of the operation has been put back into accA. This means that the arithmetic operation 3 + 2 = 5 has been executed. The result of the addition is shown in the CPU registers window: the accA has become A 5, as expected. The green highlight has moved to the next line which starts at memory address $c006. (In the CPU registers window, the program counter indicates PC $c006.) The move of the program counter was only by one memory location because the operation ABA just executed does not have operand (inherent mode), and only requires one Opcode. The line $c006 contains the opcode mnemonic SWI which signifies the end of the program. You are done! (Do not press the ‘Step’ again, because it will throw you out of the program area.)
In this simple exercise, you have learned quite a few things: New words and concepts: Opcode, opcode mnemonic, immediate mode, Assembly language (.asm), list file (.LST), reset, program counter (PC), break point, registers,. Microprocessor opcode mnemonics LDAA, LDAB, and ABA. Meaning of immediate mode and how to invoke it by using the symbol # Meaning of inherent mode.