English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Asm / Hardware

 
 
Thread Tools
Old 06 May 2017, 18:30   #1
paraj
Registered User
 
paraj's Avatar
 
Join Date: Feb 2017
Location: Denmark
Posts: 1,104
Interactive symbolic bitop calculator

I've converted a small tool I've been using (originally written in macro-ridden C++) to run on this newfangled interwebs-gizmo all the cool kids are talking about, and figured some of you might find it useful even in its current work-in-progress state.

It's a small javascript testbed with some m68k-like functions built-in.
The intended purpose is to test / debug small snippets of assembly code. Working with scrambled C2P's is what prompted me to develop the C++ tool - the pen and paper method got too unwieldy.

Click on the "interactive calculator" link at https://github.com/mras0/symbitops (it uses githubs HTML preview feature). It requires a modern browser (I have no idea how modern. I test with Chrome 58, Firfox 53 and Microsoft Edge 40).

The code window contains some hints to get started.

As an example, consider a routine to convert 32-bit RGB data in little endian format to good old 12-bit RGB. Clear the input area and copy the following:
Code:
// Set D0 = symbolic version of our input data
MOVE.L('B7B6B5B4B3B2B1B0 G7G6G5G4G3G2G1G0 R7R6R5R4R3R2R1R0 ????????????????', D0)
// Now run our routine
LSR.W(4, D0)
MOVE.L(D0, D1)
SWAP(D0)
AND.W(0xF0F0, D0)
MOVE.W(D0, D2)
ROL.W(4, D2)
OR.B(D2, D0)
MOVE.B(D0, D1)
// Check that the lower word of D1 is as expected
assert.equal(state[D1].get(16)+'', '........R7R6R5R4 G7G6G5G4B7B6B5B4')
And then press "Run!" (or ctrl+enter), the output should appear below shortly thereafter.

Note that only a subset of 68K instructions are supported.

Oh yeah, and just because I could, there is also an automatic 4-bit C2P code generator. You supply symbolic input and output and it figures out the steps necessary It's a bit slow though (especially in firefox) so give it a minute (literally).

PS: This is my first real web "app", so the code is probably poison to knowledgeable developers.
paraj is offline  
Old 06 May 2017, 19:03   #2
ross
Defendit numerus
 
ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,474
Great!

Link saved
ross is offline  
Old 07 May 2017, 22:13   #3
paraj
Registered User
 
paraj's Avatar
 
Join Date: Feb 2017
Location: Denmark
Posts: 1,104
Continuing my consolidation of various small tools into one, I've added a very (very) basic assembler and cycle counter (probably lacking and buggy). I've also tried making the editor slightly less user-hostile.

The following is now possible (larger examples also work):
Code:
MOVE.B('a3a2a1a0',D0)

lines = parse_lines(`
	lsl.w	#6, d0
	lsr.b	#6, d0
`);

to_code(lines)()
print_cost(lines)
Which gives the following output:
Code:
	MOVE.B	#magic, D0      	; D0 = ???????????????? ???????????????? ???????????????? ........a3a2a1a0
	LSL.W	#$6, D0         	; D0 = ???????????????? ???????????????? ????........a3a2 a1a0............
	LSR.B	#$6, D0         	; D0 = ???????????????? ???????????????? ????........a3a2 ............a1a0
	LSL.W	#6, d0            	18
	LSR.B	#6, d0            	18
	Total (estimated) cost: 36
The "assembler" supports way more instructions than the symbolic evaluater (in particular the evaluater doesn't handle anything involving condition codes), but there still might be missing useful instructions.

As always everything is very much work in progress, so don't expect miracles. If y'all have any reasonable suggestions/requests I'll be happy to look at them.

To be clear, say we want to count (68000) cycles in the 5 instruction loop from https://amycoders.org/opt/innerloops.html. Enter the following in the code text area and press ctrl+enter:
Code:
print_cost(parse_lines(`
.pixel
	move.w	d0,d4		; d4 = VVvv
	move.b	d2,d4		; d4 = VVUU
	move.b	(a0,d4.w),(a5)+
	add.l	d1,d0
	addx.b	d3,d2
	dbf	d7,.pixel
`));
Expected output:
Code:
	MOVE.W	d0, d4           	4
	MOVE.B	d2, d4           	4
	MOVE.B	(a0,d4.w), (a5)+ 	18
	ADD.L	d1, d0            	8
	ADDX.B	d3, d2           	4
	DBF	d7, .pixel          	10
	Total (estimated) cost: 48

Last edited by paraj; 07 May 2017 at 22:26.
paraj is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Amiga calculator cla Coders. Releases 35 30 December 2017 15:00
BPM calculator for Octamed? lordofchaos request.Apps 4 29 May 2013 19:46
looking for kissed - keith's interactive symbolic screen editing debugger copse request.Apps 0 17 April 2012 08:26
Speccy on Ti-89 calculator Fred the Fop Retrogaming General Discussion 3 27 January 2007 02:30
Vintage 1970's Commodore Calculator Steve Retrogaming General Discussion 7 05 February 2003 10:30

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 17:32.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.29209 seconds with 15 queries