在汇编中声明和访问字符串(32位Debian CommandLine OS) [英] Declaring and Accessing Strings in Assembly (32-bit Debian CommandLine OS)

查看:48
本文介绍了在汇编中声明和访问字符串(32位Debian CommandLine OS)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,这是一项家庭作业,但我终生无法在网上找到任何可靠的资源来解释教授使用的语法.

First off, this is a homework assignment but I cannot for the life of me find any reliable resources online that explain using the syntax my professor has us using.

我想在这方面先做功课,以免直接得到答案,而是要求解释,以便将来学习.我的教授不是最擅长提供学习这些知识的资源,因此我决定向SO的优秀人才寻求帮助.

I wanted to be up front about this being homework so as not to get an answer straight up but to ask for an explanation so I can learn for future reference. My professor is not the best at providing resources for learning this stuff so I've decided to turn to the great people here at SO for assistance.

任务很简单.使用一个字符串数组(北约军事字母),从用户那里接收一系列单词,然后以军事字母的形式将这些单词输出到屏幕上.

The assignment is fairly straight forward. Using an array of strings (the NATO Military Alphabet), receive a series of words from the user and then output that series of words to the screen in military alphabet.

因此,例如,输入"Feed"被输入.将会输出为:

So for example, the input "Feed" would be output as:

Foxtrot  
Echo  
Echo  
Delta

我的问题很基本.如何在Assembly中声明一个字符串数组(我很确定我使用的是AT& T语法,因为它在变量和寄存器之前使用$和%)?

My question is quite basic. How does one declare a string array in Assembly (I'm fairly certain I'm using AT&T syntax since it using $ and % before variables and registers)?

感谢您的提前帮助!让我知道是否需要详细说明,我很乐意这样做.

Thanks for the help in advance! Let me know if I need to elaborate at all, I'll be happy to do so.

因此,通过评论中的一些解释,到目前为止,我已经提出了用于定义地址数组的方法,这些地址指向军事字母的asciz值.

So with some explanations from the comments, I've come up with this so far for defining an array of addresses which point to asciz values for the military alphabet.

.section .data

Alpha:     .asciz "Alpha"
Beta:      .asciz "Beta"
Charlie:   .asciz "Charlie"
Delta:     .asciz "Delta"
Echo:      .asciz "Echo"
Foxtrot:   .asciz "Foxtrot"
Golf:      .asciz "Golf"
Hotel:     .asciz "Hotel"
India:     .asciz "India"
Juliet:    .asciz "Juliet"
Kilo:      .asciz "Kilo"
Lima:      .asciz "Lima"
Mike:      .asciz "Mike"
November:  .asciz "November"
Oscar:     .asciz "Oscar"
Papa:      .asciz "Papa"
Quebec:    .asciz "Quebec"
Romeo:     .asciz "Romeo"
Sierra:    .asciz "Sierra"
Tango:     .asciz "Tango"
Uniform:   .asciz "Uniform"
Victor:    .asciz "Victor"
Whiskey:   .asciz "Whiskey"
Xray:      .asciz "X-Ray"
Yankee:    .asciz "Yankee"
Zulu:      .asciz "Zulu"

MAlpha:    .long Alpha, Beta, Charlie, Delta, Echo, Foxtrot, Golf, Hotel, India, Juliet, Kilo, Lima, Mike, November, Oscar, Papa, Quebec, Romeo, Sierra, Tango, Uniform, Victor, Whiskey, Xray, Yankee, Zulu

推荐答案

如帖子的编辑所示,在评论的帮助下,我自己回答了这个问题!

As shown in the edit of the post, using some help from the comments, I've answered this myself!

.section .data

Alpha:     .asciz "Alpha"
Beta:      .asciz "Beta"
Charlie:   .asciz "Charlie"
Delta:     .asciz "Delta"
Echo:      .asciz "Echo"
Foxtrot:   .asciz "Foxtrot"
Golf:      .asciz "Golf"
Hotel:     .asciz "Hotel"
India:     .asciz "India"
Juliet:    .asciz "Juliet"
Kilo:      .asciz "Kilo"
Lima:      .asciz "Lima"
Mike:      .asciz "Mike"
November:  .asciz "November"
Oscar:     .asciz "Oscar"
Papa:      .asciz "Papa"
Quebec:    .asciz "Quebec"
Romeo:     .asciz "Romeo"
Sierra:    .asciz "Sierra"
Tango:     .asciz "Tango"
Uniform:   .asciz "Uniform"
Victor:    .asciz "Victor"
Whiskey:   .asciz "Whiskey"
Xray:      .asciz "X-Ray"
Yankee:    .asciz "Yankee"
Zulu:      .asciz "Zulu"

MAlpha:    .long Alpha, Beta, Charlie, Delta, Echo, Foxtrot, Golf, Hotel, India, Juliet, Kilo, Lima, Mike, November, Oscar, Papa, Quebec, Romeo, Sierra, Tango, Uniform, Victor, Whiskey, Xray, Yankee, Zulu

这篇关于在汇编中声明和访问字符串(32位Debian CommandLine OS)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆