Week1
Week1
It is important to write portable code to have better compatibility.
Portable code – code that can easily run on all kinds of computer architectures.
Most modern compilers now would outperform assembly language (depends on the user case away).
There is a rise of the ARM processors. It is more energy efficient (the power consumption is low). It is mostly used mobile devices, but there is a trend towards using arm-based system in more than just mobile devices. For example, the new apple M chip earth on the arm perform.
It is important to try to have the software to be most optimized.
- Ways to write or build code to have better performance(algorithm changes, operation sequencing, data type selection)
- Do you want speed, low memory usage, low power consumption. What are you willing to trade off.
- Picking which compiler will influence memory usage, speed, executable size, and power consumption.
- Understanding the build process can have a big impact on how software’s would perform.
- Profiling: identify the bottlenecks of the software and target it to make the software better perform.
A 6502 is a good starter to learn assembly. It is an easier platform to learn assembly. Getting the basics down before going into the big boy processors. Every processor has its own instruction set, but the base logic is share between them. Some Engineers that work in Motorola develop a less expensive processor(6502).
6502 layouts (256 bytes – 64k address space)(00-FF | 0-255):
- Register: Accumulator (A) | X | Y
- Program Counter (PC)
- Status Register (PS)
- Stack Pointer (SP) (Stacks build downwards in memory)
- 2 x execution unit
- Instruction decoder / Dispatcher / Scheduler
- Load / Store Unit
Flags: NV-BDIZC
3 letter code call monomic. They are instructions to tell the processor what to do. Every action you do can have an effect on the flags. Zero page is where we can do fast-access($0000-$00FF). $FE store a random number. Program starts at address $0600.
Simple code to color every pixel:
LDA #$10 ; store the color at A
LDY #$00 ; store 0 in Y
LOOP STA $0200,Y
STA $0300,Y
STA $0400,Y
STA $0500,Y
INY
BNE LOOP ; go to LOOP is not zero (watching zero flag)
RTS
BRK
We can see how long it takes the code to execute. By looking every instruction in the documentation and their cycle and how many times it execute. Watch out for the brunch it could add 1 or 2 cycle on an instruction.
Pair-programming: 1 drivers, and 1 or more navigator (combine knowledge)
Comments
Post a Comment