📄 reverser.asm
字号:
;----------------------------------------------------------------------------
; CPSC 355 Example Program
; "Reverser"
; Author: xuan wang
; Date: April 29, 2001
;----------------------------------------------------------------------------
[GLOBAL mystart] ; export the start address
;----------------------------------------------------------------------------
[SECTION .text]
;----------------------------------------------------------------------------
; code belongs in this section starting here
mystart:
mov ah, 09h ; select write string function
mov edx, prompt ; put address of string in EDX
int 0f1h ; call OS interrupt 0F1H
mov byte [buffer], 98 ; buffer can hold 98 characters
mov byte [buffer+1], 0 ; reuse 0 characters from last input
mov ah, 0ah ; select buffered input function
mov edx, buffer ; put buffer address in EDX
int 0f1h ; call OS interrupt 0F1H
mov ah, 02h ; select write character function
mov dl, 10 ; output a newline
int 0f1h
movzx ecx, byte [buffer+1];load ECX with number of characters read
mov esi, buffer+1 ; load adress of input text into ESI
add esi, ecx ; move to end of text
std ; set direction flag to go backwards
mov ah, 02h ; select write character function
top:
lodsb ; grab a character into AL
mov dl, al ; put it into DL for function
int 0f1h ; call OS interrupt 0F1H
loop top ; continue while ECX > 0
mov ah, 02h ; select write character function
mov dl, 13 ; output a carriage return
int 0f1h
mov ah, 02h ; select write character function
mov dl, 10 ; output a newline
int 0f1h
ret
;----------------------------------------------------------------------------
[SECTION .data]
;----------------------------------------------------------------------------
; all initialized data variables and constant definitions go here
prompt db "Enter a string:", 13, 10, "> $"
;----------------------------------------------------------------------------
[SECTION .bss]
;----------------------------------------------------------------------------
; all uninitialized data elements go here
buffer resb 100 ; buffer to store input characters
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -