Port-arm archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Looking for machine-language doc

I was a little surprised that you can feed assembly through gcc.
Which probably calls as or something but it Just Works.  You can feed
this to gcc and get an a.out file.  Or specify a different output
name.  This demonstrates calling C functions from assembly so you
don't have to write everything from scratch in assembly.

@ scanfExample1.s
@ D. Thiebaut
@ A simple example illustrating how one
@ can call the C function scanf() from
@ assembly.
@ The C example for this code would be:
@	int num = 0;
@	printf( "> " );
@	scanf( "%d", &num );
@	print( "your input: %d\n", num ) ;

@ ---------------------------------------
@	Data Section
@ ---------------------------------------
	.balign 4	
prompt:	.asciz	"> "
format: .asciz 	"%d"
num:	.int	0
output: .asciz 	"your input: %d\n"
@ ---------------------------------------
@	Code Section
@ ---------------------------------------
	.global main
	.extern printf
	.extern scanf

main:   push 	{ip, lr}	@ push return address + dummy register
				@ for alignment

	ldr	r0, =prompt	@ print the prompt
	bl	printf

	ldr     r0, =format	@ call scanf, and pass address of format
	ldr	r1, =num	@ string and address of num in r0, and r1,
	bl	scanf		@ respectively.

	ldr	r1, =num	@ print num formatted by output string.
	ldr	r1, [r1]
	ldr	r0, =output
	bl	printf

        pop 	{ip, pc}	@ pop return address into pc

On 8/16/20, Mouse <mouse%rodents-montreal.org@localhost> wrote:
>>> I'm looking for documentation on ARM machine language [...]
>> I expect you have found the usual:
>>    https://developer.arm.com/support
>>    https://community.arm.com/
> Not very.  arm.com's webpages are remarkably hostile.  Because they've
> drunk the "we won't talk to you unless you use HTTPS" koolaid, I can't
> do anything with them myself.  I have two work devices which can do
> something with them.  On one of them, it's got modal somethings that
> cover up 70-80% of the available screen space, leaving about room
> enough to see some forty words of text, and I hadn't managed to see
> enough through that to find anything useful.  On the other device, it
> says my web browser is not supported, complains (further) about lacking
> javascript, and breaks in assorted ways.
> I suppose it shouldn't surprise me.  The PDF I did manage to find
> indicated quite clearly that they don't understand what the P in PDF
> means; it says, in so many words, they test the PDF in Adobe readers
> and don't care about anything else.  So it fits that they would go to
> the trouble to break their content if I don't emit one of their blessed
> User-Agent: values.  And, they can't even be bothered to tell me what
> browsers _are_ supported, only that mine isn't!  (Fortunately, pdftoppm
> worked just fine on the file.)
>> A couple of bits you may have missed:  [...]
> Thank you; I'll have to have a look at them.
> /~\ The ASCII				  Mouse
> \ / Ribbon Campaign
>  X  Against HTML		mouse%rodents-montreal.org@localhost
> / \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B

No, I won't  call it "climate change", do you have a "reality problem"? - AB1JX
Cities are cages built to contain excess people and keep them from
cluttering up nature.
Impeach  Impeach  Impeach  Impeach  Impeach  Impeach  Impeach  Impeach

Home | Main Index | Thread Index | Old Index