4 months ago

Assembly「in article」


Registers:

		
			r0 - r15: General purpose registers (use these for whatever)
ax: Accumulator (stores the result of the last computation)
flags: Flags (flags of the last computation)
tmp: Temporary (used by instructions)
Initial value: 0 / 0b / 0h
		
	

Instructions:

		
			ldi <loc>, <val>: Load immediate (<loc> = <val>) -- example: ldi %r7, 25 (r7 = 0x19)

add <v1>, <v2>, <loc>
Addition (<loc> = <v1> + <v2>)
example: add %r9, 74, %r4 (r4 = r9 + 74)

sub <v1>, <v2>, <loc>
Subtraction (<loc> = <v1> - <v2>)
example: sub %ax, %r14, %r6 (r6 = ax + r14)

mul <v1>, <v2>, <loc>
Multiplication (<loc> = <v1> * <v2>)
example: add %r9, 74, %r4 (r4 = r9 * 74)

orr <v1>, <v2>, <loc>
Bitwise OR (<loc> = <v1> || <v2>)
example: orr %r5, 66, %r2 (r2 = r5 || 66)

and <v1>, <v2>, <loc>
Bitwise AND (<loc> = <v1> && <v2>)
example: and %r3, %ax, %r10 (r10 = r3 && ax)

xor <v1>, <v2>, <loc>
Bitwise XOR (<loc> = <v1> ^ <v2>)
example: orr %r11, %r12, %r5 (r5 = r11 ^ r12)

not <val>, <loc>
Bitwise NOT (<loc> = ~<val>)
example: and %ax, %r9 (r9 = ~ax)

lsh <val>, <loc>
Left Shift (<loc> = <val> << 1)
example: lsh %r3, %r6 (r3 = r6 << 1)

rsh <val>, <loc>
Right Shift (<loc> = <val> >> 1)
example: rsh %r4, %r8 (r8 = r4 >> 1)

coi <val>
Console Integer (print(int(<val>)))
example: con %r1

col <val>
Console Letter (print(chr(<val>)))
example: col %r12

theres no jump instructions because its not meant to do that    

inc <loc>
Increment (<loc>++)
example: inc %r7 (r7++)
coded: ...
ldi %tmp, 1
add <loc>, %tmp, <loc>

dec <loc>
Decrement (<loc>--)
example: dec %r4 (r4--)
coded: ...
ldi %tmp, 1
add <loc>, %tmp, <loc>

neg <loc>
Negate (<loc> = -<loc>)
example: neg %r13 (r13 = -r13)
coded: ...
ldi %tmp, 0
sub %tmp, <loc>, <loc>

cmp <v1>, <v2>
Compare
example: cmp %ax, %r14
coded: ...
ldi %tmp, 0
sub <v1>, <v2>, %tmp
		
	

Value Representations:

		
			Decimal example: 66
Binary example: 100010b
Hex example: 42h
Register example: %ax
Bit of value example #1 (here is the 5 bit, here it will return 64): 42h$5
Bit of value example #2 (here is the 3 bit, here it will return 0): 42h$3
Bit of value example #3 (here is the 8 bit, here it will return 512): 10110001110b$8
		
	

Flags:

		
			Flags are stored in %flags
Bit 0 of %flags is %ax==0
Bit 1 of %flags is %ax>0
Bit 2 of %flags is %ax<0
Bit 3 of %flags is carry
		
	

Please put your modifications in the comments!



3 comments

Loading...

Next up

Me being the first person to beat the scary dude mode:

WELL FELLAS GUESS WHO'S HERE, NOW INTRODUCING THE NEW PFP IN HEADER AND ONE CHANNEL BECOME THE GAMEJOLT COMMUNITY, AS NOW TO BE GETTING WHEN THE NEW EVENT ONE FOR ANNOUNCEMENTS YA'LL!! | Dandy's World! #DandysWorld #Roblox

it didnt hallucinate

DANDY!!!!🌼🌈

oh hello there @tehnoobyguy you made this right?

Why is the Minecraft Earth listing still up?

Fukuona Girl Taingle (Skin)

[Idk why I made this skin, can I call her "Yippee Fukuona Girl Taingle"?]

im making a datapack what should i add