53 lines
707 B
ArmAsm
53 lines
707 B
ArmAsm
|
extern printf
|
||
|
extern scanf
|
||
|
|
||
|
;;;;;;;;;;;;
|
||
|
;;; TEXT ;;;
|
||
|
;;;;;;;;;;;;
|
||
|
section .text
|
||
|
global main
|
||
|
main:
|
||
|
sub rsp, 8
|
||
|
|
||
|
xor rcx, rcx
|
||
|
|
||
|
.loop:
|
||
|
lea rdi, [rel format]
|
||
|
lea rsi, [rel operation]
|
||
|
lea rdx, [rel count]
|
||
|
xor ax, ax
|
||
|
call scanf
|
||
|
|
||
|
xor rax, rax
|
||
|
mov eax, [rel count]
|
||
|
cmp byte [rel operation], '+'
|
||
|
je .add
|
||
|
neg rax
|
||
|
.add:
|
||
|
add rcx, rax
|
||
|
|
||
|
push rcx
|
||
|
lea rdi, [rel message]
|
||
|
mov rsi, rcx
|
||
|
xor ax, ax
|
||
|
call printf
|
||
|
pop rcx
|
||
|
|
||
|
jmp .loop
|
||
|
|
||
|
|
||
|
add rsp, 8
|
||
|
ret
|
||
|
|
||
|
;;;;;;;;;;;;
|
||
|
;;; DATA ;;;
|
||
|
;;;;;;;;;;;;
|
||
|
section .data
|
||
|
format: db "%c%d",0
|
||
|
message: db "%d",10,0
|
||
|
|
||
|
section .bss
|
||
|
buffer: resb 64
|
||
|
operation: resb 1
|
||
|
count: resb 4
|