- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Microsoft
- >
- Cygwin help
Operating System - Microsoft
1752815
Members
5894
Online
108789
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2007 08:23 PM
01-11-2007 08:23 PM
Cygwin help
well i am stuck on a problem involving cygwin. i am to create a program which is to
run from the command prompt. A buffer should be declared which will hold a character string of an appropriate length (say 80 characters). A menu of options is to be displayed indicating the choices shown below. The user can then enter an option letter between a-d inclusive. The option letter is processed as follows:
Option a - enter a string into buffer.
Option b - display string to the screen.
Option c - encode/decode string using rot13 algorithm.
Option d - program exits.
To read and write characters, you should only make use of the system calls getchar and putchar respectively. To perform the encoding/decoding you should make use of the rot13 subroutine supplied below.
rot13:
# ls byte of edx contains value to be en/decoded
# if char >= 0x41 && char <= 0x5a then uppercase
# if (char+13) > 0x5a then subtract 26
# if char >= 0x61 && char <= 0x7a then lowercase
# if (char+13) > 0x7a then subtract 26
#
cmpb dl, 0x41
jl r13l2
cmpb dl, 0x5a
ja r13l2
# uppercase
addb dl, 13
cmpb dl, 0x5a
jle r13l1
subb dl, 26
r13l1: jmp r13le
r13l2: cmpb dl, 0x61
jl r13le
cmpb dl, 0x7a
ja r13le
# lowercase
addb dl, 13
cmpb dl, 0x7a
jbe r13le # b not l, ignore sign bit!
subb dl, 26
r13le: ret
For assistance i have made a few templatles to start off with but am stuck on it. the templates are as follows:
1.
Template for IA-32 assembly language programs
# comments start with # in column 1
# commands which start with a . (dot) are assembler directives
# which do not generate machine code
.intel_syntax noprefix
.global _main
# put external (system) calls here
.extern _exit
.extern _getchar
.extern _putchar
.data
# declare variables here
.text
_main:
# main program code goes here ...
# for example, a program which adds the values in eax and ebx, stores
# sum in eax
mov eax, 3
mov ebx, 5
add eax, ebx
# programs always end with ...
mov eax, 0
call _exit
# user-defined subroutines(methods) go here ...
# end of program
2.
Program to write two strings, each separated by a newline
Without using user-defined subroutines
.data
s1: .byte 'm','e','s','s','a','g','e','A',0
s2: .byte 'm','e','s','s','a','g','e','B',0
.text
_main:
lea ebx, s1
wrstr1: # ebx contains string pointed to
mov al, [ebx] # get character
wh1:
cmp al, 0
je whe1 # jump if al == 0
whd1:
push ebx
push eax
call _putchar # display on screen
add esp, 4
pop ebx
inc ebx # ebx points to next char
mov al, [ebx] # get character
jmp wh1
whe1:
mov al, 10 # newline
push eax
call _putchar
add esp,4
lea ebx, s2
wrstr2: # ebx contains string pointed to
mov al, [ebx] # get character
wh2:
cmp al, 0
je whe2 # jump if al == 0
whd2:
push ebx
push eax
call _putchar # display on screen
add esp, 4
pop ebx
inc ebx # ebx points to next char
mov al, [ebx] # get character
jmp wh2
whe2:
mov al, 10 # newline
push eax
call _putchar
add esp,4
mov eax, 0 # exit
push eax
call _exit
3.
Example of input character routine
Pseudo code
declare data buffer
set pointer to (1st byte of) buffer
input a char
while not enter(LF) pressed do
store in buffer
increment pointer to next byte of buffer
input next char
end
add null char to define end of string
4.
Assembly language
.data
buffer1: .rept 80 # reserve 80 bytes in memory
.byte 0
.endr
.text
_main:
lea ebx, buffer1
push ebx
call _getchar # input char
# char returned in al
pop ebx
wh1:
cmp al, 0x0a # while not LF do
je end1 #
whd1:
movb [ebx], al # note movb (see note)
inc ebx
push ebx # point to next location
call _getchar # input char
# char returned in al
pop ebx
jmp wh1
end1:
movb [ebx], 0 # make string null terminated, movb again
So can anyone help me with this??
run from the command prompt. A buffer should be declared which will hold a character string of an appropriate length (say 80 characters). A menu of options is to be displayed indicating the choices shown below. The user can then enter an option letter between a-d inclusive. The option letter is processed as follows:
Option a - enter a string into buffer.
Option b - display string to the screen.
Option c - encode/decode string using rot13 algorithm.
Option d - program exits.
To read and write characters, you should only make use of the system calls getchar and putchar respectively. To perform the encoding/decoding you should make use of the rot13 subroutine supplied below.
rot13:
# ls byte of edx contains value to be en/decoded
# if char >= 0x41 && char <= 0x5a then uppercase
# if (char+13) > 0x5a then subtract 26
# if char >= 0x61 && char <= 0x7a then lowercase
# if (char+13) > 0x7a then subtract 26
#
cmpb dl, 0x41
jl r13l2
cmpb dl, 0x5a
ja r13l2
# uppercase
addb dl, 13
cmpb dl, 0x5a
jle r13l1
subb dl, 26
r13l1: jmp r13le
r13l2: cmpb dl, 0x61
jl r13le
cmpb dl, 0x7a
ja r13le
# lowercase
addb dl, 13
cmpb dl, 0x7a
jbe r13le # b not l, ignore sign bit!
subb dl, 26
r13le: ret
For assistance i have made a few templatles to start off with but am stuck on it. the templates are as follows:
1.
Template for IA-32 assembly language programs
# comments start with # in column 1
# commands which start with a . (dot) are assembler directives
# which do not generate machine code
.intel_syntax noprefix
.global _main
# put external (system) calls here
.extern _exit
.extern _getchar
.extern _putchar
.data
# declare variables here
.text
_main:
# main program code goes here ...
# for example, a program which adds the values in eax and ebx, stores
# sum in eax
mov eax, 3
mov ebx, 5
add eax, ebx
# programs always end with ...
mov eax, 0
call _exit
# user-defined subroutines(methods) go here ...
# end of program
2.
Program to write two strings, each separated by a newline
Without using user-defined subroutines
.data
s1: .byte 'm','e','s','s','a','g','e','A',0
s2: .byte 'm','e','s','s','a','g','e','B',0
.text
_main:
lea ebx, s1
wrstr1: # ebx contains string pointed to
mov al, [ebx] # get character
wh1:
cmp al, 0
je whe1 # jump if al == 0
whd1:
push ebx
push eax
call _putchar # display on screen
add esp, 4
pop ebx
inc ebx # ebx points to next char
mov al, [ebx] # get character
jmp wh1
whe1:
mov al, 10 # newline
push eax
call _putchar
add esp,4
lea ebx, s2
wrstr2: # ebx contains string pointed to
mov al, [ebx] # get character
wh2:
cmp al, 0
je whe2 # jump if al == 0
whd2:
push ebx
push eax
call _putchar # display on screen
add esp, 4
pop ebx
inc ebx # ebx points to next char
mov al, [ebx] # get character
jmp wh2
whe2:
mov al, 10 # newline
push eax
call _putchar
add esp,4
mov eax, 0 # exit
push eax
call _exit
3.
Example of input character routine
Pseudo code
declare data buffer
set pointer to (1st byte of) buffer
input a char
while not enter(LF) pressed do
store in buffer
increment pointer to next byte of buffer
input next char
end
add null char to define end of string
4.
Assembly language
.data
buffer1: .rept 80 # reserve 80 bytes in memory
.byte 0
.endr
.text
_main:
lea ebx, buffer1
push ebx
call _getchar # input char
# char returned in al
pop ebx
wh1:
cmp al, 0x0a # while not LF do
je end1 #
whd1:
movb [ebx], al # note movb (see note)
inc ebx
push ebx # point to next location
call _getchar # input char
# char returned in al
pop ebx
jmp wh1
end1:
movb [ebx], 0 # make string null terminated, movb again
So can anyone help me with this??
1 REPLY 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2007 04:14 AM
06-21-2007 04:14 AM
Re: Cygwin help
I am confused as to how this relates to help with cygwin. Looks as if you are asking for help with assembly.
"The difference between me and you? I will read the man page." and "Respect the hat." and "You could just do a search on ITRC, you don't need to start a thread on a topic that's been answered 100 times already." Oh, and "What. no points???"
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP