can I use atmega32 c code in atmel studio to add, subtract, multiply and divide 4-bit number with another 4-bit number and display the result on 7-segment display ?
Just use unit8_t then mask to 4 bits.
Use an Intel 4004 emulator -- that is a 4-bit architecture.
You can put lipstick on a pig, but it is still a pig.
I've never met a pig I didn't like, as long as you have some salt and pepper.
So your range of inputs is 0-15, or did you mean BCD values 0-9?
(Possum Lodge oath) Quando omni flunkus, moritati.
"I thought growing old would take longer"
I wondered about 4 bit multiplication. There aren't that many combinations of 4 bits as multiplicands that won't simply overflow a 4 bit result ;-)
I wondered about 4 bit multiplication.
I think the due date for the assignment may have passed.
Is OP perhaps doing a BCD library? Where is that DAA instruction?
4x4 bit certainly fits in 8bit.
AVR does 8bit hw efficiently.Atmega32 has hw multiplication but not division.The compiler will take care anyway
Also to display connect them to the same port if possible and create a mem vector that stores the bit combination in a uint8_t for the respective port.
v has the combination for '0'
v for '1'
where each bit turns on a pin in a port.
I think the due date for the assignment may have passed
A common assignment used to be to emulate a simple 4-function ( + - * / ) calculator on an 8051 + keypad + 7-Seg display.
Maybe they've "upgraded" to AVR ... ?
© 2021 Microchip Technology Inc.