Skip to contentSkip to conversation

Make a Calculator! Help-me

DISCUSSION Guilherme Romao 4 participants 4 messages Apr 18, 2003

lore
Share & tools
lore
#0 lore raw

Hi, this is my source of my calculator:
How I can to make the addition? Thank You!

.file "calculator.s"
.version "01"
gcc2_compiled.:
.section .data
.msg:

	.string "\t\tCalculator in Assembly\n"
	tam: .long .- .msg
.pede1:
	.string "1 number: "
	tpede1: .long .- .pede1
.pede2:
	.string "2 number: "
	tpede2: .long .- .pede2

.result:
.string "The result is"
tresult: .long .- .result
.text
.align 4
.globl main
.type main,@function
main:

pushl %ebp
movl %esp,%ebp
movl $0x4,%eax
movl $0x1,%ebx
movl $.msg,%ecx
movl tam, %edx
int $0x80

movl $0x4,%eax
movl $0x1,%ebx
movl $.pede1,%ecx
movl tpede1,%edx
int $0x80

movl %esp,%ecx
subl $0xb,%esp

movl $0x3,%eax
movl $0xa,%edx
int $0x80

movl %eax,%edx
pushl %edx
movl %esp,%ebp
movl $0x4,%eax
movl $0x1,%ebx
int $0x80

movl $0x4,%eax
movl $0x1,%ebx
movl $.pede2, %ecx
movl tpede2, %edx
int $0x80

movl %esp,%ecx
subl $0xb,%esp

movl $0x3,%eax
movl $0xa,%edx
int $0x80

movl %eax, %edx
pushl %edx
movl $0x4,%eax
movl $0x1,%ebx
int $0x80

movl $0x4,%eax
movl $0x1,%ebx
movl $.result,%ecx
movl tresult,%edx
int $0x80

subl %ebp,%edx
movl $0x4,%eax
movl $0x1,%ebx

int $0x80

movl $0x1,%eax
movl $0x0,%ebx
int $0x80

.L1:
leave
ret
.Lfe1:

	.size main,.Lef1-main
	.ident "my"
Signature · 5 lines
______________________________________________
http://www.linuxmail.org/
Now with e-mail forwarding for only US$5.95/yr

Powered by Outblaze
#1 lore raw

Guilherme Romao am Freitag, 18. April 2003 03:47:

Quoted 2 lines

Hi, this is my source of my calculator:
How I can to make the addition? Thank You!

is this a GNU program?
"no docs better than a manual page" or any other kind of description...

best,
hp

Signature · 2 lines
Linux,Assembly,Forth: http://www.lxhp.in-berlin.de/index-lx.shtml en/de
  pse, reply to << lx -at- lxhp -dot- in-berlin -dot- de >>
#2 lore raw
Quoted 7 lines · hp

Guilherme Romao am Freitag, 18. April 2003 03:47:

Quoted 2 lines

Hi, this is my source of my calculator:
How I can to make the addition? Thank You!

is this a GNU program?
"no docs better than a manual page" or any other kind of description...

http://www.gnu.org/manual/bc-1.06/html_mono/bc.html

Signature · 1 line
Maciej Hrebien
#3 lore raw
In reply to Guilherme Romao

Guilherme Romao am Freitag, 18. April 2003 03:47:

Quoted 2 lines

Hi, this is my source of my calculator:
How I can to make the addition? Thank You!

honestly, do you expect your readers to analysing your(?) example to be able to send the appropriate reply? at least, I myself won't bother with anything meaningless like your(?) piece of asm text.
so, please, add some comments which fully explain what it is supposed to do - e.g. I won't look for syscall numbers which the linux sources provide by their rsp names (the numbers may change!); &c.

plus, probably, while doing so you yourself might even better understand what the concerned program segment does...

the examples which you were asking for are already mentioned or, can be found in the links page at http://linuxassembly.org

best
hp

Quoted 4 lines

.file "calculator.s"
.version "01"
gcc2_compiled.:

	[...]
Signature · 2 lines
Linux,Assembly,Forth: http://www.lxhp.in-berlin.de/index-lx.shtml en/de
  pse, reply to << lx -at- lxhp -dot- in-berlin -dot- de >>