# Tag Info

37

Could you write your code in assembly, convert it (manually) to machine code, Yes! Code can be written "out of your head" in binary, if you wish. Long (long long) ago this is how I started using (then) microprocessors. I and friends would write code in assembly language, compile it manually to machine code (something you can do "by inspection" after some ...

32

In the end, all programs are machine code, regardless of whether the source language was assembler or a high-level language. The important thing is that there are hardware mechanisms that limit what a given process can do, including "messing with" registers that could affect other programs or the operating system itself. This started with a simple ...

26

Zierick manufacture a range of surface mount PCB spacers. Part number 1258-236-0 is 6mm long.

26

As I understand it, AutoCAD Electrical is normal AutoCAD, but with some features that support electrical designers. In this context, 'electrical designers' means people designing low-voltage motor control centres, industrial plant, control cubicles, and so on. Note the distinction between electrical design and electronics design. Electrical design is ...

23

If the compiler writers put some effort into optimizing it for that target, it will at least make some use of the special DSP instructions / architecture. But for ultimate performance it will never be as good as hand-tuned assembly. It might be plenty good enough, though - depends on your application. Other alternatives include: Write the majority of ...

21

Premature optimization is the root of all evil. - Donald Knuth When you find that you don't get enough performance from your code, profile your program first, find the bottlenecks, analyze your performance requirements, and only then start doing optimizations. Writing assembly code is last resort. My question is if I just program in C, wouldn't the ...

20

It's always better to have your algorithm implemented in a higher-level language (which C is compared to assembly), even if you plan to implement everything in assembly in the end. chances are, you won't even need assembly. If the code generated by your compiler meets your design goals, your job is done. if not, you won't be starting your assembly coding ...

19

The point of a (hard) real time system is that it must do certain things within a fixed time. If done later, even by a little bit, the system is useless. Think of a car airbag that blows up after your head has hit the steering wheel. A real-time OS must give fixed guarantees for the maximum it takes to do OS things like interrupt latency, task switching, ...

19

Short answer: your registers are 8-bit and your values are 16-bit. It's therefore handling them in two pieces. Long answer: ldi r24, 0x01 ; 1 ldi r25, 0x00 ; 0 Store the 16-bit value 1 in 8-bit registers r24,r25. std Y+2, r25 ; 0x02 std Y+1, r24 ; 0x01 Store it at stack locations Y+1, Y+2. ldi r24, 0x02 ; 2 ldi r25, ...

19

It says the implementation of the function should be weakly linked (as opposed to strongly linked, which is the usual). This allows providing a "fallback" implementation of a function, in case no other (strongly linked) is found. This is often used for default interrupt handlers in bare-metal MCU frameworks. This way, when you implement an interrupt, you ...

18

I actually think a better practice that avoids this architectural ambiguity is to include <stdint.h> then use declarative types like: uint8_t for unsigned 8-bit integers int8_t for signed 8-bit integers uint16_t for unsigned 16-bit integers uint32_t for unsigned 32-bit integers and so on...

18

Many assembly houses these days do 0402 with the same machines they do anything else, possibly using a different needle, though I'd suspect they'd be using the 0402 capable needle for 0603 and 0805 as well. Is it still true you'll have more choices when you don't go below 0603? Sure. Most likely. There's a lot of cheap assembly houses that are cheap because ...

18

Your DSP will be advertised with a maximum sustained MACs, assuming all the pipes are filled. That is obviously an upper limit to what can be achieved. You know how many MACs your filters and other processing will take, from your analysis. Aim to have the first at least twice the second, as you will not be able to keep the DSP core running at maximum. Just ...

16

Dave's answer is a good one and correct in that assembly layer is not included on the pcb, it is simply to aid the assembly, just wanted to add a bit to it. The assembly layer is useful for setting up the pick and place machine in that you can make the reference designators very large and put them in the middle of the part so there is no confusion as to ...

14

Use an inverted brass flat head machine screw. These will solder easily and depending the mechanical strength you want the part can be selected from a range with various head sizes. Some possible candidate machine screws would be these part numbers from McMaster-Carr. Length of 6mm 99658A524 M3 $9.68/100 96686A150 M2$10.58/50 96686A210 M3 \$7.94/50 ...

14

You could try the following using an XOR: movlw 0x01 ; move 0x01 to W register xorwf lat, F ; XOR W with port & store result in port latch An exclusive OR operation will preserve the values in bits where the bits in the working register are set to zero and invert the values where it is set. So you could also use the same technique to toggle multiple ...

14

In 2017, 0402 is completely standard and no contract manufacturer will blink an eye, whether in prototype or mass production quantities. You'll start to notice minor effects on yield and availability at 0201, though those are outweighed by the board area savings in most cases. Going to 01005 will significantly impair yield and/or choice of manufacturer. ...

13

I think the correct thing to say is that for a given architecture, such as the ARMv7-M architecture of the Cortex-M3 core, the instruction set is the same for all processors. However, the behavior of some instructions may vary because of implementation-defined (i.e. optional) functionality in the processor. Instructions that try to access optional ...

12

PORT is the OUTPUT buffer, PIN is the INPUT buffer. When you want to set the pin to a "high" or "low" voltage, write to the PORT register. When you want to know what voltage is currently presented to a pin, read the PIN register. The bits of these registers represent the corresponding pins of the general-purpose input/output port. Here is a simplified ...

12

Refer to the AVR Instruction Set document. For the least significant byte you want a LSL – Logical Shift Left. Shift a 0 in as least significant bit and remember the highest bit in the Carry flag. Then for the subsequent higher bytes, you want a ROL – Rotate Left trough Carry. You shift the remembered bit from carry into the right (least significant) bit ...

12

I bought some boards from these guys a while back and had similar issues (you just really want to show off the pretty boards). I very successfully cleaned them by first using a lot of isopropyl alcohol with a trimmed down paint brush (so it's more firm for scrubbing). Then before it evaporates, and I know this sounds crazy, rinse it really well with ...

12

The "assembly layer" is not something that gets included in the actual physical PCB, it's just a drawing that becomes part of the documentation that accompanies it. The assembly drawing typically contains more detail than the silkscreen, and is used by the personnel who are assembling parts to the board (either directly or by programming a pick-and-place ...

11

MIPS is one of several RISC (reduced instruction set computers) architectures that are designed to execute one instruction per clock cycle. In order to achieve this, the original MIPS processors had a five-stage pipeline: The abbreviations are in the above figure are: IF (Instruction Fetch), RD (Read from register file), ALU (Execute instruction in ...

11

I'm not acquainted with the PIC microcontroller, so I'll give a more general answer. (edit: PIC-specific answer added at the bottom of this post) Especially smaller microcontrollers, like 8-bit and their derivatives, are limited in what they can do in a single instruction. An instruction may contain the target address for a jump, but not two of them, so ...

11

You should be using a bitwise AND. The expression in the first while loop evaluates to zero, which causes the compiler to remove the loop altogether.

11

You are right in that it appears the code you show is silly. Perhaps whatever machine this runs on can't do immediate operations to set bits on I/O ports, and that that's why something like SETB P2.2 isn't possible. Still setting the CY bit to 1, then ORing anything into it is just plain silly. The same goes for setting the CY bit to 0, then ANDing ...

10

What you are trying to do is tricky, but very educational (if you are prepared to spend a lot of effort). First, you must realise that this kind of PC-only (as opposed to PC+SP) task switching (which is the only thing you can do on a plain 12 or 14-bit PIC core) will only work when all the yield() statements in a task are in the same funtion: they can't be ...

10

Write a loop to shift the word left or right (doesn't matter) until the word is all zeros. The carry flag gives you the value of the next bit. If carry is 1 and the previous carry was zero you're starting a new sequence of 1s. Then set a previous-was-a-first-one flag. (I assume that by contiguous you mean at least 2.) If carry is 1 and previous-was-a-...

10

The first thing to do is to see what values the HEX file contains at what addresses. Here is the output of my HEX_DUMP program on your HEX file: 00000000-00000001 (2): 05 28 00000008-0000000F (8): 05 28 83 16 86 13 83 12 00000010-0000001F (16): 15 28 0F 30 A0 00 0D 20 08 00 7F 30 A1 00 A0 0B 00000020-0000002F (16): 12 28 08 00 A1 0B 12 28 0D 28 86 13 09 20 ...

10

I'm guessing you've encountered this in terms of PIC programming. PICs originally had I/O ports handled in a very direct manner - you could read what values they had externally, or write what values you output, both on the same address. The downside of this was that the value you were trying to output might not match the state on the pin - something else ...

Only top voted, non community-wiki answers of a minimum length are eligible