Jump to content

Terminal control/Clear the screen: Difference between revisions

Add task to ARM assembly Raspberry pi
(Add task to ARM assembly Raspberry pi)
Line 79:
Ada.Text_IO.Put(ASCII.ESC & "[2J");
end CLS;</lang>
 
=={{header|ARM Assembly}}==
{{works with|as|Raspberry Pi}}
<lang ARM Assembly>
 
/* ARM assembly Raspberry PI */
/* program clearScreen.s */
 
/* Constantes */
.equ STDOUT, 1 @ Linux output console
.equ EXIT, 1 @ Linux syscall
.equ WRITE, 4 @ Linux syscall
 
.equ BUFFERSIZE, 100
 
/* Initialized data */
.data
szMessStartPgm: .asciz "Program start \n"
szMessEndPgm: .asciz "Program normal end.\n"
szClear: .asciz "\33[2J" @ console clear (id language C)
szClear1: .byte 0x1B
.byte 'c' @ other console clear
.byte 0
szCarriageReturn: .asciz "\n"
 
/* UnInitialized data */
.bss
 
/* code section */
.text
.global main
main:
 
ldr r0,iAdrszMessStartPgm @ display start message
bl affichageMess
//ldr r0,iAdrszClear @ clear screen
ldr r0,iAdrszClear1 @ change for other clear screen
bl affichageMess
ldr r0,iAdrszMessEndPgm @ display end message
bl affichageMess
 
100: @ standard end of the program
mov r0, #0 @ return code
mov r7, #EXIT @ request to exit program
svc 0 @ perform system call
iAdrszMessStartPgm: .int szMessStartPgm
iAdrszMessEndPgm: .int szMessEndPgm
iAdrszClear: .int szClear
iAdrszClear1: .int szClear1
iAdrszCarriageReturn: .int szCarriageReturn
 
/******************************************************************/
/* display text with size calculation */
/******************************************************************/
/* r0 contains the address of the message */
affichageMess:
push {r0,r1,r2,r7,lr} @ save registers
mov r2,#0 @ counter length */
1: @ loop length calculation
ldrb r1,[r0,r2] @ read octet start position + index
cmp r1,#0 @ if 0 its over
addne r2,r2,#1 @ else add 1 in the length
bne 1b @ and loop
@ so here r2 contains the length of the message
mov r1,r0 @ address message in r1
mov r0,#STDOUT @ code to write to the standard output Linux
mov r7, #WRITE @ code call system "write"
svc #0 @ call system
pop {r0,r1,r2,r7,lr} @ restaur registers
bx lr @ return
 
</lang>
 
=={{header|AutoHotkey}}==
Cookies help us deliver our services. By using our services, you agree to our use of cookies.