The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: James Ladd on November 23, 2010, 03:24:10 AM

Title: Minimal Instruction Set ?
Post by: James Ladd on November 23, 2010, 03:24:10 AM
What would be the smallest set of x86 instructions an assembler would need to support to do reasonable work with?
One could assume only 32bits and above.

I ask because I am building such an assembler here:  https://github.com/jamesladd/rasmataz

It is an exercise in metaprogramming and teaching, so it wont be replacing MASM anytime soon.

Rgs, James.
Title: Re: Minimal Instruction Set ?
Post by: dedndave on November 23, 2010, 03:44:06 AM
you could google RISC instruction sets
they use add sub jmp call ret - simple stuff only
it might give you something to start with
Title: Re: Minimal Instruction Set ?
Post by: hutch-- on November 23, 2010, 06:34:35 AM
James,

Disassemble a large app and do a stats analysis on the instruction count for each instruction. You will find that mov's, cmp's and jumps take up a lot of the stats.
Title: Re: Minimal Instruction Set ?
Post by: donkey on November 23, 2010, 04:41:34 PM
I think you can build about anything from:

MOV
ADD ; could be a complimentary SUB though
SUB
XOR
AND
OR
NOT
NEG
CMP
JMP
JZ
CALL
RET
PUSH
POP
I would also add
MUL
DIV


These instructions should be available on every general purpose microprocessor no matter the design or manufacturer.
Title: Re: Minimal Instruction Set ?
Post by: FORTRANS on November 23, 2010, 05:18:20 PM
Hi,

   You could get rid of CMP by using SUB, though that would
be a bit inconvenient.  I think you would want ADC, JO, and JC
and the like to ease mathematics on down the road.

Regards,

Steve N.
Title: Re: Minimal Instruction Set ?
Post by: James Ladd on November 23, 2010, 08:41:49 PM
Brilliant start, thanks guys.
Title: Re: Minimal Instruction Set ?
Post by: Tight_Coder_Ex on November 23, 2010, 09:45:10 PM
IN - OUT would be a definite must as without the ability to comminucate peripherally, what is the point of a computing system
MOV
Title: Re: Minimal Instruction Set ?
Post by: Antariy on November 23, 2010, 09:47:16 PM
Quote from: hutch-- on November 23, 2010, 06:34:35 AM
Disassemble a large app and do a stats analysis on the instruction count for each instruction. You will find that mov's, cmp's and jumps take up a lot of the stats.

:bg
Title: Re: Minimal Instruction Set ?
Post by: Tight_Coder_Ex on November 23, 2010, 09:55:24 PM
IN - OUT would be a definite must as without the ability to comminucate peripherally, what is the point of a computing system
MOV
BOOLEAN OPERATORS
ADD
SUB        at minimum
CMP
JMP and it's dirivites JZ, JNZ etc.

"Reasonable work" is somewhat subjective, but it would seem historically, Intels 8080 could be thought of as a minimum, as it and its counterparts "Z80" propelled the PC to what it is today
Title: Re: Minimal Instruction Set ?
Post by: donkey on November 23, 2010, 10:01:26 PM
Yeah, I left out some good ones.... I would add INT, IRET to Tight_Coder_Ex's IN and OUT. Also some way to dump the flags PUSHFD and POPFD would work.
Title: Re: Minimal Instruction Set ?
Post by: Antariy on November 23, 2010, 10:07:04 PM
Quote from: donkey on November 23, 2010, 10:01:26 PM
Yeah, I left out some good ones.... I would add INT, IRET to Tight_Coder_Ex's IN and OUT. Also some way to dump the flags PUSHFD and POPFD would work.

He want make something like embedded CPU assembler? Just by instructions which you mentinioned already - it seems like machinery control CPU, one with quite full instruction set.
Title: Re: Minimal Instruction Set ?
Post by: FORTRANS on November 23, 2010, 10:40:56 PM
Hi,

   You can get around IN and OUT by using memory mapped
Input/Output.  Though that never seemed a good idea to me.
Motorola CPU's used it?

Regards,

Steve N.
Title: Re: Minimal Instruction Set ?
Post by: James Ladd on November 24, 2010, 03:07:42 AM
I'm starting to think I should just support the intel set.

I wont be supporting all permutations of 8 / 16 combinations, just the 32bit combinations.

From here: http://www.intel.com/design/intarch/manuals/243191.htm